From c8a5bfe694ee6e784a0c5cbe1a7076b1c055249a Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 5 Sep 2021 20:56:23 -0400 Subject: remove inline from log fields and fix purge --- src/commands/moderation/purge.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/commands/moderation') diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts index 4ed1ee7..ace72f2 100644 --- a/src/commands/moderation/purge.ts +++ b/src/commands/moderation/purge.ts @@ -1,4 +1,5 @@ -import { Message } from 'discord.js'; +import Collection from '@discordjs/collection'; +import { Snowflake } from 'discord.js'; import { BushCommand, BushMessage } from '../../lib'; export default class PurgeCommand extends BushCommand { @@ -52,22 +53,25 @@ export default class PurgeCommand extends BushCommand { if (args.bot) { shouldFilter.push(filterMessage.author.bot); } - return shouldFilter.filter((bool) => bool === false).length === 0; + return shouldFilter.filter((bool) => bool === false).length === 0 && filterMessage.id !== message.id; }; - const messages = (await message.channel.messages.fetch({ limit: args.amount })).filter((message) => messageFilter(message)); + const _messages = (await message.channel.messages.fetch({ limit: 100, before: message.id })) + .filter((message) => messageFilter(message)) + .first(args.amount); + const messages = new Collection(); + _messages.forEach((m) => messages.set(m.id, m)); 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); else { client.emit('bushPurge', message.author, message.guild!, message.channel, messages); - await message.util - .send(`${util.emojis.success} Successfully purged **${purged.size}** messages.`) - .then(async (purgeMessage) => { + await message.util.send(`${util.emojis.success} Successfully purged **${purged.size}** messages.`); + /* .then(async (purgeMessage) => { if (!message.util.isSlash) { await util.sleep(5); await (purgeMessage as Message).delete().catch(() => {}); } - }); + }); */ } } } -- cgit