Sending Messages
The basic feature of Discord Bots is sending messages across Discord. That's why here we will see how to send messages with Seyfert.
First of all, we need to set up a basic Hello World
command.
Having set up our basic Hello World
command, we are now ready to send our first message using the CommandContext.write()
function.
The CommandContext.write()
function will respond to the command.
EditOrReply
But what if we want to respond to the command or edit its response instead of just replying?
We can use the CommandContext.editOrReply()
function. This function is used to reply to the command, or if a reply has already been sent, it will edit it.
This function is very useful if we want to develop a command that responds to the command or, if the command has been answered, edits the response. If we are only using a simple CommandContext.write()
, a response will be sent in all cases.
Here’s an example of how to implement this function.
Sending Messages Without a Response
While reading this guide, you may have thought about the possibility of simply sending a message to a channel instead of responding to a command.
Here we are. To send a simple message to a specific channel, we need to get its ID and then access the BaseClient.messages
property and use the write
function.
Here’s an example of how to send that message without replying to a command:
Sending Embeds
Discord adds the ability to send embedded messages within a channel.
To send these embedded messages with Seyfert, we need to construct the embed using the Embed builder. For more information about customizing the embedded message, you can check out the Embed builder within this documentation.
Here’s an example of how to send an embed with a custom title and description.
Sending Components Attached to the Message
Discord includes the ability to send components attached to a message within an ActionRow
. These components can be Buttons
or SelectMenus
.
Components are stored in an ActionRow
, which can contain up to 5 different buttons and only one select menu and cannot contain another ActionRow inside.
In this example, we are going to send two action rows within the message. Each row will have a button and a string select menu attached, respectively.
For more information about components
For more information about components, check out the component guide.