From 5189ef45de4db1a14bb4bc7cd89eb1c46d764a47 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Fri, 14 Feb 2020 10:09:48 -0300 Subject: [PATCH] [FIX] Delete slash commands --- app/lib/methods/getSlashCommands.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/lib/methods/getSlashCommands.js b/app/lib/methods/getSlashCommands.js index 682fdb2eee3..729e8b4a92e 100644 --- a/app/lib/methods/getSlashCommands.js +++ b/app/lib/methods/getSlashCommands.js @@ -28,6 +28,8 @@ export default function() { // filter slash commands let slashCommandsToCreate = commands.filter(i1 => !allSlashCommandsRecords.find(i2 => i1.command === i2.id)); let slashCommandsToUpdate = allSlashCommandsRecords.filter(i1 => commands.find(i2 => i1.id === i2.command)); + let slashCommandsToDelete = allSlashCommandsRecords + .filter(i1 => !slashCommandsToCreate.find(i2 => i2.command === i1.id) && !slashCommandsToUpdate.find(i2 => i2.id === i1.id)); // Create slashCommandsToCreate = slashCommandsToCreate.map(command => slashCommandsCollection.prepareCreate(protectedFunction((s) => { @@ -43,9 +45,13 @@ export default function() { })); }); + // Delete + slashCommandsToDelete = slashCommandsToDelete.map(command => command.prepareDestroyPermanently()); + const allRecords = [ ...slashCommandsToCreate, - ...slashCommandsToUpdate + ...slashCommandsToUpdate, + ...slashCommandsToDelete ]; try {