aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/arguments/discordEmoji.ts16
-rw-r--r--src/commands/utilities/steal.ts12
-rw-r--r--src/lib/utils/BushConstants.ts6
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<unknown> {
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: /<a?:[a-zA-Z0-9_]+:\d{15,21}>/gim
+ // eslint-disable-next-line no-useless-escape
+ discordEmoji: /<a?:(?<name>[a-zA-Z0-9\_]+):(?<id>\d{15,21})>/gim
};
/** A bunch of mappings */