diff options
| author | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
| commit | bb511abc03bb66848947e37a999502b813c77269 (patch) | |
| tree | 612c010fc8317e1cdf11471a18aad0270819d33e /server/src/commands/util | |
| parent | fix: if clear amount equal or over 100, round down to 99 (diff) | |
| download | dep-core-bb511abc03bb66848947e37a999502b813c77269.tar.xz dep-core-bb511abc03bb66848947e37a999502b813c77269.zip | |
goodbye old uwufier :cry:
Diffstat (limited to 'server/src/commands/util')
| -rw-r--r-- | server/src/commands/util/Categories.ts | 155 | ||||
| -rw-r--r-- | server/src/commands/util/Help.ts | 100 |
2 files changed, 255 insertions, 0 deletions
diff --git a/server/src/commands/util/Categories.ts b/server/src/commands/util/Categories.ts new file mode 100644 index 0000000..7b07027 --- /dev/null +++ b/server/src/commands/util/Categories.ts @@ -0,0 +1,155 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; +import { colour } from '../../Config'; + +export default class CategoriesUtil extends Command { + public constructor() { + super('categories', { + aliases: ['categories', 'category'], + category: 'utility', + description: { + content: 'Displays a list of categories or lists all commands in a specified category.', + usage: '[command]', + examples: [ + '', + 'ping' + ] + }, + ratelimit: 3, + clientPermissions: ['EMBED_LINKS'], + args: [ + { + id: 'category', + type: 'string', + prompt: { + start: 'Which category do you need help with?', + retry: 'Please provide a valid category.', + optional: true + }, + match: 'rest' + } + ] + }); + } + + public exec(msg: Message, { category }): Promise<Message> { + if (!category) return this.execCategoryList(msg); + + let categories = []; + for (const category of this.handler.categories.values()) { + if (!categories.includes(category.id)) categories.push(category.id); + } + if (categories.includes(category)) return this.execCommandList(msg, category); + } + + public async execCommandList(message, categorii): Promise<Message> { + const embed = this.client.util.embed() + .setColor(colour) + .addField('Command List', [ + `This is a list of commands in the **${categorii}** category.`, + `To view details for a specific command, do \`${this.client.commandHandler.prefix}help <command>\`.` + ]); + + for (const category of this.handler.categories.values()) { + let title + if (message.channel.type != 'dm' && message.guild.id == '663964105983393793') { + title = { + general: '📝\u2000General', + fun: '🎉\u2000Fun', + minigames: '🕹\u2000Minigames (WIP)', + images: '🖼\u2000Images', + utility: '🔩\u2000Utility', + moderation: '⚡\u2000Moderation', + owner: '🛠️\u2000Owner', + voice: '🎧\u2000Voice', + bot: '🤖\u2000Bot', + server: '🖥\u2000Server', + anime: '🎀\u2000Anime', + animals: '🐛\u2000Animals', + emma: '🔥\u2000Emma', + nsfw: '🔞\u2000NSFW', + reactions: '😮\u2000Reactions' + }[category.id]; + } else { + title = { + general: '📝\u2000General', + fun: '🎉\u2000Fun', + minigames: '🕹\u2000Minigames (WIP)', + images: '🖼\u2000Images', + utility: '🔩\u2000Utility', + moderation: '⚡\u2000Moderation', + owner: '🛠️\u2000Owner', + voice: '🎧\u2000Voice', + bot: '🤖\u2000Bot', + server: '🖥\u2000Server', + anime: '🎀\u2000Anime', + animals: '🐛\u2000Animals', + nsfw: '🔞\u2000NSFW', + reactions: '😮\u2000Reactions' + }[category.id]; + } + + if (title && (category.id == categorii)) embed.addField(title, `${category.map(cmd => '`' + cmd.aliases[0] + '` - ' + cmd.description.content).join('\n')}`); // .join('`\n`') + } + + return message.channel.send({ embed }); + } + + public async execCategoryList(message): Promise<Message> { + const embed = this.client.util.embed() + .setColor(colour) + .addField('Category List', [ + `To view details for a specific category, do \`${this.client.commandHandler.prefix}category <category>\`.` + ]); + + let count; + for (const category of this.handler.categories.values()) { + count++; + let title + if (message.channel.type != 'dm' && message.guild.id == '663964105983393793') { + title = { + general: '📝\u2000General', + fun: '🎉\u2000Fun', + minigames: '🕹\u2000Minigames (WIP)', + images: '🖼\u2000Images', + utility: '🔩\u2000Utility', + moderation: '⚡\u2000Moderation', + owner: '🛠️\u2000Owner', + voice: '🎧\u2000Voice', + bot: '🤖\u2000Bot', + server: '🖥\u2000Server', + anime: '🎀\u2000Anime', + animals: '🐛\u2000Animals', + emma: '🔥\u2000Emma', + nsfw: '🔞\u2000NSFW', + reactions: '😮\u2000Reactions' + }[category.id]; + } else { + title = { + general: '📝\u2000General', + fun: '🎉\u2000Fun', + minigames: '🕹\u2000Minigames (WIP)', + images: '🖼\u2000Images', + utility: '🔩\u2000Utility', + moderation: '⚡\u2000Moderation', + owner: '🛠️\u2000Owner', + voice: '🎧\u2000Voice', + bot: '🤖\u2000Bot', + server: '🖥\u2000Server', + anime: '🎀\u2000Anime', + animals: '🐛\u2000Animals', + nsfw: '🔞\u2000NSFW', + reactions: '😮\u2000Reactions' + }[category.id]; + } + + if (title) + if (count % 3 == 0) + embed.addField(`${title}`, `${category.size} commands`, false); + else + embed.addField(`${title}`, `${category.size} commands`, true); + } + + return message.channel.send({ embed }); + } +}
\ No newline at end of file diff --git a/server/src/commands/util/Help.ts b/server/src/commands/util/Help.ts new file mode 100644 index 0000000..76d2bf6 --- /dev/null +++ b/server/src/commands/util/Help.ts @@ -0,0 +1,100 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; +import { colour } from '../../Config'; + +export default class HelpUtil extends Command { + public constructor() { + super('help', { + aliases: ['help'], + category: 'utility', + description: { + content: 'List help features or get information on a specified command.', + usage: '[command]', + examples: [ + '', + '8ball' + ] + }, + ratelimit: 3, + clientPermissions: ['EMBED_LINKS'], + args: [ + { + id: 'command', + type: 'commandAlias', + prompt: { + start: 'Which command do you need help with?', + retry: 'Please provide a valid command.', + optional: true + }, + match: 'rest' + } + ] + }); + } + + public exec(msg: Message, { command }): Promise<void | Message> { + if (!command) { + const embed = this.client.util.embed() + .setColor(colour) + .addFields([ + { + name: 'Online Command List', + value: '*Coming soon!*' + }, + { + name: 'Specific Command Help', + value: `${this.handler.prefix}help <command>` + }, + { + name: 'List of all public categories', + value: `${this.handler.prefix}categories` + } + ]); + return msg.channel.send({ embed }); + } + + const description = Object.assign({ + content: 'No description available.', + usage: '', + examples: [], + fields: [] + }, command.description); + + const embed = this.client.util.embed() + .setColor(colour) + .setTitle(`\`${this.client.commandHandler.prefix}${command.aliases[0]} ${description.usage}\``) + .addField('Description', description.content); + + for (const field of description.fields) embed.addField(field.name, field.value); + + if (command.aliases.length > 1) { + embed.addField('Aliases', `\`${command.aliases.join('`, `')}\``, true); + } + + if (command.description.examples.length >= 1) { + embed.addField('Examples', `\`${this.client.commandHandler.prefix}${command.aliases[0]} ${command.description.examples.join(`, ${this.client.commandHandler.prefix}${command.aliases[0]} `)}\``, true); + } + + if (command.userPermissions) { + embed.addField('User permission', `\`${command.userPermissions.join('` `')}\``, true); + } + + if (command.clientPermissions) { + embed.addField('Bot permission', `\`${command.clientPermissions.join('` `')}\``, true); + } + + if (command.contentParser.flagWords.length) { + embed.addField('Command flags', `\`${command.contentParser.flagWords.join('` `')}\``, true); + } + + if (command.contentParser.optionFlagWords.length) { + embed.addField('Command options flags', `\`${command.contentParser.optionFlagWords.join('` `')}\``, true); + } + + if (msg.channel.type === 'dm') return msg.author.send({ embed }); + return msg.reply('sending you a DM with information...').then(async m => { + await msg.author.send({ embed }); + m.edit('I\'ve send you a DM with information!'); + }); + } +}
\ No newline at end of file |