Skip to content

Commit 566064a

Browse files
luca-montaigutpotb
andcommitted
feat: add 'fart' slash command (#26)
Co-authored-by: Peïo Thibault <[email protected]>
1 parent c3d01a5 commit 566064a

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

src/commands.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ export const voiceOnDemandCommand = new SlashCommandBuilder()
44
.setName('voice-on-demand')
55
.setDescription('Actions related to the voice lobby')
66
.addSubcommand((subcommand) =>
7-
subcommand.setName('create').setDescription('Creates the voice lobby')
7+
subcommand.setName('create').setDescription('Creates the voice lobby'),
88
)
99
.toJSON();
10+
11+
export const fartCommand = new SlashCommandBuilder()
12+
.setName('fart')
13+
.setDescription("Replies with https://prout.dev")
14+
.toJSON();

src/handlers/handle-interaction-creation.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@ export const handleInteractionCreation = async (interaction: Interaction): Promi
77
!interaction.isCommand() ||
88
!interaction.inGuild() ||
99
!interaction.isChatInputCommand() ||
10-
interaction.commandName !== 'voice-on-demand'
10+
!['voice-on-demand', 'fart'].includes(interaction.commandName)
1111
) {
1212
return;
1313
}
1414

15-
if (interaction.options.getSubcommand(true) !== 'create') {
16-
await interaction.reply('Unknown subcommand');
17-
return;
15+
switch (interaction.commandName) {
16+
case 'voice-on-demand':
17+
if (interaction.options.getSubcommand(true) !== 'create') {
18+
await interaction.reply('Unknown subcommand');
19+
return;
20+
}
21+
await createLobby(interaction);
22+
break;
23+
case 'fart':
24+
await interaction.reply('https://prout.dev');
25+
break;
1826
}
19-
20-
await createLobby(interaction);
2127
};

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Client, REST, Routes } from 'discord.js';
22

3-
import { voiceOnDemandCommand } from './commands';
3+
import { fartCommand, voiceOnDemandCommand } from './commands';
44
import { config } from './config';
55
import { deleteExistingCommands } from './delete-existing-commands';
66
import { handleGuildMessageCreation } from './handlers/handle-guild-message-creation';
@@ -51,7 +51,7 @@ const rest = new REST({ version: '10' }).setToken(discord.token);
5151
await deleteExistingCommands(rest, discord);
5252

5353
await rest.put(Routes.applicationGuildCommands(discord.clientId, discord.guildId), {
54-
body: [voiceOnDemandCommand],
54+
body: [voiceOnDemandCommand, fartCommand],
5555
});
5656

5757
console.log('Bot started.');

0 commit comments

Comments
 (0)