From 481a157a177e60f023b59e4e9acffc549760db40 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 26 May 2021 16:53:45 +0000 Subject: Automatically format code --- src/commands/info/pronouns.ts | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'src/commands/info') diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 07d210f..97cca34 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -59,9 +59,17 @@ export default class PronounsCommand extends BotCommand { slashEmphemeral: true // I'll add dynamic checking to this later }); } - async sendResponse(message: Message|CommandInteraction, user: User, author: boolean): Promise { + async sendResponse( + message: Message | CommandInteraction, + user: User, + author: boolean + ): Promise { try { - const apiRes: { pronouns: pronounsType } = await got.get(`https://pronoundb.org/api/v1/lookup?platform=discord&id=${user.id}`).json(); + const apiRes: { pronouns: pronounsType } = await got + .get( + `https://pronoundb.org/api/v1/lookup?platform=discord&id=${user.id}` + ) + .json(); if (message instanceof Message) { message.reply( new MessageEmbed({ @@ -71,7 +79,7 @@ export default class PronounsCommand extends BotCommand { text: 'Data provided by https://pronoundb.org/' } }) - ) + ); } else { message.reply({ embeds: [ @@ -83,24 +91,31 @@ export default class PronounsCommand extends BotCommand { } }) ] - }) + }); } } catch (e) { if (e instanceof HTTPError && e.response.statusCode === 404) { if (author) { - await message.reply('You do not appear to have any pronouns set. Please go to https://pronoundb.org/ and set your pronouns.'); + await message.reply( + 'You do not appear to have any pronouns set. Please go to https://pronoundb.org/ and set your pronouns.' + ); } else { - await message.reply(`${user.tag} does not appear to have any pronouns set. Please tell them to go to https://pronoundb.org/ and set their pronouns.`); + await message.reply( + `${user.tag} does not appear to have any pronouns set. Please tell them to go to https://pronoundb.org/ and set their pronouns.` + ); } } else throw e; } } async exec(message: Message, { user }: { user?: User }): Promise { const u = user || message.author; - await this.sendResponse(message, u, u.id === message.author.id) + await this.sendResponse(message, u, u.id === message.author.id); } - async execSlash(message: CommandInteraction, { user }: { user?: SlashCommandOption }): Promise { - const u = user?.user || message.user - await this.sendResponse(message, u, u.id === message.user.id) + async execSlash( + message: CommandInteraction, + { user }: { user?: SlashCommandOption } + ): Promise { + const u = user?.user || message.user; + await this.sendResponse(message, u, u.id === message.user.id); } -} \ No newline at end of file +} -- cgit From 0caccda67d97dd74405aa4ece5d3f07e7c7dfc66 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Wed, 26 May 2021 21:36:50 -0400 Subject: some rebranding --- src/commands/info/botinfo.ts | 4 ++-- src/commands/info/help.ts | 10 +++++----- src/commands/info/ping.ts | 4 ++-- src/commands/info/pronouns.ts | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/commands/info') diff --git a/src/commands/info/botinfo.ts b/src/commands/info/botinfo.ts index 8f5f055..e6a4fbb 100644 --- a/src/commands/info/botinfo.ts +++ b/src/commands/info/botinfo.ts @@ -1,8 +1,8 @@ import { MessageEmbed, Message, CommandInteraction } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { duration } from 'moment'; -export default class BotInfoCommand extends BotCommand { +export default class BotInfoCommand extends BushCommand { constructor() { super('botinfo', { aliases: ['botinfo'], diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 116669c..30c2a21 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -1,11 +1,11 @@ import { Message, MessageEmbed } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { stripIndent } from 'common-tags'; import { ApplicationCommandOptionType } from 'discord-api-types'; import { CommandInteraction } from 'discord.js'; import { SlashCommandOption } from '../../lib/extensions/Util'; -export default class HelpCommand extends BotCommand { +export default class HelpCommand extends BushCommand { constructor() { super('help', { aliases: ['help'], @@ -32,7 +32,7 @@ export default class HelpCommand extends BotCommand { }); } - private generateEmbed(command?: BotCommand): MessageEmbed { + private generateEmbed(command?: BushCommand): MessageEmbed { const prefix = this.handler.prefix; if (!command) { const embed = new MessageEmbed() @@ -85,7 +85,7 @@ export default class HelpCommand extends BotCommand { public async exec( message: Message, - { command }: { command: BotCommand } + { command }: { command: BushCommand } ): Promise { await message.util.send(this.generateEmbed(command)); } @@ -97,7 +97,7 @@ export default class HelpCommand extends BotCommand { if (command) { await message.reply( this.generateEmbed( - this.handler.findCommand(command.value) as BotCommand + this.handler.findCommand(command.value) as BushCommand ) ); } else { diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index e51867f..62b8e60 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -1,9 +1,9 @@ import { CommandInteraction } from 'discord.js'; import { Message } from 'discord.js'; import { MessageEmbed } from 'discord.js'; -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; -export default class PingCommand extends BotCommand { +export default class PingCommand extends BushCommand { constructor() { super('ping', { aliases: ['ping'], diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 97cca34..f30a981 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -1,4 +1,4 @@ -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { User, Message, MessageEmbed } from 'discord.js'; import got, { HTTPError } from 'got'; import { CommandInteraction } from 'discord.js'; @@ -30,7 +30,7 @@ export const pronounMapping = { }; export type pronounsType = keyof typeof pronounMapping; -export default class PronounsCommand extends BotCommand { +export default class PronounsCommand extends BushCommand { constructor() { super('pronouns', { aliases: ['pronouns', 'pronoun'], -- cgit From cd0f853a2e4732cea5356f9ee3603bb804b0ab1f Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Wed, 26 May 2021 21:53:35 -0400 Subject: made some more changes --- src/commands/info/botInfoCommand.ts | 65 +++++++++++++++++++ src/commands/info/botinfo.ts | 65 ------------------- src/commands/info/help.ts | 107 ------------------------------- src/commands/info/helpCommand.ts | 107 +++++++++++++++++++++++++++++++ src/commands/info/ping.ts | 68 -------------------- src/commands/info/pingCommand.ts | 68 ++++++++++++++++++++ src/commands/info/pronouns.ts | 121 ----------------------------------- src/commands/info/pronounsCommand.ts | 121 +++++++++++++++++++++++++++++++++++ 8 files changed, 361 insertions(+), 361 deletions(-) create mode 100644 src/commands/info/botInfoCommand.ts delete mode 100644 src/commands/info/botinfo.ts delete mode 100644 src/commands/info/help.ts create mode 100644 src/commands/info/helpCommand.ts delete mode 100644 src/commands/info/ping.ts create mode 100644 src/commands/info/pingCommand.ts delete mode 100644 src/commands/info/pronouns.ts create mode 100644 src/commands/info/pronounsCommand.ts (limited to 'src/commands/info') diff --git a/src/commands/info/botInfoCommand.ts b/src/commands/info/botInfoCommand.ts new file mode 100644 index 0000000..e6a4fbb --- /dev/null +++ b/src/commands/info/botInfoCommand.ts @@ -0,0 +1,65 @@ +import { MessageEmbed, Message, CommandInteraction } from 'discord.js'; +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { duration } from 'moment'; + +export default class BotInfoCommand extends BushCommand { + constructor() { + super('botinfo', { + aliases: ['botinfo'], + description: { + content: 'Shows information about the bot', + usage: 'botinfo', + examples: ['botinfo'] + } + }); + } + + private async generateEmbed(): Promise { + const owners = (await this.client.util.mapIDs(this.client.ownerID)) + .map((u) => u.tag) + .join('\n'); + const currentCommit = ( + await this.client.util.shell('git rev-parse HEAD') + ).stdout.replace('\n', ''); + const repoUrl = ( + await this.client.util.shell('git remote get-url origin') + ).stdout.replace('\n', ''); + const embed = new MessageEmbed() + .setTitle('Bot Info:') + .addFields([ + { + name: 'Owners', + value: owners, + inline: true + }, + { + name: 'Uptime', + value: this.client.util.capitalize( + duration(this.client.uptime, 'milliseconds').humanize() + ) + }, + { + name: 'User count', + value: this.client.users.cache.size, + inline: true + }, + { + name: 'Current commit', + value: `[${currentCommit.substring( + 0, + 7 + )}](${repoUrl}/commit/${currentCommit})` + } + ]) + .setTimestamp(); + return embed; + } + + public async exec(message: Message): Promise { + await message.util.send(await this.generateEmbed()); + } + + public async execSlash(message: CommandInteraction): Promise { + await message.reply(await this.generateEmbed()); + } +} diff --git a/src/commands/info/botinfo.ts b/src/commands/info/botinfo.ts deleted file mode 100644 index e6a4fbb..0000000 --- a/src/commands/info/botinfo.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { MessageEmbed, Message, CommandInteraction } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { duration } from 'moment'; - -export default class BotInfoCommand extends BushCommand { - constructor() { - super('botinfo', { - aliases: ['botinfo'], - description: { - content: 'Shows information about the bot', - usage: 'botinfo', - examples: ['botinfo'] - } - }); - } - - private async generateEmbed(): Promise { - const owners = (await this.client.util.mapIDs(this.client.ownerID)) - .map((u) => u.tag) - .join('\n'); - const currentCommit = ( - await this.client.util.shell('git rev-parse HEAD') - ).stdout.replace('\n', ''); - const repoUrl = ( - await this.client.util.shell('git remote get-url origin') - ).stdout.replace('\n', ''); - const embed = new MessageEmbed() - .setTitle('Bot Info:') - .addFields([ - { - name: 'Owners', - value: owners, - inline: true - }, - { - name: 'Uptime', - value: this.client.util.capitalize( - duration(this.client.uptime, 'milliseconds').humanize() - ) - }, - { - name: 'User count', - value: this.client.users.cache.size, - inline: true - }, - { - name: 'Current commit', - value: `[${currentCommit.substring( - 0, - 7 - )}](${repoUrl}/commit/${currentCommit})` - } - ]) - .setTimestamp(); - return embed; - } - - public async exec(message: Message): Promise { - await message.util.send(await this.generateEmbed()); - } - - public async execSlash(message: CommandInteraction): Promise { - await message.reply(await this.generateEmbed()); - } -} diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts deleted file mode 100644 index 30c2a21..0000000 --- a/src/commands/info/help.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { Message, MessageEmbed } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { stripIndent } from 'common-tags'; -import { ApplicationCommandOptionType } from 'discord-api-types'; -import { CommandInteraction } from 'discord.js'; -import { SlashCommandOption } from '../../lib/extensions/Util'; - -export default class HelpCommand extends BushCommand { - constructor() { - super('help', { - aliases: ['help'], - description: { - content: 'Shows the commands of the bot', - usage: 'help', - examples: ['help'] - }, - clientPermissions: ['EMBED_LINKS'], - args: [ - { - id: 'command', - type: 'commandAlias' - } - ], - slashCommandOptions: [ - { - type: ApplicationCommandOptionType.STRING, - name: 'command', - description: 'The command to get help for', - required: false - } - ] - }); - } - - private generateEmbed(command?: BushCommand): MessageEmbed { - const prefix = this.handler.prefix; - if (!command) { - const embed = new MessageEmbed() - .addField( - 'Commands', - stripIndent`A list of available commands. - For additional info on a command, type \`${prefix}help \` - ` - ) - .setFooter( - `For more information about a command use "${this.client.config.prefix}help "` - ) - .setTimestamp(); - for (const category of this.handler.categories.values()) { - embed.addField( - `${category.id.replace(/(\b\w)/gi, (lc): string => - lc.toUpperCase() - )}`, - `${category - .filter((cmd): boolean => cmd.aliases.length > 0) - .map((cmd): string => `\`${cmd.aliases[0]}\``) - .join(' ')}` - ); - } - return embed; - } else { - const embed = new MessageEmbed() - .setColor([155, 200, 200]) - .setTitle( - `\`${command.description.usage ? command.description.usage : ''}\`` - ) - .addField( - 'Description', - `${command.description.content ? command.description.content : ''} ${ - command.ownerOnly ? '\n__Owner Only__' : '' - }` - ); - - if (command.aliases.length > 1) - embed.addField('Aliases', `\`${command.aliases.join('` `')}\``, true); - if (command.description.examples && command.description.examples.length) - embed.addField( - 'Examples', - `\`${command.description.examples.join('`\n`')}\``, - true - ); - return embed; - } - } - - public async exec( - message: Message, - { command }: { command: BushCommand } - ): Promise { - await message.util.send(this.generateEmbed(command)); - } - - public async execSlash( - message: CommandInteraction, - { command }: { command: SlashCommandOption } - ): Promise { - if (command) { - await message.reply( - this.generateEmbed( - this.handler.findCommand(command.value) as BushCommand - ) - ); - } else { - await message.reply(this.generateEmbed()); - } - } -} diff --git a/src/commands/info/helpCommand.ts b/src/commands/info/helpCommand.ts new file mode 100644 index 0000000..30c2a21 --- /dev/null +++ b/src/commands/info/helpCommand.ts @@ -0,0 +1,107 @@ +import { Message, MessageEmbed } from 'discord.js'; +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { stripIndent } from 'common-tags'; +import { ApplicationCommandOptionType } from 'discord-api-types'; +import { CommandInteraction } from 'discord.js'; +import { SlashCommandOption } from '../../lib/extensions/Util'; + +export default class HelpCommand extends BushCommand { + constructor() { + super('help', { + aliases: ['help'], + description: { + content: 'Shows the commands of the bot', + usage: 'help', + examples: ['help'] + }, + clientPermissions: ['EMBED_LINKS'], + args: [ + { + id: 'command', + type: 'commandAlias' + } + ], + slashCommandOptions: [ + { + type: ApplicationCommandOptionType.STRING, + name: 'command', + description: 'The command to get help for', + required: false + } + ] + }); + } + + private generateEmbed(command?: BushCommand): MessageEmbed { + const prefix = this.handler.prefix; + if (!command) { + const embed = new MessageEmbed() + .addField( + 'Commands', + stripIndent`A list of available commands. + For additional info on a command, type \`${prefix}help \` + ` + ) + .setFooter( + `For more information about a command use "${this.client.config.prefix}help "` + ) + .setTimestamp(); + for (const category of this.handler.categories.values()) { + embed.addField( + `${category.id.replace(/(\b\w)/gi, (lc): string => + lc.toUpperCase() + )}`, + `${category + .filter((cmd): boolean => cmd.aliases.length > 0) + .map((cmd): string => `\`${cmd.aliases[0]}\``) + .join(' ')}` + ); + } + return embed; + } else { + const embed = new MessageEmbed() + .setColor([155, 200, 200]) + .setTitle( + `\`${command.description.usage ? command.description.usage : ''}\`` + ) + .addField( + 'Description', + `${command.description.content ? command.description.content : ''} ${ + command.ownerOnly ? '\n__Owner Only__' : '' + }` + ); + + if (command.aliases.length > 1) + embed.addField('Aliases', `\`${command.aliases.join('` `')}\``, true); + if (command.description.examples && command.description.examples.length) + embed.addField( + 'Examples', + `\`${command.description.examples.join('`\n`')}\``, + true + ); + return embed; + } + } + + public async exec( + message: Message, + { command }: { command: BushCommand } + ): Promise { + await message.util.send(this.generateEmbed(command)); + } + + public async execSlash( + message: CommandInteraction, + { command }: { command: SlashCommandOption } + ): Promise { + if (command) { + await message.reply( + this.generateEmbed( + this.handler.findCommand(command.value) as BushCommand + ) + ); + } else { + await message.reply(this.generateEmbed()); + } + } +} diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts deleted file mode 100644 index 62b8e60..0000000 --- a/src/commands/info/ping.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { CommandInteraction } from 'discord.js'; -import { Message } from 'discord.js'; -import { MessageEmbed } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; - -export default class PingCommand extends BushCommand { - constructor() { - super('ping', { - aliases: ['ping'], - description: { - content: 'Gets the latency of the bot', - usage: 'ping', - examples: ['ping'] - } - }); - } - - public async exec(message: Message): Promise { - const sentMessage = await message.util.send('Pong!'); - const timestamp: number = message.editedTimestamp - ? message.editedTimestamp - : message.createdTimestamp; - const botLatency = `\`\`\`\n ${Math.floor( - sentMessage.createdTimestamp - timestamp - )}ms \`\`\``; - const apiLatency = `\`\`\`\n ${Math.round( - message.client.ws.ping - )}ms \`\`\``; - const embed = new MessageEmbed() - .setTitle('Pong! 🏓') - .addField('Bot Latency', botLatency, true) - .addField('API Latency', apiLatency, true) - .setFooter( - message.author.username, - message.author.displayAvatarURL({ dynamic: true }) - ) - .setTimestamp(); - await sentMessage.edit({ - content: null, - embed - }); - } - - public async execSlash(message: CommandInteraction): Promise { - const timestamp1 = message.createdTimestamp; - await message.reply('Pong!'); - const timestamp2 = await message - .fetchReply() - .then((m) => (m as Message).createdTimestamp); - const botLatency = `\`\`\`\n ${Math.floor( - timestamp2 - timestamp1 - )}ms \`\`\``; - const apiLatency = `\`\`\`\n ${Math.round(this.client.ws.ping)}ms \`\`\``; - const embed = new MessageEmbed() - .setTitle('Pong! 🏓') - .addField('Bot Latency', botLatency, true) - .addField('API Latency', apiLatency, true) - .setFooter( - message.user.username, - message.user.displayAvatarURL({ dynamic: true }) - ) - .setTimestamp(); - await message.editReply({ - content: null, - embeds: [embed] - }); - } -} diff --git a/src/commands/info/pingCommand.ts b/src/commands/info/pingCommand.ts new file mode 100644 index 0000000..62b8e60 --- /dev/null +++ b/src/commands/info/pingCommand.ts @@ -0,0 +1,68 @@ +import { CommandInteraction } from 'discord.js'; +import { Message } from 'discord.js'; +import { MessageEmbed } from 'discord.js'; +import { BushCommand } from '../../lib/extensions/BushCommand'; + +export default class PingCommand extends BushCommand { + constructor() { + super('ping', { + aliases: ['ping'], + description: { + content: 'Gets the latency of the bot', + usage: 'ping', + examples: ['ping'] + } + }); + } + + public async exec(message: Message): Promise { + const sentMessage = await message.util.send('Pong!'); + const timestamp: number = message.editedTimestamp + ? message.editedTimestamp + : message.createdTimestamp; + const botLatency = `\`\`\`\n ${Math.floor( + sentMessage.createdTimestamp - timestamp + )}ms \`\`\``; + const apiLatency = `\`\`\`\n ${Math.round( + message.client.ws.ping + )}ms \`\`\``; + const embed = new MessageEmbed() + .setTitle('Pong! 🏓') + .addField('Bot Latency', botLatency, true) + .addField('API Latency', apiLatency, true) + .setFooter( + message.author.username, + message.author.displayAvatarURL({ dynamic: true }) + ) + .setTimestamp(); + await sentMessage.edit({ + content: null, + embed + }); + } + + public async execSlash(message: CommandInteraction): Promise { + const timestamp1 = message.createdTimestamp; + await message.reply('Pong!'); + const timestamp2 = await message + .fetchReply() + .then((m) => (m as Message).createdTimestamp); + const botLatency = `\`\`\`\n ${Math.floor( + timestamp2 - timestamp1 + )}ms \`\`\``; + const apiLatency = `\`\`\`\n ${Math.round(this.client.ws.ping)}ms \`\`\``; + const embed = new MessageEmbed() + .setTitle('Pong! 🏓') + .addField('Bot Latency', botLatency, true) + .addField('API Latency', apiLatency, true) + .setFooter( + message.user.username, + message.user.displayAvatarURL({ dynamic: true }) + ) + .setTimestamp(); + await message.editReply({ + content: null, + embeds: [embed] + }); + } +} diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts deleted file mode 100644 index f30a981..0000000 --- a/src/commands/info/pronouns.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { User, Message, MessageEmbed } from 'discord.js'; -import got, { HTTPError } from 'got'; -import { CommandInteraction } from 'discord.js'; -import { ApplicationCommandOptionType } from 'discord-api-types'; -import { SlashCommandOption } from '../../lib/extensions/Util'; - -export const pronounMapping = { - unspecified: 'Unspecified', - hh: 'He/Him', - hi: 'He/It', - hs: 'He/She', - ht: 'He/They', - ih: 'It/Him', - ii: 'It/Its', - is: 'It/She', - it: 'It/They', - shh: 'She/He', - sh: 'She/Her', - si: 'She/It', - st: 'She/They', - th: 'They/He', - ti: 'They/It', - ts: 'They/She', - tt: 'They/Them', - any: 'Any pronouns', - other: 'Other pronouns', - ask: 'Ask me my pronouns', - avoid: 'Avoid pronouns, use my name' -}; -export type pronounsType = keyof typeof pronounMapping; - -export default class PronounsCommand extends BushCommand { - constructor() { - super('pronouns', { - aliases: ['pronouns', 'pronoun'], - category: 'utilities', - description: { - usage: 'pronouns ', - examples: ['pronouns IRONM00N'], - content: 'Finds the pronouns of a user using https://pronoundb.org.' - }, - args: [ - { - id: 'user', - type: 'user', - default: null - } - ], - clientPermissions: ['SEND_MESSAGES'], - slashCommandOptions: [ - { - type: ApplicationCommandOptionType.USER, - name: 'user', - description: 'The user to get pronouns for', - required: false - } - ], - slashEmphemeral: true // I'll add dynamic checking to this later - }); - } - async sendResponse( - message: Message | CommandInteraction, - user: User, - author: boolean - ): Promise { - try { - const apiRes: { pronouns: pronounsType } = await got - .get( - `https://pronoundb.org/api/v1/lookup?platform=discord&id=${user.id}` - ) - .json(); - if (message instanceof Message) { - message.reply( - new MessageEmbed({ - title: `${author ? 'Your' : `${user.tag}'s`} pronouns:`, - description: pronounMapping[apiRes.pronouns], - footer: { - text: 'Data provided by https://pronoundb.org/' - } - }) - ); - } else { - message.reply({ - embeds: [ - new MessageEmbed({ - title: `${author ? 'Your' : `${user.tag}'s`} pronouns:`, - description: pronounMapping[apiRes.pronouns], - footer: { - text: 'Data provided by https://pronoundb.org/' - } - }) - ] - }); - } - } catch (e) { - if (e instanceof HTTPError && e.response.statusCode === 404) { - if (author) { - await message.reply( - 'You do not appear to have any pronouns set. Please go to https://pronoundb.org/ and set your pronouns.' - ); - } else { - await message.reply( - `${user.tag} does not appear to have any pronouns set. Please tell them to go to https://pronoundb.org/ and set their pronouns.` - ); - } - } else throw e; - } - } - async exec(message: Message, { user }: { user?: User }): Promise { - const u = user || message.author; - await this.sendResponse(message, u, u.id === message.author.id); - } - async execSlash( - message: CommandInteraction, - { user }: { user?: SlashCommandOption } - ): Promise { - const u = user?.user || message.user; - await this.sendResponse(message, u, u.id === message.user.id); - } -} diff --git a/src/commands/info/pronounsCommand.ts b/src/commands/info/pronounsCommand.ts new file mode 100644 index 0000000..f30a981 --- /dev/null +++ b/src/commands/info/pronounsCommand.ts @@ -0,0 +1,121 @@ +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { User, Message, MessageEmbed } from 'discord.js'; +import got, { HTTPError } from 'got'; +import { CommandInteraction } from 'discord.js'; +import { ApplicationCommandOptionType } from 'discord-api-types'; +import { SlashCommandOption } from '../../lib/extensions/Util'; + +export const pronounMapping = { + unspecified: 'Unspecified', + hh: 'He/Him', + hi: 'He/It', + hs: 'He/She', + ht: 'He/They', + ih: 'It/Him', + ii: 'It/Its', + is: 'It/She', + it: 'It/They', + shh: 'She/He', + sh: 'She/Her', + si: 'She/It', + st: 'She/They', + th: 'They/He', + ti: 'They/It', + ts: 'They/She', + tt: 'They/Them', + any: 'Any pronouns', + other: 'Other pronouns', + ask: 'Ask me my pronouns', + avoid: 'Avoid pronouns, use my name' +}; +export type pronounsType = keyof typeof pronounMapping; + +export default class PronounsCommand extends BushCommand { + constructor() { + super('pronouns', { + aliases: ['pronouns', 'pronoun'], + category: 'utilities', + description: { + usage: 'pronouns ', + examples: ['pronouns IRONM00N'], + content: 'Finds the pronouns of a user using https://pronoundb.org.' + }, + args: [ + { + id: 'user', + type: 'user', + default: null + } + ], + clientPermissions: ['SEND_MESSAGES'], + slashCommandOptions: [ + { + type: ApplicationCommandOptionType.USER, + name: 'user', + description: 'The user to get pronouns for', + required: false + } + ], + slashEmphemeral: true // I'll add dynamic checking to this later + }); + } + async sendResponse( + message: Message | CommandInteraction, + user: User, + author: boolean + ): Promise { + try { + const apiRes: { pronouns: pronounsType } = await got + .get( + `https://pronoundb.org/api/v1/lookup?platform=discord&id=${user.id}` + ) + .json(); + if (message instanceof Message) { + message.reply( + new MessageEmbed({ + title: `${author ? 'Your' : `${user.tag}'s`} pronouns:`, + description: pronounMapping[apiRes.pronouns], + footer: { + text: 'Data provided by https://pronoundb.org/' + } + }) + ); + } else { + message.reply({ + embeds: [ + new MessageEmbed({ + title: `${author ? 'Your' : `${user.tag}'s`} pronouns:`, + description: pronounMapping[apiRes.pronouns], + footer: { + text: 'Data provided by https://pronoundb.org/' + } + }) + ] + }); + } + } catch (e) { + if (e instanceof HTTPError && e.response.statusCode === 404) { + if (author) { + await message.reply( + 'You do not appear to have any pronouns set. Please go to https://pronoundb.org/ and set your pronouns.' + ); + } else { + await message.reply( + `${user.tag} does not appear to have any pronouns set. Please tell them to go to https://pronoundb.org/ and set their pronouns.` + ); + } + } else throw e; + } + } + async exec(message: Message, { user }: { user?: User }): Promise { + const u = user || message.author; + await this.sendResponse(message, u, u.id === message.author.id); + } + async execSlash( + message: CommandInteraction, + { user }: { user?: SlashCommandOption } + ): Promise { + const u = user?.user || message.user; + await this.sendResponse(message, u, u.id === message.user.id); + } +} -- cgit From 358113f823936a8b5613535067941a17169d942f Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Wed, 26 May 2021 22:01:05 -0400 Subject: add info category to commands --- src/commands/info/botInfoCommand.ts | 1 + src/commands/info/helpCommand.ts | 1 + src/commands/info/pingCommand.ts | 1 + src/commands/info/pronounsCommand.ts | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/commands/info') diff --git a/src/commands/info/botInfoCommand.ts b/src/commands/info/botInfoCommand.ts index e6a4fbb..779b318 100644 --- a/src/commands/info/botInfoCommand.ts +++ b/src/commands/info/botInfoCommand.ts @@ -6,6 +6,7 @@ export default class BotInfoCommand extends BushCommand { constructor() { super('botinfo', { aliases: ['botinfo'], + category: 'info', description: { content: 'Shows information about the bot', usage: 'botinfo', diff --git a/src/commands/info/helpCommand.ts b/src/commands/info/helpCommand.ts index 30c2a21..3b5e538 100644 --- a/src/commands/info/helpCommand.ts +++ b/src/commands/info/helpCommand.ts @@ -9,6 +9,7 @@ export default class HelpCommand extends BushCommand { constructor() { super('help', { aliases: ['help'], + category: 'info', description: { content: 'Shows the commands of the bot', usage: 'help', diff --git a/src/commands/info/pingCommand.ts b/src/commands/info/pingCommand.ts index 62b8e60..e0bbfc7 100644 --- a/src/commands/info/pingCommand.ts +++ b/src/commands/info/pingCommand.ts @@ -7,6 +7,7 @@ export default class PingCommand extends BushCommand { constructor() { super('ping', { aliases: ['ping'], + category: 'info', description: { content: 'Gets the latency of the bot', usage: 'ping', diff --git a/src/commands/info/pronounsCommand.ts b/src/commands/info/pronounsCommand.ts index f30a981..2c1d5f2 100644 --- a/src/commands/info/pronounsCommand.ts +++ b/src/commands/info/pronounsCommand.ts @@ -34,7 +34,7 @@ export default class PronounsCommand extends BushCommand { constructor() { super('pronouns', { aliases: ['pronouns', 'pronoun'], - category: 'utilities', + category: 'info', description: { usage: 'pronouns ', examples: ['pronouns IRONM00N'], -- cgit From 1546da359646b89f13d17784eb7653a52ca61efd Mon Sep 17 00:00:00 2001 From: TymanWasTaken Date: Thu, 27 May 2021 14:58:21 -0600 Subject: Fix file naming --- src/commands/info/botInfo.ts | 66 +++++++++++++++++++ src/commands/info/botInfoCommand.ts | 66 ------------------- src/commands/info/help.ts | 108 +++++++++++++++++++++++++++++++ src/commands/info/helpCommand.ts | 108 ------------------------------- src/commands/info/ping.ts | 69 ++++++++++++++++++++ src/commands/info/pingCommand.ts | 69 -------------------- src/commands/info/pronouns.ts | 121 +++++++++++++++++++++++++++++++++++ src/commands/info/pronounsCommand.ts | 121 ----------------------------------- 8 files changed, 364 insertions(+), 364 deletions(-) create mode 100644 src/commands/info/botInfo.ts delete mode 100644 src/commands/info/botInfoCommand.ts create mode 100644 src/commands/info/help.ts delete mode 100644 src/commands/info/helpCommand.ts create mode 100644 src/commands/info/ping.ts delete mode 100644 src/commands/info/pingCommand.ts create mode 100644 src/commands/info/pronouns.ts delete mode 100644 src/commands/info/pronounsCommand.ts (limited to 'src/commands/info') diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts new file mode 100644 index 0000000..779b318 --- /dev/null +++ b/src/commands/info/botInfo.ts @@ -0,0 +1,66 @@ +import { MessageEmbed, Message, CommandInteraction } from 'discord.js'; +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { duration } from 'moment'; + +export default class BotInfoCommand extends BushCommand { + constructor() { + super('botinfo', { + aliases: ['botinfo'], + category: 'info', + description: { + content: 'Shows information about the bot', + usage: 'botinfo', + examples: ['botinfo'] + } + }); + } + + private async generateEmbed(): Promise { + const owners = (await this.client.util.mapIDs(this.client.ownerID)) + .map((u) => u.tag) + .join('\n'); + const currentCommit = ( + await this.client.util.shell('git rev-parse HEAD') + ).stdout.replace('\n', ''); + const repoUrl = ( + await this.client.util.shell('git remote get-url origin') + ).stdout.replace('\n', ''); + const embed = new MessageEmbed() + .setTitle('Bot Info:') + .addFields([ + { + name: 'Owners', + value: owners, + inline: true + }, + { + name: 'Uptime', + value: this.client.util.capitalize( + duration(this.client.uptime, 'milliseconds').humanize() + ) + }, + { + name: 'User count', + value: this.client.users.cache.size, + inline: true + }, + { + name: 'Current commit', + value: `[${currentCommit.substring( + 0, + 7 + )}](${repoUrl}/commit/${currentCommit})` + } + ]) + .setTimestamp(); + return embed; + } + + public async exec(message: Message): Promise { + await message.util.send(await this.generateEmbed()); + } + + public async execSlash(message: CommandInteraction): Promise { + await message.reply(await this.generateEmbed()); + } +} diff --git a/src/commands/info/botInfoCommand.ts b/src/commands/info/botInfoCommand.ts deleted file mode 100644 index 779b318..0000000 --- a/src/commands/info/botInfoCommand.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { MessageEmbed, Message, CommandInteraction } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { duration } from 'moment'; - -export default class BotInfoCommand extends BushCommand { - constructor() { - super('botinfo', { - aliases: ['botinfo'], - category: 'info', - description: { - content: 'Shows information about the bot', - usage: 'botinfo', - examples: ['botinfo'] - } - }); - } - - private async generateEmbed(): Promise { - const owners = (await this.client.util.mapIDs(this.client.ownerID)) - .map((u) => u.tag) - .join('\n'); - const currentCommit = ( - await this.client.util.shell('git rev-parse HEAD') - ).stdout.replace('\n', ''); - const repoUrl = ( - await this.client.util.shell('git remote get-url origin') - ).stdout.replace('\n', ''); - const embed = new MessageEmbed() - .setTitle('Bot Info:') - .addFields([ - { - name: 'Owners', - value: owners, - inline: true - }, - { - name: 'Uptime', - value: this.client.util.capitalize( - duration(this.client.uptime, 'milliseconds').humanize() - ) - }, - { - name: 'User count', - value: this.client.users.cache.size, - inline: true - }, - { - name: 'Current commit', - value: `[${currentCommit.substring( - 0, - 7 - )}](${repoUrl}/commit/${currentCommit})` - } - ]) - .setTimestamp(); - return embed; - } - - public async exec(message: Message): Promise { - await message.util.send(await this.generateEmbed()); - } - - public async execSlash(message: CommandInteraction): Promise { - await message.reply(await this.generateEmbed()); - } -} diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts new file mode 100644 index 0000000..3b5e538 --- /dev/null +++ b/src/commands/info/help.ts @@ -0,0 +1,108 @@ +import { Message, MessageEmbed } from 'discord.js'; +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { stripIndent } from 'common-tags'; +import { ApplicationCommandOptionType } from 'discord-api-types'; +import { CommandInteraction } from 'discord.js'; +import { SlashCommandOption } from '../../lib/extensions/Util'; + +export default class HelpCommand extends BushCommand { + constructor() { + super('help', { + aliases: ['help'], + category: 'info', + description: { + content: 'Shows the commands of the bot', + usage: 'help', + examples: ['help'] + }, + clientPermissions: ['EMBED_LINKS'], + args: [ + { + id: 'command', + type: 'commandAlias' + } + ], + slashCommandOptions: [ + { + type: ApplicationCommandOptionType.STRING, + name: 'command', + description: 'The command to get help for', + required: false + } + ] + }); + } + + private generateEmbed(command?: BushCommand): MessageEmbed { + const prefix = this.handler.prefix; + if (!command) { + const embed = new MessageEmbed() + .addField( + 'Commands', + stripIndent`A list of available commands. + For additional info on a command, type \`${prefix}help \` + ` + ) + .setFooter( + `For more information about a command use "${this.client.config.prefix}help "` + ) + .setTimestamp(); + for (const category of this.handler.categories.values()) { + embed.addField( + `${category.id.replace(/(\b\w)/gi, (lc): string => + lc.toUpperCase() + )}`, + `${category + .filter((cmd): boolean => cmd.aliases.length > 0) + .map((cmd): string => `\`${cmd.aliases[0]}\``) + .join(' ')}` + ); + } + return embed; + } else { + const embed = new MessageEmbed() + .setColor([155, 200, 200]) + .setTitle( + `\`${command.description.usage ? command.description.usage : ''}\`` + ) + .addField( + 'Description', + `${command.description.content ? command.description.content : ''} ${ + command.ownerOnly ? '\n__Owner Only__' : '' + }` + ); + + if (command.aliases.length > 1) + embed.addField('Aliases', `\`${command.aliases.join('` `')}\``, true); + if (command.description.examples && command.description.examples.length) + embed.addField( + 'Examples', + `\`${command.description.examples.join('`\n`')}\``, + true + ); + return embed; + } + } + + public async exec( + message: Message, + { command }: { command: BushCommand } + ): Promise { + await message.util.send(this.generateEmbed(command)); + } + + public async execSlash( + message: CommandInteraction, + { command }: { command: SlashCommandOption } + ): Promise { + if (command) { + await message.reply( + this.generateEmbed( + this.handler.findCommand(command.value) as BushCommand + ) + ); + } else { + await message.reply(this.generateEmbed()); + } + } +} diff --git a/src/commands/info/helpCommand.ts b/src/commands/info/helpCommand.ts deleted file mode 100644 index 3b5e538..0000000 --- a/src/commands/info/helpCommand.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { Message, MessageEmbed } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { stripIndent } from 'common-tags'; -import { ApplicationCommandOptionType } from 'discord-api-types'; -import { CommandInteraction } from 'discord.js'; -import { SlashCommandOption } from '../../lib/extensions/Util'; - -export default class HelpCommand extends BushCommand { - constructor() { - super('help', { - aliases: ['help'], - category: 'info', - description: { - content: 'Shows the commands of the bot', - usage: 'help', - examples: ['help'] - }, - clientPermissions: ['EMBED_LINKS'], - args: [ - { - id: 'command', - type: 'commandAlias' - } - ], - slashCommandOptions: [ - { - type: ApplicationCommandOptionType.STRING, - name: 'command', - description: 'The command to get help for', - required: false - } - ] - }); - } - - private generateEmbed(command?: BushCommand): MessageEmbed { - const prefix = this.handler.prefix; - if (!command) { - const embed = new MessageEmbed() - .addField( - 'Commands', - stripIndent`A list of available commands. - For additional info on a command, type \`${prefix}help \` - ` - ) - .setFooter( - `For more information about a command use "${this.client.config.prefix}help "` - ) - .setTimestamp(); - for (const category of this.handler.categories.values()) { - embed.addField( - `${category.id.replace(/(\b\w)/gi, (lc): string => - lc.toUpperCase() - )}`, - `${category - .filter((cmd): boolean => cmd.aliases.length > 0) - .map((cmd): string => `\`${cmd.aliases[0]}\``) - .join(' ')}` - ); - } - return embed; - } else { - const embed = new MessageEmbed() - .setColor([155, 200, 200]) - .setTitle( - `\`${command.description.usage ? command.description.usage : ''}\`` - ) - .addField( - 'Description', - `${command.description.content ? command.description.content : ''} ${ - command.ownerOnly ? '\n__Owner Only__' : '' - }` - ); - - if (command.aliases.length > 1) - embed.addField('Aliases', `\`${command.aliases.join('` `')}\``, true); - if (command.description.examples && command.description.examples.length) - embed.addField( - 'Examples', - `\`${command.description.examples.join('`\n`')}\``, - true - ); - return embed; - } - } - - public async exec( - message: Message, - { command }: { command: BushCommand } - ): Promise { - await message.util.send(this.generateEmbed(command)); - } - - public async execSlash( - message: CommandInteraction, - { command }: { command: SlashCommandOption } - ): Promise { - if (command) { - await message.reply( - this.generateEmbed( - this.handler.findCommand(command.value) as BushCommand - ) - ); - } else { - await message.reply(this.generateEmbed()); - } - } -} diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts new file mode 100644 index 0000000..e0bbfc7 --- /dev/null +++ b/src/commands/info/ping.ts @@ -0,0 +1,69 @@ +import { CommandInteraction } from 'discord.js'; +import { Message } from 'discord.js'; +import { MessageEmbed } from 'discord.js'; +import { BushCommand } from '../../lib/extensions/BushCommand'; + +export default class PingCommand extends BushCommand { + constructor() { + super('ping', { + aliases: ['ping'], + category: 'info', + description: { + content: 'Gets the latency of the bot', + usage: 'ping', + examples: ['ping'] + } + }); + } + + public async exec(message: Message): Promise { + const sentMessage = await message.util.send('Pong!'); + const timestamp: number = message.editedTimestamp + ? message.editedTimestamp + : message.createdTimestamp; + const botLatency = `\`\`\`\n ${Math.floor( + sentMessage.createdTimestamp - timestamp + )}ms \`\`\``; + const apiLatency = `\`\`\`\n ${Math.round( + message.client.ws.ping + )}ms \`\`\``; + const embed = new MessageEmbed() + .setTitle('Pong! 🏓') + .addField('Bot Latency', botLatency, true) + .addField('API Latency', apiLatency, true) + .setFooter( + message.author.username, + message.author.displayAvatarURL({ dynamic: true }) + ) + .setTimestamp(); + await sentMessage.edit({ + content: null, + embed + }); + } + + public async execSlash(message: CommandInteraction): Promise { + const timestamp1 = message.createdTimestamp; + await message.reply('Pong!'); + const timestamp2 = await message + .fetchReply() + .then((m) => (m as Message).createdTimestamp); + const botLatency = `\`\`\`\n ${Math.floor( + timestamp2 - timestamp1 + )}ms \`\`\``; + const apiLatency = `\`\`\`\n ${Math.round(this.client.ws.ping)}ms \`\`\``; + const embed = new MessageEmbed() + .setTitle('Pong! 🏓') + .addField('Bot Latency', botLatency, true) + .addField('API Latency', apiLatency, true) + .setFooter( + message.user.username, + message.user.displayAvatarURL({ dynamic: true }) + ) + .setTimestamp(); + await message.editReply({ + content: null, + embeds: [embed] + }); + } +} diff --git a/src/commands/info/pingCommand.ts b/src/commands/info/pingCommand.ts deleted file mode 100644 index e0bbfc7..0000000 --- a/src/commands/info/pingCommand.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { CommandInteraction } from 'discord.js'; -import { Message } from 'discord.js'; -import { MessageEmbed } from 'discord.js'; -import { BushCommand } from '../../lib/extensions/BushCommand'; - -export default class PingCommand extends BushCommand { - constructor() { - super('ping', { - aliases: ['ping'], - category: 'info', - description: { - content: 'Gets the latency of the bot', - usage: 'ping', - examples: ['ping'] - } - }); - } - - public async exec(message: Message): Promise { - const sentMessage = await message.util.send('Pong!'); - const timestamp: number = message.editedTimestamp - ? message.editedTimestamp - : message.createdTimestamp; - const botLatency = `\`\`\`\n ${Math.floor( - sentMessage.createdTimestamp - timestamp - )}ms \`\`\``; - const apiLatency = `\`\`\`\n ${Math.round( - message.client.ws.ping - )}ms \`\`\``; - const embed = new MessageEmbed() - .setTitle('Pong! 🏓') - .addField('Bot Latency', botLatency, true) - .addField('API Latency', apiLatency, true) - .setFooter( - message.author.username, - message.author.displayAvatarURL({ dynamic: true }) - ) - .setTimestamp(); - await sentMessage.edit({ - content: null, - embed - }); - } - - public async execSlash(message: CommandInteraction): Promise { - const timestamp1 = message.createdTimestamp; - await message.reply('Pong!'); - const timestamp2 = await message - .fetchReply() - .then((m) => (m as Message).createdTimestamp); - const botLatency = `\`\`\`\n ${Math.floor( - timestamp2 - timestamp1 - )}ms \`\`\``; - const apiLatency = `\`\`\`\n ${Math.round(this.client.ws.ping)}ms \`\`\``; - const embed = new MessageEmbed() - .setTitle('Pong! 🏓') - .addField('Bot Latency', botLatency, true) - .addField('API Latency', apiLatency, true) - .setFooter( - message.user.username, - message.user.displayAvatarURL({ dynamic: true }) - ) - .setTimestamp(); - await message.editReply({ - content: null, - embeds: [embed] - }); - } -} diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts new file mode 100644 index 0000000..2c1d5f2 --- /dev/null +++ b/src/commands/info/pronouns.ts @@ -0,0 +1,121 @@ +import { BushCommand } from '../../lib/extensions/BushCommand'; +import { User, Message, MessageEmbed } from 'discord.js'; +import got, { HTTPError } from 'got'; +import { CommandInteraction } from 'discord.js'; +import { ApplicationCommandOptionType } from 'discord-api-types'; +import { SlashCommandOption } from '../../lib/extensions/Util'; + +export const pronounMapping = { + unspecified: 'Unspecified', + hh: 'He/Him', + hi: 'He/It', + hs: 'He/She', + ht: 'He/They', + ih: 'It/Him', + ii: 'It/Its', + is: 'It/She', + it: 'It/They', + shh: 'She/He', + sh: 'She/Her', + si: 'She/It', + st: 'She/They', + th: 'They/He', + ti: 'They/It', + ts: 'They/She', + tt: 'They/Them', + any: 'Any pronouns', + other: 'Other pronouns', + ask: 'Ask me my pronouns', + avoid: 'Avoid pronouns, use my name' +}; +export type pronounsType = keyof typeof pronounMapping; + +export default class PronounsCommand extends BushCommand { + constructor() { + super('pronouns', { + aliases: ['pronouns', 'pronoun'], + category: 'info', + description: { + usage: 'pronouns ', + examples: ['pronouns IRONM00N'], + content: 'Finds the pronouns of a user using https://pronoundb.org.' + }, + args: [ + { + id: 'user', + type: 'user', + default: null + } + ], + clientPermissions: ['SEND_MESSAGES'], + slashCommandOptions: [ + { + type: ApplicationCommandOptionType.USER, + name: 'user', + description: 'The user to get pronouns for', + required: false + } + ], + slashEmphemeral: true // I'll add dynamic checking to this later + }); + } + async sendResponse( + message: Message | CommandInteraction, + user: User, + author: boolean + ): Promise { + try { + const apiRes: { pronouns: pronounsType } = await got + .get( + `https://pronoundb.org/api/v1/lookup?platform=discord&id=${user.id}` + ) + .json(); + if (message instanceof Message) { + message.reply( + new MessageEmbed({ + title: `${author ? 'Your' : `${user.tag}'s`} pronouns:`, + description: pronounMapping[apiRes.pronouns], + footer: { + text: 'Data provided by https://pronoundb.org/' + } + }) + ); + } else { + message.reply({ + embeds: [ + new MessageEmbed({ + title: `${author ? 'Your' : `${user.tag}'s`} pronouns:`, + description: pronounMapping[apiRes.pronouns], + footer: { + text: 'Data provided by https://pronoundb.org/' + } + }) + ] + }); + } + } catch (e) { + if (e instanceof HTTPError && e.response.statusCode === 404) { + if (author) { + await message.reply( + 'You do not appear to have any pronouns set. Please go to https://pronoundb.org/ and set your pronouns.' + ); + } else { + await message.reply( + `${user.tag} does not appear to have any pronouns set. Please tell them to go to https://pronoundb.org/ and set their pronouns.` + ); + } + } else throw e; + } + } + async exec(message: Message, { user }: { user?: User }): Promise { + const u = user || message.author; + await this.sendResponse(message, u, u.id === message.author.id); + } + async execSlash( + message: CommandInteraction, + { user }: { user?: SlashCommandOption } + ): Promise { + const u = user?.user || message.user; + await this.sendResponse(message, u, u.id === message.user.id); + } +} diff --git a/src/commands/info/pronounsCommand.ts b/src/commands/info/pronounsCommand.ts deleted file mode 100644 index 2c1d5f2..0000000 --- a/src/commands/info/pronounsCommand.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { BushCommand } from '../../lib/extensions/BushCommand'; -import { User, Message, MessageEmbed } from 'discord.js'; -import got, { HTTPError } from 'got'; -import { CommandInteraction } from 'discord.js'; -import { ApplicationCommandOptionType } from 'discord-api-types'; -import { SlashCommandOption } from '../../lib/extensions/Util'; - -export const pronounMapping = { - unspecified: 'Unspecified', - hh: 'He/Him', - hi: 'He/It', - hs: 'He/She', - ht: 'He/They', - ih: 'It/Him', - ii: 'It/Its', - is: 'It/She', - it: 'It/They', - shh: 'She/He', - sh: 'She/Her', - si: 'She/It', - st: 'She/They', - th: 'They/He', - ti: 'They/It', - ts: 'They/She', - tt: 'They/Them', - any: 'Any pronouns', - other: 'Other pronouns', - ask: 'Ask me my pronouns', - avoid: 'Avoid pronouns, use my name' -}; -export type pronounsType = keyof typeof pronounMapping; - -export default class PronounsCommand extends BushCommand { - constructor() { - super('pronouns', { - aliases: ['pronouns', 'pronoun'], - category: 'info', - description: { - usage: 'pronouns ', - examples: ['pronouns IRONM00N'], - content: 'Finds the pronouns of a user using https://pronoundb.org.' - }, - args: [ - { - id: 'user', - type: 'user', - default: null - } - ], - clientPermissions: ['SEND_MESSAGES'], - slashCommandOptions: [ - { - type: ApplicationCommandOptionType.USER, - name: 'user', - description: 'The user to get pronouns for', - required: false - } - ], - slashEmphemeral: true // I'll add dynamic checking to this later - }); - } - async sendResponse( - message: Message | CommandInteraction, - user: User, - author: boolean - ): Promise { - try { - const apiRes: { pronouns: pronounsType } = await got - .get( - `https://pronoundb.org/api/v1/lookup?platform=discord&id=${user.id}` - ) - .json(); - if (message instanceof Message) { - message.reply( - new MessageEmbed({ - title: `${author ? 'Your' : `${user.tag}'s`} pronouns:`, - description: pronounMapping[apiRes.pronouns], - footer: { - text: 'Data provided by https://pronoundb.org/' - } - }) - ); - } else { - message.reply({ - embeds: [ - new MessageEmbed({ - title: `${author ? 'Your' : `${user.tag}'s`} pronouns:`, - description: pronounMapping[apiRes.pronouns], - footer: { - text: 'Data provided by https://pronoundb.org/' - } - }) - ] - }); - } - } catch (e) { - if (e instanceof HTTPError && e.response.statusCode === 404) { - if (author) { - await message.reply( - 'You do not appear to have any pronouns set. Please go to https://pronoundb.org/ and set your pronouns.' - ); - } else { - await message.reply( - `${user.tag} does not appear to have any pronouns set. Please tell them to go to https://pronoundb.org/ and set their pronouns.` - ); - } - } else throw e; - } - } - async exec(message: Message, { user }: { user?: User }): Promise { - const u = user || message.author; - await this.sendResponse(message, u, u.id === message.author.id); - } - async execSlash( - message: CommandInteraction, - { user }: { user?: SlashCommandOption } - ): Promise { - const u = user?.user || message.user; - await this.sendResponse(message, u, u.id === message.user.id); - } -} -- cgit From b0bdb217435ac1c8263ba6031bf7d7612f4b10ca Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Fri, 28 May 2021 16:35:47 -0400 Subject: fix "function () { [native code] }" --- src/commands/info/help.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/commands/info') diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 3b5e538..2f4f6b4 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -33,8 +33,9 @@ export default class HelpCommand extends BushCommand { }); } - private generateEmbed(command?: BushCommand): MessageEmbed { - const prefix = this.handler.prefix; + private async generateEmbed(command?: BushCommand): Promise { + //@ts-ignore + const prefix = await this.handler.prefix(); if (!command) { const embed = new MessageEmbed() .addField( @@ -97,12 +98,12 @@ export default class HelpCommand extends BushCommand { ): Promise { if (command) { await message.reply( - this.generateEmbed( + await this.generateEmbed( this.handler.findCommand(command.value) as BushCommand ) ); } else { - await message.reply(this.generateEmbed()); + await message.reply(await this.generateEmbed()); } } } -- cgit From f3cde793e778d1dc29b704d9cce560c6e929e6e8 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Fri, 28 May 2021 16:42:51 -0400 Subject: fuck off --- src/commands/info/help.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'src/commands/info') diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 2f4f6b4..3c2fb47 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -34,6 +34,7 @@ export default class HelpCommand extends BushCommand { } private async generateEmbed(command?: BushCommand): Promise { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore const prefix = await this.handler.prefix(); if (!command) { -- cgit From f1cdbd260c6c2249fc0d765949d44d889bcaedc8 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Fri, 28 May 2021 17:37:04 -0400 Subject: I can't read anything --- src/commands/info/botInfo.ts | 19 +++++++++---------- src/commands/info/ping.ts | 26 ++++++-------------------- src/commands/info/pronouns.ts | 4 +--- 3 files changed, 16 insertions(+), 33 deletions(-) (limited to 'src/commands/info') diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index 779b318..0226edc 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -19,12 +19,14 @@ export default class BotInfoCommand extends BushCommand { const owners = (await this.client.util.mapIDs(this.client.ownerID)) .map((u) => u.tag) .join('\n'); - const currentCommit = ( - await this.client.util.shell('git rev-parse HEAD') - ).stdout.replace('\n', ''); - const repoUrl = ( - await this.client.util.shell('git remote get-url origin') - ).stdout.replace('\n', ''); + const currentCommit = (await this.client.util.shell('git rev-parse HEAD')).stdout.replace( + '\n', + '' + ); + const repoUrl = (await this.client.util.shell('git remote get-url origin')).stdout.replace( + '\n', + '' + ); const embed = new MessageEmbed() .setTitle('Bot Info:') .addFields([ @@ -46,10 +48,7 @@ export default class BotInfoCommand extends BushCommand { }, { name: 'Current commit', - value: `[${currentCommit.substring( - 0, - 7 - )}](${repoUrl}/commit/${currentCommit})` + value: `[${currentCommit.substring(0, 7)}](${repoUrl}/commit/${currentCommit})` } ]) .setTimestamp(); diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index e0bbfc7..9468722 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -21,20 +21,13 @@ export default class PingCommand extends BushCommand { const timestamp: number = message.editedTimestamp ? message.editedTimestamp : message.createdTimestamp; - const botLatency = `\`\`\`\n ${Math.floor( - sentMessage.createdTimestamp - timestamp - )}ms \`\`\``; - const apiLatency = `\`\`\`\n ${Math.round( - message.client.ws.ping - )}ms \`\`\``; + const botLatency = `\`\`\`\n ${Math.floor(sentMessage.createdTimestamp - timestamp)}ms \`\`\``; + const apiLatency = `\`\`\`\n ${Math.round(message.client.ws.ping)}ms \`\`\``; const embed = new MessageEmbed() .setTitle('Pong! 🏓') .addField('Bot Latency', botLatency, true) .addField('API Latency', apiLatency, true) - .setFooter( - message.author.username, - message.author.displayAvatarURL({ dynamic: true }) - ) + .setFooter(message.author.username, message.author.displayAvatarURL({ dynamic: true })) .setTimestamp(); await sentMessage.edit({ content: null, @@ -45,21 +38,14 @@ export default class PingCommand extends BushCommand { public async execSlash(message: CommandInteraction): Promise { const timestamp1 = message.createdTimestamp; await message.reply('Pong!'); - const timestamp2 = await message - .fetchReply() - .then((m) => (m as Message).createdTimestamp); - const botLatency = `\`\`\`\n ${Math.floor( - timestamp2 - timestamp1 - )}ms \`\`\``; + const timestamp2 = await message.fetchReply().then((m) => (m as Message).createdTimestamp); + const botLatency = `\`\`\`\n ${Math.floor(timestamp2 - timestamp1)}ms \`\`\``; const apiLatency = `\`\`\`\n ${Math.round(this.client.ws.ping)}ms \`\`\``; const embed = new MessageEmbed() .setTitle('Pong! 🏓') .addField('Bot Latency', botLatency, true) .addField('API Latency', apiLatency, true) - .setFooter( - message.user.username, - message.user.displayAvatarURL({ dynamic: true }) - ) + .setFooter(message.user.username, message.user.displayAvatarURL({ dynamic: true })) .setTimestamp(); await message.editReply({ content: null, diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 2c1d5f2..ca70ff0 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -66,9 +66,7 @@ export default class PronounsCommand extends BushCommand { ): Promise { try { const apiRes: { pronouns: pronounsType } = await got - .get( - `https://pronoundb.org/api/v1/lookup?platform=discord&id=${user.id}` - ) + .get(`https://pronoundb.org/api/v1/lookup?platform=discord&id=${user.id}`) .json(); if (message instanceof Message) { message.reply( -- cgit From e220f8462bbfb26e3237df34923be4acc5d83fee Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Fri, 28 May 2021 17:37:21 -0400 Subject: remove help crap --- src/commands/info/help.ts | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'src/commands/info') diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index 3c2fb47..7f91cdf 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -33,10 +33,8 @@ export default class HelpCommand extends BushCommand { }); } - private async generateEmbed(command?: BushCommand): Promise { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - //@ts-ignore - const prefix = await this.handler.prefix(); + private generateEmbed(command?: BushCommand): MessageEmbed { + const prefix = this.handler.prefix; if (!command) { const embed = new MessageEmbed() .addField( @@ -51,9 +49,7 @@ export default class HelpCommand extends BushCommand { .setTimestamp(); for (const category of this.handler.categories.values()) { embed.addField( - `${category.id.replace(/(\b\w)/gi, (lc): string => - lc.toUpperCase() - )}`, + `${category.id.replace(/(\b\w)/gi, (lc): string => lc.toUpperCase())}`, `${category .filter((cmd): boolean => cmd.aliases.length > 0) .map((cmd): string => `\`${cmd.aliases[0]}\``) @@ -64,9 +60,7 @@ export default class HelpCommand extends BushCommand { } else { const embed = new MessageEmbed() .setColor([155, 200, 200]) - .setTitle( - `\`${command.description.usage ? command.description.usage : ''}\`` - ) + .setTitle(`\`${command.description.usage ? command.description.usage : ''}\``) .addField( 'Description', `${command.description.content ? command.description.content : ''} ${ @@ -77,19 +71,12 @@ export default class HelpCommand extends BushCommand { if (command.aliases.length > 1) embed.addField('Aliases', `\`${command.aliases.join('` `')}\``, true); if (command.description.examples && command.description.examples.length) - embed.addField( - 'Examples', - `\`${command.description.examples.join('`\n`')}\``, - true - ); + embed.addField('Examples', `\`${command.description.examples.join('`\n`')}\``, true); return embed; } } - public async exec( - message: Message, - { command }: { command: BushCommand } - ): Promise { + public async exec(message: Message, { command }: { command: BushCommand }): Promise { await message.util.send(this.generateEmbed(command)); } @@ -99,12 +86,10 @@ export default class HelpCommand extends BushCommand { ): Promise { if (command) { await message.reply( - await this.generateEmbed( - this.handler.findCommand(command.value) as BushCommand - ) + this.generateEmbed(this.handler.findComm