frankie813 / discord-embed-messages
一个用于创建并向 Discord 频道发送具有按钮和选择菜单等交互组件的嵌入消息的 Laravel 扩展包。
0.0.1
2023-04-18 22:14 UTC
This package is not auto-updated.
Last update: 2024-10-03 03:30:10 UTC
README
一个用于创建并向 Discord 频道发送具有按钮和选择菜单等交互组件的嵌入消息的 Laravel 扩展包。
安装
使用 Composer 安装包
composer require frankie813/discord-embed-message
用法
要使用此包,首先使用您的机器人令牌创建 DiscordEmbedMessage 类的新实例
use Frankie813\DiscordEmbedMessage\DiscordEmbedMessage;
// ...
$botToken = 'YOUR_BOT_TOKEN';
$message = new DiscordEmbedMessage($botToken);
然后,使用提供的方法自定义您的嵌入消息并添加交互组件
$message->addTitle('Title')
->addDescription('Description')
->addColor('#FF0000')
->addAuthor('Author Name', 'https://author-url.com', 'https://author-icon-url.com')
->addTimestamp()
->addImage('https://image-url.com')
->addField('Field Name', 'Field Value', true)
->addFooter('Footer Text', 'https://footer-icon-url.com')
->addThumbnail('https://thumbnail-url.com')
->addMentionRole('ROLE_ID')
->addButton('Button Label', 1, 'custom_id', null, false)
->addSelectMenu('select_menu_custom_id', 'Select Menu Placeholder', [['label' => 'Option 1', 'value' => 'option1'], ['label' => 'Option 2', 'value' => 'option2']]);
最后,使用 sendEmbed 方法将嵌入消息发送到指定的频道
$channelId = 'YOUR_CHANNEL_ID';
$response = $message->sendEmbed($channelId);
方法
以下是 DiscordEmbedMessage 类可用的方法
addTitle($title)
addDescription($description)
addColor($color)
addAuthor($name, $url = null, $icon_url = null)
addTimestamp($timestamp = null)
addImage($url)
addField($name, $value, $inline = false)
addFooter($text, $icon_url = null)
addThumbnail($url)
addMentionRole($roleId)
addButton($label, $style, $custom_id, $url = null, $disabled = false)
addSelectMenu($custom_id, $placeholder, $options, $min_values = 1, $max_values = 1, $disabled = false)
sendEmbed($channelId)
许可证
此包是开源软件,许可协议为 MIT 许可。