DiscordHelper
How to register Web Hook URL
How to register Web Hook URL
use NewThing\DiscordHelper\DiscordHelper;
DiscordHelper::setURL($YourWebHookURL);
EX)
protected function onLoad(): void
{
DiscordHelper::setURL('https://discordapp.com/api/webhooks/kscwiqgdieidwowpsdwvdo');
//It is not really web hook =)
}
How to send discorrd message
How to send discord embed
How to send discord embed
use NewThing\DiscordHelper\DiscordHelper;
use NewThing\DiscordHelper\Embed;
use NewThing\DiscordHelper\EmbedColor;
$embed = new Embed($content);
$embed = new Embed('THIS IS TITLE', $color); //If you want to set custom color, you put hexdec( "6 digit color code" ) in $color
DiscordHelper::send($embed->call());
Other funtions of Message
$embed->setDescription("THIS IS DESCRIPTION");
$embed->setFooter('THIS IS FOOTER', $icon_url);
$embed->setImage($image_url);
$embed->setAuthor('THIS IS AUTHOR', $link);
$embed->addField('FIELD 1','THIS IS INLINE FIELD',true);
$embed->addField('FIELD 2','THIS IS OUTLINE FIELD',false);
$embed->setBotName('HOOK BOT NAME CHANGE TEST');
$embed->setTTS(true or false);
Embed color list
Color list
use NewThing\DiscordHelper\EmbedColor;
EmbedColor::DEFAULT;
EmbedColor::WHITE;
EmbedColor::AQUA;
EmbedColor::GREEN;
EmbedColor::BLUE;
EmbedColor::YELLOW;
EmbedColor::PURPLE;
EmbedColor::LUMINOUS_VIVID_PINK;
EmbedColor::FUCHSIA;
EmbedColor::GOLD;
EmbedColor::ORANGE;
EmbedColor::RED;
EmbedColor::GREY;
EmbedColor::NAVY;
EmbedColor::DARK_AQUA;
EmbedColor::DARK_GREEN;
EmbedColor::DARK_BLUE;
EmbedColor::DARK_PURPLE;
EmbedColor::DARK_VIVID_PINK;
EmbedColor::DARK_GOLD;
EmbedColor::DARK_ORANGE;
EmbedColor::DARK_RED;
EmbedColor::DARK_GREY;
EmbedColor::DARKER_GREY;
EmbedColor::LIGHT_GREY;
EmbedColor::DARK_NAVY;
EmbedColor::BLURPLE;
EmbedColor::GREYPLE;
EmbedColor::DARK_BUT_NOT_BLACK;
EmbedColor::NOT_QUITE_BLACK;
Example
<?php
declare(strict_types=1);
/**
* @name Discord
* @api 4.0.0
* @version 0.1
* @author MIN
* @main Min\Discord
*/
namespace Min;
use NewThing\DiscordHelper\DiscordHelper;
use NewThing\DiscordHelper\Embed;
use NewThing\DiscordHelper\EmbedColor;
use NewThing\DiscordHelper\Message;
use pocketmine\plugin\PluginBase;
class Discord extends PluginBase
{
protected function onLoad(): void
{
DiscordHelper::setURL('set your web hook url');
}
protected function onEnable(): void
{
$this->sendEmbed();
$this->sendMessage();
}
private function sendEmbed(): void
{
$embed = new Embed('THIS IS TITLE', EmbedColor::RED);
$embed->setBotName('HOOK BOT NAME CHANGE TEST');
$embed->addField('FIELD 1', 'THIS IS INLINE FIELD 1', true);
$embed->addField('FIELD 2', 'THIS IS INLINE FIELD 2', true);
$embed->addField('FIELD 3', 'THIS IS INLINE FIELD 3', true);
$embed->addField('FIELD 4', 'THIS IS INLINE FIELD 4', true);
$embed->addField('FIELD 5', 'THIS IS INLINE FIELD 5', true);
$embed->addField('FIELD 6', 'THIS IS INLINE FIELD 6', true);
$embed->addField('FIELD 1', 'THIS IS OUTLINE FIELD 1', false);
$embed->addField('FIELD 2', 'THIS IS OUTLINE FIELD 2', false);
$embed->addField('FIELD 3', 'THIS IS OUTLINE FIELD 3', false);
$embed->setDescription('THIS IS DESCRIPTION');
$embed->setImage('https://cdn.discordapp.com/icons/903992974285869076/04401aecf133a04bd8c3efa678cecb2a.webp?size=96');
$embed->setAuthor('THIS IS AUTHOR', 'https://github.com/MIN0707');
$embed->setFooter('THIS IS FOOTER', 'https://cdn.discordapp.com/icons/903992974285869076/04401aecf133a04bd8c3efa678cecb2a.webp?size=96');
DiscordHelper::send($embed->call());
}
private function sendMessage(): void
{
$message = new Message('THIS IS CONTENT');
$message->setTTS(true);
$message->setBotName('HOOK BOT NAME CHANGE TEST');
DiscordHelper::send($message->call());
}
}