Riscord Back to chat

Developer docs

Build a bot that belongs in your community.

API v1 SDK 0.5.0

Replies, buttons and forms

Respond on time and build controls without losing the reply’s audience.

Examples use the bot client from Your first bot.

Reply or defer

Acknowledge an interaction within three seconds with a message, a deferral or a form. Follow-ups are available for fifteen minutes, up to ten response records. Choose private or public at the first acknowledgement; the audience cannot change later.

Private replies are excluded from public chat history, search and notifications. In server channels, the bot still needs Send Messages.

JavaScript
bot.command('status', async interaction => {
  await interaction.defer({ private: true });
  const result = await loadStatus();
  await interaction.reply(result);
});

Edit your reply and send followups

editReply / edit_reply targets the first successful message response from this interaction. After deferring, it sends that first response. Followups have their own response IDs, which you can keep for later edits or deletion.

These operations expire after fifteen minutes and recheck the bot and original user’s current access. They cannot change the private/public audience. A component creates a new interaction; edit its original public message with the channel/DM message helper instead.

JavaScript
await interaction.defer({ private: true });
await interaction.editReply('Your export is ready.');
const extra = await interaction.followUp('The download expires tomorrow.');
await interaction.editFollowUp(extra.id, 'The download expires in 24 hours.');
await interaction.deleteFollowUp(extra.id);
await interaction.deleteReply();

Buttons and select menus

Controls are arrays of rows: up to five rows and five controls per row, with a 16 KiB total limit. Use a customId to route clicks. An optional userId restricts a control to one person.

A custom ID is a routing key, not authorization. Check the user and your own application rules before performing a privileged action.

JavaScript
await interaction.reply('Choose what happens next.', {
  components: [[
    { type: 'button', label: 'Continue', customId: 'continue', userId: interaction.userId },
    { type: 'select', label: 'Choose one', customId: 'choice', options: [
      { label: 'First option', value: 'first' },
    ] },
  ]],
});
bot.on('interaction', async interaction => {
  if (interaction.kind === 'component' && interaction.data.customId === 'continue') {
    await interaction.reply('Continuing.', { private: true });
  }
});

Open a form

Open a form as the initial response, before replying or deferring. A form has one to five text or paragraph fields. Submission creates a fresh interaction with a new three-second acknowledgement deadline.

JavaScript
await interaction.showModal({
  customId: 'feedback', title: 'Your feedback',
  fields: [{ name: 'message', label: 'What could be better?', type: 'paragraph', required: true, maxLength: 1000 }],
});
bot.on('interaction', async interaction => {
  if (interaction.kind === 'form' && interaction.data.customId === 'feedback') {
    const message = interaction.data.values.message;
    await interaction.reply('Thanks for the feedback.', { private: true });
  }
});