knightrider/src/bot/commands/messagemacro.ts

77 lines
2.6 KiB
TypeScript
Raw Normal View History

2025-01-18 01:27:58 +00:00
import { Client, ChatInputCommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
2025-01-18 14:46:30 +00:00
2025-01-18 01:27:58 +00:00
import YALAS from 'mcstatusbot-logger';
import * as AddMessageMacro from './messagemacro/add';
import * as ListMessageMacros from './messagemacro/list';
import { GuildInstance } from "../../database/schemas/Guild";
import { UserInstance } from "../../database/schemas/User";
const data = {
2025-01-18 14:46:30 +00:00
allowSuspendedUserAccess: false,
2025-01-18 01:27:58 +00:00
command: new SlashCommandBuilder()
.setName('messagemacro')
.setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild)
.setDescription("setup message macros for the server")
.addSubcommand(subcommand =>
subcommand
.setName('add')
.setDescription("Add a message macro")
.addStringOption(option =>
option.setName('macro')
.setDescription('The macro you send (without prefix)')
.setRequired(true)
.setMinLength(1)
.setMaxLength(5)
)
.addStringOption(option =>
option.setName('message')
.setDescription('The content of the message the bot will send')
.setRequired(true)
.setMinLength(3)
.setMaxLength(2000)
)
.addMentionableOption(option =>
option.setName('trigger-role')
.setDescription('The role that grants people permission to use this')
.setRequired(true)
)
.addBooleanOption(o =>
o.setName('deletecmd')
.setDescription("should your macro message be deleted after you send it?")
.setRequired(true)
)
.addBooleanOption(o =>
o.setName('impersonate')
.setDescription("setting to true will use your name and photo")
.setRequired(true)
)
.addChannelOption(option =>
option.setName('channel')
.setDescription('The channel in which you want to it to be sent in (leave blank to send in same channel as command)')
.setRequired(false)
)
)
.addSubcommand(subcommand =>
subcommand
.setName('list')
.setDescription("Lists all your message macros and allows you to edit/remove them")
)
}
export { data };
export async function chatInputCommand(client: Client, interaction: ChatInputCommandInteraction, guild: GuildInstance, user: UserInstance) {
switch (interaction.options.getSubcommand()) {
case 'add':
AddMessageMacro.chatInputCommand(client, interaction, guild, user)
break;
case 'list':
ListMessageMacros.chatInputCommand(client, interaction, guild, user)
break;
}
}