send(): a channel, a user, a member, a webhook. A message is a text, or an object with everything it contains.
src/commands/announce.ts
channel is the channel the command was used in, and send() posts there. The message is checked before it leaves (a text over 2000 characters, too many embeds…): a mistake is an error in your code with a plain message, not a refusal of Discord.
Every field a message takes is in Message options, and everything a message you receive has is in Message.
Where a message goes
They all take the same thing. A text:
send() returns the Message that was sent, so you can react to it, pin it or edit it later.
Replying
message.reply() answers a message in its channel: Discord shows the message it answers above yours.
allowedMentions:
send() can reply too: pass the message (or its id) as replyTo.
Embeds
An embed is a box with a title, a description, fields, an image, a footer… Pass up to 10 inembeds:
Files
The pictures and documents your bot sends live in thepublic/ folder of your project, next to src/. asset() picks one: your editor lists every file of the folder as you type, and a path that does not exist is underlined.
src/commands/chart.ts
name; spoiler: true hides it until it is clicked. Two files of one message can’t have the same name: Discord tells them apart by it.
In chapterjs dev, a file added to public/ is offered by the editor right away:
Buffer, a Uint8Array, an ArrayBuffer or a Blob. Up to 10 files per message, from public/ or made, together.
A text too long for a message can go in a file instead:
Mentions
A mention is a text: write it incontent with the helpers of ChapterJS, or with what a structure gives when put in a text (${member}, ${channel}, ${role}).
allowedMentions says who really gets a notification, whatever the text contains:
parseis the kinds of mentions of the text that notify:['users'],['roles'],['everyone'], or[]for nobody.usersandroleslist the ids that may be notified, whateverparsesays.
userMention, roleMention, channelMention, timestamp…) are listed in Helpers.
Polls
A poll is a question with up to 10 answers. People vote in Discord; the poll closes afterduration hours (24 by default).
Editing
message.edit() changes a message the bot wrote: its text, its embeds, its components, its files, and whether the previews of its links show. Only what you pass changes.
edit() accepts is listed in MessageEditOptions.
Deleting
message.delete() deletes one message; the reason goes to the audit log of the server.
channel.bulkDelete() takes messages or ids and returns how many were deleted. Discord refuses to delete messages older than two weeks in bulk: they are left out.
Reacting
message.react() adds a reaction of the bot: a standard emoji, or a custom emoji of the server, as Discord writes it (<:name:id>) or as one of guild.emojis.
message.reactions lists the reactions a message has, with how many of each; fetchReactionUsers() asks who reacted with one emoji. removeReaction() removes the reaction of the bot (or of a given user), clearReactions() removes every reaction, or every reaction of one emoji.
Pinning
message.pin() and message.unpin() pin and unpin a message in its channel; channel.fetchPins() lists the pinned messages, latest pin first.
Reading the history
channel.fetchMessages() asks Discord for the latest messages of a channel, newest first, 100 at most per call. before, after and around pick where to read from, so you can go further back:
channel.fetchMessage(id) gets one message by its id. channel.messages is what the bot remembers of the channel without asking Discord: it is empty by default, since most bots never read an old message. See what the bot remembers.
Buttons, menus and layout
A message can hold buttons and select menus, declared withbutton() and select(), which run your code when they are used, and be built out of texts, sections, galleries and containers instead of a text and embeds:
src/commands/vote.ts
src/components/yes.ts
components only takes what ChapterJS made, never JSON: the ids that tell a click apart are written by the framework. How to write them is in Buttons, Select menus, Forms and Embeds and layout.
Events about messages
React when a message is sent, edited or deleted.
Message options
Every field a message takes, with the limits.