discord.Message
discord.Message
https://pylon.bot/docs/reference/classes/discord.message.html
A discord.Message
instance represents a message on Discord.
Messages extend past simple messages sent by users. They may be special system messages like member join or boost messages (if enabled for the guild), messages sent via Discord Webhooks, or even messages broadcasted from other guilds using Announcement channels.
Message Sub-Types
discord.GuildMemberMessage
discord.Message
has a child class called discord.GuildMemberMessage
which represents a Discord message where type
is 0
(DEFAULT) and has a member
field present. Any message sent by a real Discord user (or another Bot) in a guild will be of this type.
You can check for this type in an event handler to prevent processing system messages that may result in errors.
Outgoing Messages
Sending messages is easy. Check out the discord.OutgoingMessage
, which is accepted by GuildTextChannel.sendMessage(...)
and Message.reply(...)
.
Sending Typing Events
Sometimes a response to a command may take some time to compute. Any method that accepts an OutgoingMessage may also consume a Promise\<OutgoingMessage>. When you use a Promise, a "typing" indicator is sent giving your bot a more natural feel.
If the promise resolves within 50ms, the typing event will not be sent.
Message Embeds
Discord allows us to send Rich Embed objects attached to messages that render as nice info boxes in chat.
(An example of a rich embed)
For all the Embed options and properties, check out the SDK Reference for Embed objects:
https://pylon.bot/docs/reference/classes/discord.embed.html
Below is an example of a command !userinfo @user
that replies with a rich embed containing information about the user. It will look similar to the one pictured above.