Add dropdown to /inventory command for quick navigation (#365)
- Add ability to handle dropdown menus with the bot - Add a dropdown to the inventoryhelper - Add handler for the dropdown to navigate to that page #344 Reviewed-on: #365 Reviewed-by: VylpesTester <tester@vylpes.com> Co-authored-by: Ethan Lane <ethan@vylpes.com> Co-committed-by: Ethan Lane <ethan@vylpes.com>
This commit is contained in:
parent
5ebc5ff27c
commit
1762b525b2
11 changed files with 146 additions and 7 deletions
29
src/client/interactionCreate/StringDropdown.ts
Normal file
29
src/client/interactionCreate/StringDropdown.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import {StringSelectMenuInteraction} from "discord.js";
|
||||
import {CoreClient} from "../client";
|
||||
import AppLogger from "../appLogger";
|
||||
|
||||
export default class StringDropdown {
|
||||
public static async onStringDropdownSelected(interaction: StringSelectMenuInteraction) {
|
||||
if (!interaction.isStringSelectMenu()) return;
|
||||
|
||||
const item = CoreClient.stringDropdowns.find(x => x.DropdownId == interaction.customId.split(" ")[0]);
|
||||
|
||||
if (!item) {
|
||||
AppLogger.LogVerbose("StringDropdown", `Event not found: ${interaction.customId}`);
|
||||
|
||||
await interaction.reply("Event not found");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
AppLogger.LogDebug("StringDropdown", `Executing ${interaction.customId}`);
|
||||
|
||||
item.Event.execute(interaction);
|
||||
} catch (e) {
|
||||
AppLogger.LogError("StringDropdown", `Error occurred while executing event: ${interaction.customId}`);
|
||||
AppLogger.LogError("StringDropdown", e as string);
|
||||
|
||||
await interaction.reply("An error occurred while executing the event");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue