Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ export const voiceOnDemandCommand = new SlashCommandBuilder()
.setName('voice-on-demand')
.setDescription('Actions related to the voice lobby')
.addSubcommand((subcommand) =>
subcommand.setName('create').setDescription('Creates the voice lobby')
subcommand.setName('create').setDescription('Creates the voice lobby'),
)
.toJSON();

export const fartCommand = new SlashCommandBuilder()
.setName('fart')
.setDescription("Replies with https://prout.dev")
.toJSON();
18 changes: 12 additions & 6 deletions src/handlers/handle-interaction-creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ export const handleInteractionCreation = async (interaction: Interaction): Promi
!interaction.isCommand() ||
!interaction.inGuild() ||
!interaction.isChatInputCommand() ||
interaction.commandName !== 'voice-on-demand'
!['voice-on-demand', 'fart'].includes(interaction.commandName)
) {
return;
}

if (interaction.options.getSubcommand(true) !== 'create') {
await interaction.reply('Unknown subcommand');
return;
switch (interaction.commandName) {
case 'voice-on-demand':
if (interaction.options.getSubcommand(true) !== 'create') {
await interaction.reply('Unknown subcommand');
return;
}
await createLobby(interaction);
break;
case 'fart':
await interaction.reply('https://prout.dev');
break;
}

await createLobby(interaction);
};
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Client, REST, Routes } from 'discord.js';

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

await rest.put(Routes.applicationGuildCommands(discord.clientId, discord.guildId), {
body: [voiceOnDemandCommand],
body: [voiceOnDemandCommand, fartCommand],
});

console.log('Bot started.');