From 3b811f26e44f1988572546a592ffad4927ada018 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 28 Sep 2021 18:06:01 +0200 Subject: [PATCH] Fix for redundant editions/deletions in logs. --- src/commands/delete.ts | 8 ++++---- src/commands/edit.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/commands/delete.ts b/src/commands/delete.ts index b7f7a6bc..a6c5593c 100644 --- a/src/commands/delete.ts +++ b/src/commands/delete.ts @@ -12,8 +12,6 @@ export default new Command('delete', async (caller, cmd, log) => { if (!message || message.type !== 'STAFF_REPLY') return caller.utils.discord.createMessage(cmd.channel.id, 'The message could not be found.'); - caller.db.editMessage(log!, message.id, '[DELETED] ' + message.content); - const userMsg = await caller.utils.discord.fetchMessage(log!.recipient.id, message.complementaryID!, true); if (!userMsg || !userMsg.embeds[0]) return caller.utils.discord.createMessage(cmd.channel.id, 'The message could not be found.'); @@ -21,14 +19,16 @@ export default new Command('delete', async (caller, cmd, log) => { // Delete the user message. userMsg.delete() .catch(() => { - return caller.utils.discord.createMessage(cmd.channel.id, 'The message could not be deleted.'); + return caller.utils.discord.createMessage(cmd.channel.id, 'The message could not be deleted for the user.'); }); + caller.db.editMessage(log!, message.id, '[DELETED] ' + message.content); + guildMsg.embeds[0].description = '[DELETED] ' + guildMsg.embeds[0].description; guildMsg.embeds[0].footer ? guildMsg.embeds[0].footer.text = 'Deleted' : guildMsg.embeds[0].footer = { text: 'Deleted' }; guildMsg.edit({ embed: guildMsg.embeds[0] }) .catch(() => { - return caller.utils.discord.createMessage(cmd.channel.id, 'The message could not be deleted.'); + return caller.utils.discord.createMessage(cmd.channel.id, 'The message could not be deleted in this channel.'); }); caller.utils.discord.createMessage(cmd.channel.id, 'The message has been deleted.'); }, diff --git a/src/commands/edit.ts b/src/commands/edit.ts index a917841c..6a5fa2de 100644 --- a/src/commands/edit.ts +++ b/src/commands/edit.ts @@ -14,8 +14,6 @@ export default new Command('edit', async (caller, cmd, log) => { if (!message || message.type !== 'STAFF_REPLY') return caller.utils.discord.createMessage(cmd.channel.id, 'The message could not be found.'); - caller.db.editMessage(log!, message.id, cmd.args.slice(1).join(' ')); - const userMsg = await caller.utils.discord.fetchMessage(log!.recipient.id, message.complementaryID!, true); if (!userMsg || !userMsg.embeds[0]) return caller.utils.discord.createMessage(cmd.channel.id, 'The message could not be found.'); @@ -24,14 +22,16 @@ export default new Command('edit', async (caller, cmd, log) => { userMsg.embeds[0].description = cmd.args.slice(1).join(' '); userMsg.edit({ embed: userMsg.embeds[0] }) .catch(() => { - return caller.utils.discord.createMessage(cmd.channel.id, 'The message could not be edited.'); + return caller.utils.discord.createMessage(cmd.channel.id, 'The message could not be edited for the user.'); }); + caller.db.editMessage(log!, message.id, cmd.args.slice(1).join(' ')); + guildMsg.embeds[0].description = cmd.args.slice(1).join(' '); guildMsg.embeds[0].footer ? guildMsg.embeds[0].footer.text = 'Edited' : guildMsg.embeds[0].footer = { text: 'Edited' }; guildMsg.edit({ embed: guildMsg.embeds[0] }) .catch(() => { - return caller.utils.discord.createMessage(cmd.channel.id, 'The message could not be edited.'); + return caller.utils.discord.createMessage(cmd.channel.id, 'The message could not be edited in this channel.'); }); caller.utils.discord.createMessage(cmd.channel.id, 'The message has been edited.'); },