From eb381b80e60f01a635af3ffe80bf950bb4a73c30 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Fri, 20 Aug 2021 12:41:28 -0400 Subject: fixed steal --- src/arguments/discordEmoji.ts | 16 ++++------------ src/commands/utilities/steal.ts | 12 ++++++------ src/lib/utils/BushConstants.ts | 6 ++---- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/arguments/discordEmoji.ts b/src/arguments/discordEmoji.ts index 9884c98..47e734d 100644 --- a/src/arguments/discordEmoji.ts +++ b/src/arguments/discordEmoji.ts @@ -1,17 +1,9 @@ import { Snowflake } from 'discord-api-types'; import { BushArgumentTypeCaster } from '../lib'; -export const discordEmojiTypeCaster: BushArgumentTypeCaster = ( - _, - phrase -): { name: string; id: Snowflake; animated: boolean } | null => { - console.log(phrase); +export const discordEmojiTypeCaster: BushArgumentTypeCaster = (_, phrase): { name: string; id: Snowflake } | null => { if (!phrase) return null; - const validEmoji = client.consts.regex.discordEmoji.test(phrase); - console.log(validEmoji); - if (!validEmoji) return null; - const emoji = phrase.replace(/[<>]/g, '').split(':'); - const animated = emoji[0] === 'a'; - console.log(emoji); - return { name: emoji[1], id: emoji[2], animated }; + const validEmoji: RegExpExecArray | null = client.consts.regex.discordEmoji.exec(phrase); + if (!validEmoji || !validEmoji.groups) return null; + return { name: validEmoji.groups.name, id: validEmoji.groups.id }; }; diff --git a/src/commands/utilities/steal.ts b/src/commands/utilities/steal.ts index 734aab5..097c902 100644 --- a/src/commands/utilities/steal.ts +++ b/src/commands/utilities/steal.ts @@ -33,11 +33,10 @@ export default class StealCommand extends BushCommand { } public override async exec( message: BushMessage, - args?: { emojiOrName?: { name: string; id: Snowflake; animated: boolean } | Snowflake | URL | string; name: string } + args?: { emojiOrName?: { name: string; id: Snowflake } | Snowflake | URL | string; name: string } ): Promise { if ((!args || !args.emojiOrName) && !message.attachments.size) return await message.util.reply(`${util.emojis.error} You must provide an emoji to steal.`); - console.log(args); const image = message.attachments.size && message.attachments.first()?.contentType?.includes('image/') @@ -62,10 +61,11 @@ export default class StealCommand extends BushCommand { ? args?.name ?? args.emojiOrName.name ?? 'stolen_emoji' : 'stolen_emoji'; - const creationSuccess = await message.guild!.emojis.create(image, emojiName, { - reason: `Stolen by ${message.author.tag} (${message.author.id})` - }); - // .catch((e: Error) => e); + const creationSuccess = await message + .guild!.emojis.create(image, emojiName, { + reason: `Stolen by ${message.author.tag} (${message.author.id})` + }) + .catch((e: Error) => e); if (!(creationSuccess instanceof Error)) return await message.util.reply(`${util.emojis.success} You successfully stole ${creationSuccess}.`); diff --git a/src/lib/utils/BushConstants.ts b/src/lib/utils/BushConstants.ts index 1d7f81e..de3076a 100644 --- a/src/lib/utils/BushConstants.ts +++ b/src/lib/utils/BushConstants.ts @@ -22,9 +22,6 @@ interface bushColors { orange: '#E86100'; } -('<:verifiedbot1:700325427998097449>'); -(''); - export class BushConstants { public static emojis = { success: '<:checkmark:837109864101707807>', @@ -105,7 +102,8 @@ export class BushConstants { public static regex = { snowflake: /\d{15,21}/gim, - discordEmoji: //gim + // eslint-disable-next-line no-useless-escape + discordEmoji: /[a-zA-Z0-9\_]+):(?\d{15,21})>/gim }; /** A bunch of mappings */ -- cgit