mirror of
https://github.com/Burn-E99/GroupUp.git
synced 2026-01-08 04:17:54 -05:00
slash command system added
This commit is contained in:
23
src/commands/_index.ts
Normal file
23
src/commands/_index.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { Bot, CreateApplicationCommand, log, LT, MakeRequired } from '../../deps.ts';
|
||||
import { Commands } from '../types/commandTypes.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
import info from './info.ts';
|
||||
|
||||
export const commands: Array<Commands> = [info];
|
||||
|
||||
export const createSlashCommands = async (bot: Bot) => {
|
||||
const globalCommands: MakeRequired<CreateApplicationCommand, 'name'>[] = [];
|
||||
for (const command of commands) {
|
||||
globalCommands.push({
|
||||
name: command.details.name,
|
||||
description: command.details.description,
|
||||
type: command.details.type,
|
||||
options: command.details.options ? command.details.options : undefined,
|
||||
dmPermission: command.details.dmPermission ? command.details.dmPermission : false,
|
||||
defaultMemberPermissions: command.details.defaultMemberPermissions ? command.details.defaultMemberPermissions : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
await bot.helpers.upsertGlobalApplicationCommands(globalCommands).catch((errMsg) => log(LT.ERROR, `Failed to upsert application commands | ${utils.jsonStringifyBig(errMsg)}`));
|
||||
};
|
||||
41
src/commands/info.ts
Normal file
41
src/commands/info.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import config from '../../config.ts';
|
||||
import { ApplicationCommandTypes, Bot, Interaction, InteractionResponseTypes } from '../../deps.ts';
|
||||
import { infoColor2, isLFGChannel } from '../commandUtils.ts';
|
||||
import { CommandDetails } from '../types/commandTypes.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
const details: CommandDetails = {
|
||||
name: 'info',
|
||||
description: `Information about ${config.name} and its developer`,
|
||||
type: ApplicationCommandTypes.ChatInput,
|
||||
};
|
||||
|
||||
const execute = (bot: Bot, interaction: Interaction) => {
|
||||
bot.helpers.sendInteractionResponse(
|
||||
interaction.id,
|
||||
interaction.token,
|
||||
{
|
||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||
data: {
|
||||
flags: isLFGChannel(interaction.channelId || 0n),
|
||||
embeds: [{
|
||||
color: infoColor2,
|
||||
title: `${config.name}, the LFG bot`,
|
||||
description: `${config.name} is developed by Ean AKA Burn_E99.
|
||||
Want to check out my source code? Check it out [here](${config.links.sourceCode}).
|
||||
Need help with this bot? Join my support server [here](${config.links.supportServer}).
|
||||
|
||||
Ran into a bug? Report it to my developers using \`/report [issue description]\`.`,
|
||||
footer: {
|
||||
text: `Current Version: ${config.version}`,
|
||||
},
|
||||
}],
|
||||
},
|
||||
},
|
||||
).catch((e: Error) => utils.commonLoggers.interactionSendError('info.ts', interaction, e));
|
||||
};
|
||||
|
||||
export default {
|
||||
details,
|
||||
execute,
|
||||
};
|
||||
Reference in New Issue
Block a user