Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import * as CONFIG from '../../modules/config';
- import * as CMD from '../../modules/config/commands';
- const GROUP = CONFIG.CLIENT.COMMANDS;
- const CHANNELS = CONFIG.CHANNELS;
- const EMBEDS = CONFIG.EMBEDS;
- const IMAGES = CONFIG.IMAGES;
- let messageId: string | null = null;
- let authorId: string | null = null;
- interface IMenuItem {
- title: string;
- text: string;
- description?: string;
- asCancel?: boolean;
- color?: number;
- aliases?: string[];
- }
- const options = new Map<discord.decor.Emojis | string, IMenuItem>([
- [
- discord.decor.Emojis.RED_CIRCLE,
- {
- title: 'Administrator Commands',
- text:
- '\n' +
- '**__' +
- CMD.BAN_COMMAND.NAME +
- '__**' +
- '\n' +
- CMD.BAN_COMMAND.DESCRIPTION +
- '\n**Sub Commands**: ' +
- '\n' +
- CMD.BAN_COMMAND.SUBCOMMAND.ADD.NAME +
- '\n**Aliases**: `' +
- CMD.BAN_COMMAND.SUBCOMMAND.ADD.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.BAN_COMMAND.SUBCOMMAND.ADD.DESCRIPTION +
- '\n```\n**Arguments**: ' +
- CMD.BAN_COMMAND.SUBCOMMAND.ADD.ARGUMENTS +
- '\n' +
- CMD.BAN_COMMAND.SUBCOMMAND.REMOVE.NAME +
- '\n**Aliases**: `' +
- CMD.BAN_COMMAND.SUBCOMMAND.REMOVE.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.BAN_COMMAND.SUBCOMMAND.REMOVE.DESCRIPTION +
- '\n```\n**Arguments**: ' +
- CMD.BAN_COMMAND.SUBCOMMAND.REMOVE.ARGUMENTS +
- '\n' +
- CMD.BAN_COMMAND.SUBCOMMAND.LIST.NAME +
- '\n**Aliases**: `' +
- CMD.BAN_COMMAND.SUBCOMMAND.LIST.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.BAN_COMMAND.SUBCOMMAND.LIST.DESCRIPTION +
- '\n```\n\n' +
- '\n' +
- '**__' +
- CMD.KICK_COMMAND.NAME +
- '__**' +
- '\n' +
- CMD.KICK_COMMAND.DESCRIPTION +
- '\n**Aliases**: `' +
- CMD.KICK_COMMAND.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.KICK_COMMAND.DESCRIPTION +
- '\n```\n**Arguments**: ' +
- CMD.KICK_COMMAND.ARGUMENTS +
- '\n\n`<>` flags represent required arguments.\n`[]` flags represent optional arguments.',
- aliases: ['admin', 'administrator'],
- },
- ],
- [
- discord.decor.Emojis.ORANGE_CIRCLE,
- {
- title: 'Manager Commands',
- text:
- '\n' +
- '**__' +
- CMD.ANNOUNCE_COMMAND.NAME +
- '__**' +
- '\n' +
- CMD.ANNOUNCE_COMMAND.DESCRIPTION +
- '\n**Aliases**: `' +
- CMD.ANNOUNCE_COMMAND.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.ANNOUNCE_COMMAND.DESCRIPTION +
- '\n```\n**Arguments**: ' +
- CMD.ANNOUNCE_COMMAND.ARGUMENTS +
- '\n\n`<>` flags represent required arguments.\n`[]` flags represent optional arguments.',
- aliases: ['mng', 'manager'],
- },
- ],
- [
- discord.decor.Emojis.YELLOW_CIRCLE,
- {
- title: 'Moderator Commands',
- text:
- '\n' +
- '**__' +
- CMD.MUTE_COMMAND.NAME +
- '__**' +
- '\n' +
- CMD.MUTE_COMMAND.DESCRIPTION +
- '\n**Sub Commands**: ' +
- '\n' +
- CMD.MUTE_COMMAND.SUBCOMMAND.ADD.NAME +
- '\n**Aliases**: `' +
- CMD.MUTE_COMMAND.SUBCOMMAND.ADD.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.MUTE_COMMAND.SUBCOMMAND.ADD.DESCRIPTION +
- '\n```\n**Arguments**: ' +
- CMD.MUTE_COMMAND.SUBCOMMAND.ADD.ARGUMENTS +
- '\n' +
- CMD.MUTE_COMMAND.SUBCOMMAND.REMOVE.NAME +
- '\n**Aliases**: `' +
- CMD.MUTE_COMMAND.SUBCOMMAND.REMOVE.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.MUTE_COMMAND.SUBCOMMAND.REMOVE.DESCRIPTION +
- '\n```\n**Arguments**: ' +
- CMD.MUTE_COMMAND.SUBCOMMAND.REMOVE.ARGUMENTS +
- '\n' +
- CMD.MUTE_COMMAND.SUBCOMMAND.LIST.NAME +
- '\n**Aliases**: `' +
- CMD.MUTE_COMMAND.SUBCOMMAND.LIST.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.MUTE_COMMAND.SUBCOMMAND.LIST.DESCRIPTION +
- '\n```\n\n' +
- '\n' +
- '**__' +
- CMD.WARN_COMMAND.NAME +
- '__**' +
- '\n' +
- CMD.WARN_COMMAND.DESCRIPTION +
- '\n**Sub Commands**: ' +
- '\n' +
- CMD.WARN_COMMAND.SUBCOMMAND.ADD.NAME +
- '\n**Aliases**: `' +
- CMD.WARN_COMMAND.SUBCOMMAND.ADD.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.WARN_COMMAND.SUBCOMMAND.ADD.DESCRIPTION +
- '\n```\n**Arguments**: ' +
- CMD.WARN_COMMAND.SUBCOMMAND.ADD.ARGUMENTS +
- '\n' +
- CMD.WARN_COMMAND.SUBCOMMAND.REMOVE.NAME +
- '\n**Aliases**: `' +
- CMD.WARN_COMMAND.SUBCOMMAND.REMOVE.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.WARN_COMMAND.SUBCOMMAND.REMOVE.DESCRIPTION +
- '\n```\n**Arguments**: ' +
- CMD.WARN_COMMAND.SUBCOMMAND.REMOVE.ARGUMENTS +
- '\n' +
- CMD.WARN_COMMAND.SUBCOMMAND.LIST.NAME +
- '\n**Aliases**: `' +
- CMD.WARN_COMMAND.SUBCOMMAND.LIST.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.WARN_COMMAND.SUBCOMMAND.LIST.DESCRIPTION +
- '\n```\n\n`<>` flags represent required arguments.\n`[]` flags represent optional arguments.',
- aliases: ['mod', 'moderator'],
- },
- ],
- [
- discord.decor.Emojis.PURPLE_CIRCLE,
- {
- title: 'Helper Commands',
- text:
- '\n' +
- '**__' +
- CMD.CLEAR_COMMAND.NAME +
- '__**' +
- '\n' +
- CMD.CLEAR_COMMAND.DESCRIPTION +
- '\n**Aliases**: `' +
- CMD.CLEAR_COMMAND.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.CLEAR_COMMAND.DESCRIPTION +
- '\n```\n**Arguments**: ' +
- CMD.CLEAR_COMMAND.ARGUMENTS +
- '\n\n`<>` flags represent required arguments.\n`[]` flags represent optional arguments.',
- aliases: ['helper'],
- },
- ],
- [
- discord.decor.Emojis.BLUE_CIRCLE,
- {
- title: 'Utility Commands',
- text:
- '\n' +
- '**__' +
- CMD.HELP_COMMAND.NAME +
- '__**' +
- '\n' +
- CMD.HELP_COMMAND.DESCRIPTION +
- '\n**Aliases**: `' +
- CMD.HELP_COMMAND.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.HELP_COMMAND.DESCRIPTION +
- '\n```\n**Arguments**: ' +
- CMD.HELP_COMMAND.ARGUMENTS +
- '\n\n`<>` flags represent required arguments.\n`[]` flags represent optional arguments.',
- aliases: ['util', 'utility'],
- },
- ],
- [
- discord.decor.Emojis.GREEN_CIRCLE,
- {
- title: 'Slash Commands',
- text:
- '\n' +
- '**__' +
- CMD.SLOWMODE_COMMAND.NAME +
- '__**' +
- '\n' +
- CMD.SLOWMODE_COMMAND.DESCRIPTION +
- '\n**Aliases**: `' +
- CMD.SLOWMODE_COMMAND.ALIASES +
- '`\n**Description**: ```\n' +
- CMD.SLOWMODE_COMMAND.DESCRIPTION +
- '\n```\n**Arguments**: ' +
- CMD.SLOWMODE_COMMAND.ARGUMENTS +
- '\n\n`<>` flags represent required arguments.\n`[]` flags represent optional arguments.',
- aliases: ['slash'],
- },
- ],
- [
- discord.decor.Emojis.X,
- {
- title: 'Close Menu',
- text: 'Closed the menu',
- asCancel: true,
- },
- ],
- ]);
- const optionKeys = Array.from(options.keys());
- GROUP.on(
- {
- name: CMD.HELP_COMMAND.NAME,
- aliases: CMD.HELP_COMMAND.ALIASES,
- description: CMD.HELP_COMMAND.DESCRIPTION,
- filters: CONFIG.PERMISSIONS.LEVEL.USER,
- },
- (args) => ({
- optionalSelection: args.textOptional(),
- }),
- async (msg, { optionalSelection }) => {
- try {
- if (optionalSelection) {
- const item =
- options.get(optionalSelection) ??
- options.get(
- Array.from(options.keys()).find((v) => {
- const value = options.get(v)!;
- const nameCheck =
- value.title.toLowerCase() === optionalSelection.toLowerCase();
- const aliasCheck = (value.aliases ?? [])
- .map((v) => v.toLowerCase())
- .includes(optionalSelection.toLowerCase());
- return nameCheck || aliasCheck;
- }) ?? ''
- );
- if (!item) return await msg.reply('❌ I could not find that menu');
- if (item.asCancel)
- return await msg.reply("❌ There isn't anything to cancel!");
- const embed = new discord.Embed();
- embed.setColor(item.color ?? EMBEDS.DEFAULT_COLOR.BLUE);
- embed.setTitle(item.title);
- embed.setDescription(item.text);
- embed.setThumbnail({ url: IMAGES.PYLON_LOGO });
- embed.setFooter({
- text: EMBEDS.FOOTER_TEXT,
- iconUrl: IMAGES.PYLON_LOGO,
- });
- await msg.reply({ embed: embed });
- messageId = null;
- authorId = null;
- } else
- await msg
- .reply(
- new discord.Embed({
- color: EMBEDS.DEFAULT_COLOR.BLUE,
- title: 'Pylon Help Menu',
- description: `Click the reactions to see my available commands!\n
- ${optionKeys
- .map((v) => {
- const item = options.get(v)!;
- return `${v} - ${item.title}${
- item.aliases ? ` (${item.aliases.join(', ')})` : ''
- }${item.description ? `\n*${item.description}*` : ''}`;
- })
- .join('\n\n')}`,
- })
- .setThumbnail({ url: IMAGES.PYLON_LOGO })
- .setTimestamp(new Date().toISOString())
- )
- .then(async (message) => {
- optionKeys.forEach(async (v) => await message.addReaction(v));
- messageId = message.id;
- authorId = msg.author.id;
- });
- } catch (e) {
- const channel = await discord.getTextChannel(CHANNELS.ERROR_CHANNEL);
- if (!channel) throw new Error(':x: Invalid Error Channel Specified!');
- const embed = new discord.Embed();
- embed.setDescription(
- '```ts\n[' + e.name + '(' + e.code + '): ' + e.message + ']\n```'
- );
- embed.addField({
- name: 'Error Stack',
- value: '```ts\n' + e.stack + '\n```',
- inline: false,
- });
- embed.addField({
- name: 'Error Code',
- value: '```\n' + String(e.code) + '\n```',
- inline: true,
- });
- embed.addField({
- name: 'Channel ID',
- value: '```\n' + String(msg.channelId) + '\n```',
- inline: true,
- });
- embed.setThumbnail({ url: IMAGES.PYLON_LOGO });
- embed.setColor(EMBEDS.DEFAULT_COLOR.ORANGE);
- embed.setTimestamp(new Date().toISOString());
- embed.setFooter({ text: EMBEDS.FOOTER_TEXT, iconUrl: IMAGES.PYLON_LOGO });
- console.error(e);
- channel?.sendMessage({ embed: embed });
- }
- }
- );
- discord.on(discord.Event.MESSAGE_REACTION_ADD, async (theReaction) => {
- const reactionMenu = await (
- await discord.getGuildTextChannel(theReaction.channelId)
- )?.getMessage(theReaction.messageId);
- if (!reactionMenu) return;
- if (
- theReaction.emoji.type === discord.Emoji.Type.UNICODE &&
- options.has(theReaction.emoji.name!) &&
- theReaction.messageId == messageId &&
- theReaction.member &&
- theReaction.member.user.id == authorId
- ) {
- const item = options.get(theReaction.emoji.name!);
- if (!item) return;
- const embed = new discord.Embed();
- embed.setColor(item.color ?? EMBEDS.DEFAULT_COLOR.BLUE);
- embed.setTitle(item.title);
- embed.setDescription(item.text);
- embed.setThumbnail({ url: IMAGES.PYLON_LOGO });
- embed.setFooter({ text: EMBEDS.FOOTER_TEXT, iconUrl: IMAGES.PYLON_LOGO });
- const response = await reactionMenu.reply({ embed: embed });
- messageId = null;
- authorId = null;
- await reactionMenu.delete();
- if (item.asCancel) setTimeout(() => response?.delete(), 5000);
- }
- });
Add Comment
Please, Sign In to add comment