Returned from actionRowComponent
Returned from buttonComponent
Options for buttonComponent
Whether the button is disabled. This can be anti-accessibility, so consider an alternative, like showing an error on click, or hiding the button entirely.
An emoji displayed on the button. If you only want to show an emoji, pass an empty string for the label.
The text to display on the button
Called when the button is clicked
The color and intent of the button.
The context object received by button onClick handlers. See buttonComponent
Basic information about the commands currently added
The name of the command
Returned from embedComponent
Options for creating a gatekeeper instance
A Discord.JS client
An absolute path to a folder with command files.
Each file should export default
a function to accept a gatekeeper instance
and add commands to it.
// main.ts
Gatekeeper.create({
commandFolder: join(__dirname, "commands"),
})
// commands/ping.ts
export default function addCommands(gatekeeper) {
gatekeeper.addCommand({
name: "ping",
description: "Pong!",
run: (ctx) => ctx.reply(() => "Pong!"),
})
}
Show colorful debug logs in the console
The name of the bot, used for logger messages
Called when any error occurs. You can use this to log your own errors, send them to an error reporting service, etc.
Where commands should be registered.
guild
- Register commands in all guilds (servers) that the bot joins, which appear immediately.
This is the default, and recommended for testing, or if your bot is just in a few guilds.
global
- Register commands globally, which can take a few minutes or an hour to show up.
Since bots have a global command limit, this is good for when your bot grows beyond just a few servers.
both
- Register commands in both guilds and globally.
See the discord docs for more info: https://discord.com/developers/docs/interactions/application-commands#registering-a-command
Base type for all context objects
The channel that this interaction took place in.
Defer a reply, which shows a loading message. Useful if your command might take a long time to reply.
Same as {@link InteractionContext.defer defer}, but shows the loading message only to the interacting user.
Like {@link InteractionContext.reply reply}, but only shows the message to the interacting user.
This does not return a reply handle; ephemeral replies can't be updated or deleted manually
The guild that this interaction took place in.
The guild member for the user that triggered this interaction
Create a new reply for this interaction. This reply can be updated over time via interactions, or via manual {@link ReplyHandle.refresh refresh} calls
The user that triggered this interaction. For buttons, this is the user that clicked the button, and so on
Returned from linkComponent
Options for the link component
An emoji displayed on the button. If you only want to show an emoji, pass an empty string for the label.
The text to display on the button
The URL to open when the button is clicked
Options for creating a message command. Shows when right-clicking a message.
Aliases: alternate names to call this command with
The name of the command. This shows up in the context menu for messages.
The function to call when the command is ran.
The context object received when running a message command
The function passed to context.reply
Anything that can be rendered in a reply.
\n
will also add a new line.undefined
, null
) is ignoredAny reply component object
Returned from {@link InteractionContext.reply}, for arbitrarily doing stuff with a reply message
Delete the message. After this point, {@link ReplyHandle.message message} will be undefined
The discord message associated with this reply
Refresh the reply message.
Gatekeeper will call this automatically on a component interaction, but you can do so yourself when you want to update the message outside of a component interaction
Returned from selectMenuComponent
Options passed to selectMenuComponent
The maximum number of options that can be selected. Passing this option will enable multi-select, and can't be greater than the number of options.
The minimum number of options that can be selected. Passing this option will enable multi-select, and can't be 0.
Called when one or more options are selected. Use this callback to update your current selected state.
Note: For multi-select ({@link SelectMenuComponentOptions.maxValues}), this doesn't get called immediately. It only gets called after clicking away from the select dropdown.
The array of options that can be selected. Same structure as MessageSelectOptionData from DJS
The placeholder text to display when no options are selected
The currently selected option value(s).
This accepts Iterable
, so you can pass an array, a Set,
or any other kind of iterable.
Context object passed to {@link SelectMenuComponentOptions.onSelect}
Configuration for a slash command. See Gatekeeper.addSlashCommand
Aliases: alternate names to call this command with
The description of the command. Shows up when showing a list of the bot's commands
The name of the command. e.g. If you pass the name "airhorn", the command will be run with /airhorn in Discord
An object of options for the command, also called arguments, or parameters.
The function to run when the command is called. Receives a SlashCommandInteractionContext object as the first argument.
The interaction context for a slash command
A resolved mentionable option for a slash command
A potential choice for a slash command option
A possible option for a slash command. See SlashCommandOptionValueMap for a list of possible options and the values they resolve to.
Shared properties for all slash command option types
Description for the option, shows up when tabbing through the options in Discord
Whether the option is required. If true, the value will be guaranteed to exist in the options object, otherwise it will be undefined
Valid slash command option config, only used for typescript inference
A map of option types to the kind of value it resolves to. e.g. If an option has a type of "NUMBER", it will resolve to a number.
This is the magic that takes your option config and gives you a typesafe object of values.
Represents the text in a message
A gatekeeper-specific type representing top-level components, stuff that doesn't need an extra wrapper.
For example, a button isn't top level, as it needs to be wrapped in an action row
Options for creating a user command. Shows when right-clicking on a user.
Aliases: alternate names to call this command with
The name of the command. This shows up in the context menu for users.
The function to call when the command is ran.
A component that represents a Discord action row and follows the same limitations (max 5 buttons, max 1 select, can't mix both).
You usually don't have to use this yourself; Gatekeeper will automatically create action rows for you. But if you have a specific structure in mind, you can still use this.
context.reply(() => [
// normally, these two buttons would be on the same line,
// but you can use action row components to put them on different lines
actionRowComponent(
buttonComponent({
// ...
}),
),
actionRowComponent(
buttonComponent({
// ...
}),
),
])
Represents a discord button component. Does not support URL or disabled props yet.
context.reply(() => (
buttonComponent({
label: "Click me!",
onClick: context => {
context.reply(() => "You clicked me!"),
},
}),
))
Creates an embed component. Accepts MessageEmbedOptions, or a DJS MessageEmbed instance.
context.reply(() => [
embedComponent({
title: "Your weather today 🌤",
description: `Sunny, with a 12% chance of rain`,
footer: {
text: "Sourced from https://openweathermap.org/",
},
}),
])
Creates a link component, which is a button that opens a URL when clicked.
Represents a Discord select menu component.
let selected
context.reply(() =>
selectMenuComponent({
options: [
{ label: "option 1", value: "option 1" },
{ label: "option 2", value: "option 2" },
],
placeholder: "select one",
selected,
onChange: (values) => {
selected = values[0]
},
}),
)
Generated using TypeDoc
A valid child of actionRowComponent