From 339a94f757d424a6d5c239d69755fa63d52756a3 Mon Sep 17 00:00:00 2001 From: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Date: Sun, 26 Sep 2021 16:28:10 +0100 Subject: [PATCH] feat(logs): add reset button --- commands/bot/logs.js | 20 +++++++++++++++++++- interactions/commands/logs.js | 20 +++++++++++++++++++- interactions/components/logs.js | 24 ++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 interactions/components/logs.js diff --git a/commands/bot/logs.js b/commands/bot/logs.js index 462d42b..a40c4ca 100644 --- a/commands/bot/logs.js +++ b/commands/bot/logs.js @@ -15,7 +15,16 @@ module.exports = { title: 'Loqs', description: logs ? `The current loqs channel is ${logs}` : 'You don\'t have a loqs channel set up!', color: client.config.color - }] + }], + components: logs ? [{ + type: 'ACTION_ROW', + components: [{ + type: 'BUTTON', + style: 'SECONDARY', + label: 'Reset', + customId: `loqs::${message.author.id}` + }] + }] : null }); } @@ -28,6 +37,15 @@ module.exports = { title: 'Loqs', description: `The loqs channel is now ${channel}`, color: client.config.color + }], + components: [{ + type: 'ACTION_ROW', + components: [{ + type: 'BUTTON', + style: 'SECONDARY', + label: 'Reset', + customId: `loqs::${message.author.id}` + }] }] }); } diff --git a/interactions/commands/logs.js b/interactions/commands/logs.js index fe76f0e..c389aa6 100644 --- a/interactions/commands/logs.js +++ b/interactions/commands/logs.js @@ -14,7 +14,16 @@ module.exports = { title: 'Loqs', description: logs ? `The current loqs channel is ${logs}` : 'You don\'t have a loqs channel set up!', color: client.config.color - }] + }], + components: logs ? [{ + type: 'ACTION_ROW', + components: [{ + type: 'BUTTON', + style: 'SECONDARY', + label: 'Reset', + customId: `loqs::${interaction.user.id}` + }] + }] : null }); } @@ -24,6 +33,15 @@ module.exports = { title: 'Loqs', description: `The loqs channel is now ${channel}`, color: client.config.color + }], + components: [{ + type: 'ACTION_ROW', + components: [{ + type: 'BUTTON', + style: 'SECONDARY', + label: 'Reset', + customId: `loqs::${interaction.user.id}` + }] }] }); } diff --git a/interactions/components/logs.js b/interactions/components/logs.js new file mode 100644 index 0000000..c2d5ff2 --- /dev/null +++ b/interactions/components/logs.js @@ -0,0 +1,24 @@ +module.exports = { + name: 'loqs', + permissions: ['MANAGE_CHANNELS'], + async execute(client, interaction) { + client.db.prepare('UPDATE guilds SET logs = @logs WHERE id = @id').run({ id: interaction.guildId, logs: null }); + interaction.update({ + embeds: [{ + title: 'Loqs', + description: 'The loqs channel was reset', + color: client.config.color + }], + components: [{ + type: 'ACTION_ROW', + components: [{ + type: 'BUTTON', + style: 'SECONDARY', + label: 'Reset', + customId: `loqs::${interaction.user.id}`, + disabled: true + }] + }] + }); + } +};