crra/util/DiscordInteractionCommand.ts

34 lines
971 B
TypeScript
Raw Permalink Normal View History

2024-03-19 17:41:20 -04:00
import { SlashCommandBuilder, ChatInputCommandInteraction } from "discord.js";
import { guildID } from "../config.json";
2024-03-19 17:41:20 -04:00
export interface DiscordInteractionCommandSkeleton {
2024-10-25 16:57:33 -04:00
GUILD_ID: string;
builder?: SlashCommandBuilder;
description: string;
execute: (interaction: ChatInputCommandInteraction) => Error | Promise<void | any>;
name: string;
}
2024-10-25 16:57:33 -04:00
export default abstract class DiscordInteractionCommand
implements DiscordInteractionCommandSkeleton
{
public name: string;
public description: string;
public builder: SlashCommandBuilder;
2024-03-19 17:41:20 -04:00
2024-10-25 16:57:33 -04:00
public GUILD_ID: string;
2024-10-25 16:57:33 -04:00
protected constructor(name: string, description: string) {
this.name = name;
this.description = description;
this.builder = new SlashCommandBuilder();
2024-03-19 17:41:20 -04:00
2024-10-25 16:57:33 -04:00
this.builder.setName(this.name);
this.builder.setDescription(this.description);
2024-10-25 16:57:33 -04:00
this.GUILD_ID = guildID;
}
2024-03-19 17:41:20 -04:00
2024-10-25 16:57:33 -04:00
public abstract execute(interaction: ChatInputCommandInteraction): Error | Promise<void | any>;
2024-03-19 17:41:20 -04:00
}