From 166d7fdf24440db71311c2cda95697c06e7b8b36 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Thu, 21 Oct 2021 00:05:53 -0400 Subject: Refactoring, rewrote ButtonPaginator, better permission handling + support for send messages in threads, optimizations, another scam link --- src/commands/info/avatar.ts | 3 ++- src/commands/info/botInfo.ts | 4 ++-- src/commands/info/color.ts | 3 ++- src/commands/info/guildInfo.ts | 4 ++-- src/commands/info/help.ts | 4 ++-- src/commands/info/icon.ts | 3 ++- src/commands/info/links.ts | 3 ++- src/commands/info/ping.ts | 4 ++-- src/commands/info/pronouns.ts | 17 +++++++---------- src/commands/info/snowflake.ts | 3 ++- src/commands/info/userInfo.ts | 4 ++-- 11 files changed, 27 insertions(+), 25 deletions(-) (limited to 'src/commands/info') diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts index 1e6496a..7625b61 100644 --- a/src/commands/info/avatar.ts +++ b/src/commands/info/avatar.ts @@ -22,7 +22,8 @@ export default class AvatarCommand extends BushCommand { } } ], - clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'], + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), + userPermissions: [], slash: true, slashOptions: [ { diff --git a/src/commands/info/botInfo.ts b/src/commands/info/botInfo.ts index 257dc90..ffb785c 100644 --- a/src/commands/info/botInfo.ts +++ b/src/commands/info/botInfo.ts @@ -14,8 +14,8 @@ export default class BotInfoCommand extends BushCommand { examples: ['botinfo'] }, slash: true, - clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'], - userPermissions: ['SEND_MESSAGES'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), + userPermissions: [] }); } diff --git a/src/commands/info/color.ts b/src/commands/info/color.ts index d641fd7..958aadd 100644 --- a/src/commands/info/color.ts +++ b/src/commands/info/color.ts @@ -31,7 +31,8 @@ export default class ColorCommand extends BushCommand { } ], channel: 'guild', - clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), + userPermissions: [] }); } diff --git a/src/commands/info/guildInfo.ts b/src/commands/info/guildInfo.ts index f1db783..4a79918 100644 --- a/src/commands/info/guildInfo.ts +++ b/src/commands/info/guildInfo.ts @@ -31,8 +31,8 @@ export default class GuildInfoCommand extends BushCommand { required: false } ], - clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'], - userPermissions: ['SEND_MESSAGES'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), + userPermissions: [] }); } diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index ce171c9..5e80199 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -37,8 +37,8 @@ export default class HelpCommand extends BushCommand { required: false } ], - clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'], - userPermissions: ['SEND_MESSAGES'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), + userPermissions: [] }); } diff --git a/src/commands/info/icon.ts b/src/commands/info/icon.ts index 677fdaf..ce27cc0 100644 --- a/src/commands/info/icon.ts +++ b/src/commands/info/icon.ts @@ -11,7 +11,8 @@ export default class IconCommand extends BushCommand { usage: 'icon', examples: 'icon' }, - clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'], + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), + userPermissions: [], channel: 'guild', slash: true }); diff --git a/src/commands/info/links.ts b/src/commands/info/links.ts index b3a762a..569b959 100644 --- a/src/commands/info/links.ts +++ b/src/commands/info/links.ts @@ -14,7 +14,8 @@ export default class LinksCommand extends BushCommand { }, ratelimit: 4, cooldown: 4000, - clientPermissions: ['SEND_MESSAGES'], + clientPermissions: (m) => util.clientSendAndPermCheck(m), + userPermissions: [], slash: true }); } diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts index 5f2220c..82db2ff 100644 --- a/src/commands/info/ping.ts +++ b/src/commands/info/ping.ts @@ -12,8 +12,8 @@ export default class PingCommand extends BushCommand { examples: ['ping'] }, slash: true, - clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'], - userPermissions: ['SEND_MESSAGES'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), + userPermissions: [] }); } diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 77612da..cd66530 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -1,5 +1,4 @@ import { BushCommand, BushMessage, BushSlashMessage } from '@lib'; -import { Snowflake } from 'discord-api-types'; import { MessageEmbed, User } from 'discord.js'; export default class PronounsCommand extends BushCommand { @@ -15,7 +14,7 @@ export default class PronounsCommand extends BushCommand { args: [ { id: 'user', - customType: util.arg.union('user', 'snowflake'), + type: 'globalUser', prompt: { start: 'Who would you like to view the pronouns of?', retry: '{error} Choose a valid user to view the pronouns of.', @@ -23,7 +22,8 @@ export default class PronounsCommand extends BushCommand { } } ], - clientPermissions: ['SEND_MESSAGES'], + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), + userPermissions: [], slashOptions: [ { name: 'user', @@ -35,18 +35,15 @@ export default class PronounsCommand extends BushCommand { slash: true }); } - override async exec(message: BushMessage | BushSlashMessage, args: { user?: User | Snowflake }): Promise { - const user = (await util.resolveNonCachedUser(args.user)) ?? message.author; - - if (!user) return message.util.reply(`${util.emojis.error} Invalid user.`); - + override async exec(message: BushMessage | BushSlashMessage, args: { user?: User }): Promise { + const user = args.user ?? message.author; const author = user.id === message.author.id; const pronouns = await util.getPronounsOf(user); if (!pronouns) { return await message.util.reply( - `${author ? 'You do' : `${user.tag} does`} not appear to have any pronouns set. Please ${ - author ? '' : 'tell them to' + `${author ? 'You do' : `${user.tag} does`} not appear to have any pronouns set. Please${ + author ? '' : ' tell them to' } go to https://pronoundb.org/ and set ${author ? 'your' : 'their'} pronouns.` ); } else { diff --git a/src/commands/info/snowflake.ts b/src/commands/info/snowflake.ts index df11bce..81b3f9d 100644 --- a/src/commands/info/snowflake.ts +++ b/src/commands/info/snowflake.ts @@ -40,7 +40,8 @@ export default class SnowflakeCommand extends BushCommand { } } ], - clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'], + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), + userPermissions: [], slash: true, slashOptions: [ { diff --git a/src/commands/info/userInfo.ts b/src/commands/info/userInfo.ts index b55bbcf..353d844 100644 --- a/src/commands/info/userInfo.ts +++ b/src/commands/info/userInfo.ts @@ -33,8 +33,8 @@ export default class UserInfoCommand extends BushCommand { required: false } ], - clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'], - userPermissions: ['SEND_MESSAGES'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), + userPermissions: [] }); } -- cgit