-
Notifications
You must be signed in to change notification settings - Fork 237
Reaction
Reactions are part of Message.
use Discord\Parts\Channel\Reaction;
Represents a reaction to a message by members(s).
Requires GUILD_MESSAGE_REACTIONS
intent for guild, or DIRECT_MESSAGE_REACTIONS
intent for direct message
Your BOT must have add_reactions
permission
You must first get the Message object to use the code below
Adds a reaction $emoji
to the $message
:
$message->react($emoji)->then(function () {
// ...
})->done();
https://discord.com/developers/docs/resources/channel#create-reaction
Or with Unicode Emoji:
$message->react('😀')->then(function () {
// ...
})->done();
Or with Custom Emoji:
$message->react(':michael:251127796439449631')->then(function () {
// ...
})->done();
Your BOT must have manage_messages
permission (except REACT_DELETE_ME
)
You must first get the Message object to use the code below
(e.g. delete all [😀1][❤️2])
$message->deleteReaction(Message::REACT_DELETE_ALL)->then(function () {
// ...
})->done();
https://discord.com/developers/docs/resources/channel#delete-all-reactions
(e.g. the bot reacted 😀 so [😀4] becomes [😀3]):
$message->deleteReaction(Message::REACT_DELETE_ME, $emoji)->then(function () {
// ...
})->done();
https://discord.com/developers/docs/resources/channel#delete-own-reaction
(e.g. an user reacted 😀 so [😀2] becomes [😀1]), change 123123123123123123
with User ID:
$message->deleteReaction(Message::REACT_DELETE_ID, $emoji, '123123123123123123')->then(function () {
// ...
})->done();
https://discord.com/developers/docs/resources/channel#delete-user-reaction
(e.g. deleting 😂 from [😀1][😂4][❤️2] becomes [😀1][❤️2])
$message->deleteReaction(Message::REACT_DELETE_EMOJI, $emoji)->then(function () {
// ...
})->done();
https://discord.com/developers/docs/resources/channel#delete-all-reactions-for-emoji
You must first get the Message object to use the code below. Change 😀
below with the emoji you want to retrieve
Cached, synchronous:
$reaction = $message->reactions->get('id', '😀');
If the code above returns null
, you may need to fetch it first (Promise, asynchronous):
$message->reactions->fetch('😀')->then(function (Reaction $reactions) {
// ...
})->done();
https://discord.com/developers/docs/resources/channel#get-reactions
Note: This wiki is currently Work In Progress. Consider reading the docs instead.
- Application Command (Slash based)
Command Client (Message based)
- Activity
- Application
- Guild
- Private Channel
- User
Components
-
ActionRow
- Buttons
- Option (commands)
- SelectMenu
- TextInput
Builders