diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-06-11 15:25:56 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-06-11 15:25:56 -0400 |
commit | ddb48e8e98c4fd9b6d86d8024db559369bc5f201 (patch) | |
tree | d41b9517b30c2acdc219aece4436c82fdf8dc9f4 | |
parent | 5f4f28903b2f3428e54ed74417fc06e8eeb58ebf (diff) | |
download | tanzanite-ddb48e8e98c4fd9b6d86d8024db559369bc5f201.tar.gz tanzanite-ddb48e8e98c4fd9b6d86d8024db559369bc5f201.tar.bz2 tanzanite-ddb48e8e98c4fd9b6d86d8024db559369bc5f201.zip |
fix: purge fetch
-rw-r--r-- | src/commands/moderation/purge.ts | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts index 2cc9d04..799cf36 100644 --- a/src/commands/moderation/purge.ts +++ b/src/commands/moderation/purge.ts @@ -1,6 +1,6 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; import assert from 'assert'; -import { ApplicationCommandOptionType, Collection, PermissionFlagsBits, type Snowflake } from 'discord.js'; +import { ApplicationCommandOptionType, Collection, PermissionFlagsBits } from 'discord.js'; export default class PurgeCommand extends BushCommand { public constructor() { @@ -64,10 +64,12 @@ export default class PurgeCommand extends BushCommand { return shouldFilter.filter((bool) => bool === false).length === 0 && filterMessage.id !== message.id; }; - const _messages = (await message.channel.messages.fetch({ limit: 100, before: message.id })) - .filter((message) => messageFilter(message)) - .first(args.amount); - const messages = new Collection<Snowflake, BushMessage>(_messages.map((m) => [m.id, m])); + const messages = new Collection( + (await message.channel.messages.fetch({ limit: 100, before: message.id })) + .filter((message) => messageFilter(message)) + .first(args.amount) + .map((m) => [m.id, m] as const) + ); const purged = await message.channel.bulkDelete(messages, true).catch(() => null); if (!purged) return message.util.reply(`${util.emojis.error} Failed to purge messages.`).catch(() => null); |