Skip to content

Instantly share code, notes, and snippets.

@mikkipastel
Created April 20, 2022 14:31
Show Gist options
  • Save mikkipastel/baea57c04945559f412353aa8fae2e82 to your computer and use it in GitHub Desktop.
Save mikkipastel/baea57c04945559f412353aa8fae2e82 to your computer and use it in GitHub Desktop.
register discord bot command
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
if (commandName === 'ping') {
const timeTaken = Date.now() - interaction.createdTimestamp;
await interaction.reply(`Pong! This message had a latency of ${timeTaken}ms.`);
} else if (commandName === 'holiday') {
await interaction.reply(await calendar.getHolidayList());
}
});
client.login(process.env.DISCORD_BOT_TOKEN);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment