Sending and managing messages
Send and reply
Section titled “Send and reply”const general = community.channels.find((c) => c.name === "general");const sent = await general.send("hello");await sent.reply("replying to myself");let general = community.channel_by_name("general").expect("a general channel");let sent = general.send("hello")?;sent.reply("replying to myself")?;Edit, delete, react
Section titled “Edit, delete, react”const message = await general.send("typo");await message.edit("fixed");await message.react("👍");await message.delete();let mut message = general.send("typo")?;message.edit("fixed")?;message.react("👍")?;message.delete()?;You can edit and delete your own messages; deleting someone else’s needs MANAGE_MESSAGES.
History
Section titled “History”The client keeps no message history of its own; fetch pages from the host:
const latest = await general.messages.fetch({ limit: 50 });// Up to 50 messages before sequence number `before` (the newest without it), oldest first.let latest = general.messages(None, 50)?;Partial messages
Section titled “Partial messages”An edit or deletion event only says what changed, so it carries a partial message: its id, and
for an edit its new text. It still acts (reply, edit, delete, react), but fields the event
didn’t include are empty.