2023-06-25 02:32:56 +00:00
|
|
|
import {
|
2023-10-10 21:20:01 -05:00
|
|
|
AttachmentBuilder,
|
2023-06-25 02:32:56 +00:00
|
|
|
AutocompleteInteraction,
|
|
|
|
|
ButtonBuilder,
|
|
|
|
|
ButtonInteraction,
|
|
|
|
|
CacheType,
|
|
|
|
|
ChatInputCommandInteraction,
|
|
|
|
|
EmbedBuilder,
|
|
|
|
|
Interaction,
|
|
|
|
|
SlashCommandBuilder,
|
2024-06-23 20:59:03 -05:00
|
|
|
SlashCommandOptionsOnlyBuilder,
|
2023-06-25 02:32:56 +00:00
|
|
|
SlashCommandSubcommandsOnlyBuilder,
|
|
|
|
|
} from 'discord.js';
|
2024-09-08 10:28:54 -05:00
|
|
|
import { RenderConfiguration } from '../../core/blitzkit/renderConfiguration';
|
2023-06-25 02:32:56 +00:00
|
|
|
|
|
|
|
|
export type InteractionRawReturnable =
|
2023-07-10 19:14:16 +00:00
|
|
|
| string
|
2023-06-25 02:32:56 +00:00
|
|
|
| EmbedBuilder
|
|
|
|
|
| ButtonBuilder
|
2023-10-10 21:20:01 -05:00
|
|
|
| AttachmentBuilder
|
2024-04-24 16:22:48 -05:00
|
|
|
| RenderConfiguration
|
2023-10-11 18:26:35 -05:00
|
|
|
| JSX.Element
|
|
|
|
|
| null;
|
2023-06-25 02:32:56 +00:00
|
|
|
export type InteractionIterableReturnable =
|
|
|
|
|
| InteractionRawReturnable
|
|
|
|
|
| InteractionRawReturnable[];
|
|
|
|
|
export type InteractionReturnable =
|
|
|
|
|
| InteractionIterableReturnable
|
|
|
|
|
| Promise<InteractionIterableReturnable>;
|
|
|
|
|
|
2024-03-06 15:38:53 -06:00
|
|
|
interface CommandRegistryBase {
|
|
|
|
|
command:
|
|
|
|
|
| SlashCommandBuilder
|
|
|
|
|
| SlashCommandSubcommandsOnlyBuilder
|
2024-06-23 20:59:03 -05:00
|
|
|
| SlashCommandOptionsOnlyBuilder
|
2024-03-06 15:38:53 -06:00
|
|
|
| Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
|
|
|
|
|
|
2023-06-25 02:32:56 +00:00
|
|
|
autocomplete?: (interaction: AutocompleteInteraction<CacheType>) => void;
|
|
|
|
|
button?: (interaction: ButtonInteraction<CacheType>) => InteractionReturnable;
|
2024-03-06 15:38:53 -06:00
|
|
|
}
|
2025-01-15 20:14:05 -06:00
|
|
|
|
2024-03-06 15:38:53 -06:00
|
|
|
interface CommandRegistryImplicit extends CommandRegistryBase {
|
2024-01-19 21:32:46 -06:00
|
|
|
handlesInteraction: true;
|
|
|
|
|
handler: (interaction: ChatInputCommandInteraction<CacheType>) => void;
|
2024-03-06 15:38:53 -06:00
|
|
|
}
|
2025-01-15 20:14:05 -06:00
|
|
|
|
2024-03-06 15:38:53 -06:00
|
|
|
interface CommandRegistryExplicit extends CommandRegistryBase {
|
2024-01-19 21:32:46 -06:00
|
|
|
handlesInteraction?: false;
|
|
|
|
|
handler: (
|
|
|
|
|
interaction: ChatInputCommandInteraction<CacheType>,
|
|
|
|
|
) => InteractionReturnable;
|
2024-03-06 15:38:53 -06:00
|
|
|
}
|
2025-01-15 20:14:05 -06:00
|
|
|
|
2024-03-06 15:38:53 -06:00
|
|
|
export type CommandRegistry = CommandRegistryImplicit | CommandRegistryExplicit;
|
2023-06-25 02:32:56 +00:00
|
|
|
|
2024-03-06 15:34:10 -06:00
|
|
|
export const COMMANDS_RAW: Promise<CommandRegistry>[] = [
|
2025-01-15 20:14:05 -06:00
|
|
|
// auctionCommand,
|
|
|
|
|
// permissionsCommand,
|
|
|
|
|
// debugCommand,
|
|
|
|
|
// aboutCommand,
|
|
|
|
|
// inactiveCommand,
|
|
|
|
|
// ownedTanksCommand,
|
|
|
|
|
// playerInfoCommand,
|
|
|
|
|
// searchClansCommand,
|
|
|
|
|
// searchPlayersCommand,
|
|
|
|
|
// fullStatsCommand,
|
|
|
|
|
// breakdownCommand,
|
|
|
|
|
// verifyCommand,
|
|
|
|
|
// pingCommand,
|
|
|
|
|
// evolutionCommand,
|
|
|
|
|
// statsCommand,
|
|
|
|
|
// ratingLeaderboardCommand,
|
|
|
|
|
// todayCommand,
|
|
|
|
|
// researchCommand,
|
|
|
|
|
// ratingCommand,
|
|
|
|
|
// replayCommand,
|
2023-07-10 19:14:16 +00:00
|
|
|
];
|
2023-08-04 02:13:21 +00:00
|
|
|
|
2024-03-03 22:21:06 -06:00
|
|
|
export const commands = Promise.allSettled(COMMANDS_RAW).then((rawCommands) => {
|
2025-01-15 20:14:05 -06:00
|
|
|
// return rawCommands.reduce<Record<string, CommandRegistry>>(
|
|
|
|
|
// (commands, registry, index) => {
|
|
|
|
|
// if (registry.status === 'rejected') {
|
|
|
|
|
// console.warn(
|
|
|
|
|
// `Command ${index} failed to load; skipping...`,
|
|
|
|
|
// registry.reason,
|
|
|
|
|
// );
|
|
|
|
|
// return commands;
|
|
|
|
|
// }
|
|
|
|
|
// return { ...commands, [registry.value.command.name]: registry.value };
|
|
|
|
|
// },
|
|
|
|
|
// {},
|
|
|
|
|
// );
|
2024-03-03 22:21:06 -06:00
|
|
|
});
|
2023-06-25 02:32:56 +00:00
|
|
|
|
2025-01-15 20:14:05 -06:00
|
|
|
// const rest = new REST().setToken(assertSecret(import.meta.env.DISCORD_TOKEN));
|
2023-06-25 02:32:56 +00:00
|
|
|
|
2025-01-15 20:14:05 -06:00
|
|
|
// commands.then((awaitedCommands) => {
|
|
|
|
|
// const body = Object.values(awaitedCommands).map((registry) =>
|
|
|
|
|
// registry.command.toJSON(),
|
|
|
|
|
// );
|
2023-06-25 02:32:56 +00:00
|
|
|
|
2025-01-15 20:14:05 -06:00
|
|
|
// rest.put(
|
|
|
|
|
// Routes.applicationCommands(assertSecret(import.meta.env.DISCORD_CLIENT_ID)),
|
|
|
|
|
// { body },
|
|
|
|
|
// );
|
|
|
|
|
// });
|
2023-06-25 02:32:56 +00:00
|
|
|
|
2024-09-08 10:11:24 -05:00
|
|
|
export async function interactionCreate(interaction: Interaction<CacheType>) {
|
2023-06-25 02:32:56 +00:00
|
|
|
if (interaction.isAutocomplete()) {
|
2025-01-16 13:53:29 -06:00
|
|
|
// handleAutocomplete(interaction);
|
2023-06-25 02:32:56 +00:00
|
|
|
} else if (interaction.isChatInputCommand()) {
|
2025-01-16 13:53:29 -06:00
|
|
|
// handleChatInputCommand(interaction);
|
2023-06-25 02:32:56 +00:00
|
|
|
} else if (interaction.isButton()) {
|
2025-01-15 20:14:05 -06:00
|
|
|
// handleButton(interaction);
|
2023-06-25 02:32:56 +00:00
|
|
|
}
|
|
|
|
|
}
|