Skip to content

Commit

Permalink
Refactor sub command
Browse files Browse the repository at this point in the history
  • Loading branch information
holzmaster committed Jul 28, 2024
1 parent 6ef144a commit f79d5b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 91 deletions.
25 changes: 14 additions & 11 deletions src/commands/ehre.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,23 @@ export default class EhreCommand implements ApplicationCommand {

async handleInteraction(command: CommandInteraction, context: BotContext) {
if (!command.isChatInputCommand()) {
// TODO: Solve this on a type level
return;
}

const subcommand = command.options.getSubcommand();
if (subcommand === "tabelle") {
await command.reply(await createEhreTable(context));
return;
}

const user = command.options.getUser("user", true);
if (subcommand === "add") {
const reply = await ehreService.addEhre(command.user, user);
await command.reply(reply);
const subCommand = command.options.getSubcommand();
switch (subCommand) {
case "tabelle": {
await command.reply(await createEhreTable(context));
return;
}
case "add": {
const user = command.options.getUser("user", true);
const reply = await ehreService.addEhre(command.user, user);
await command.reply(reply);
return;
}
default:
throw new Error("Unknown subcommand");
}
}
}
80 changes: 0 additions & 80 deletions src/commands/emoteSearch.ts

This file was deleted.

0 comments on commit f79d5b3

Please sign in to comment.