From 28edd1660156c135159bbaf32f1b4d3dc1daee9a Mon Sep 17 00:00:00 2001 From: NishantMajumdar Date: Thu, 9 Dec 2021 21:25:11 +0530 Subject: [PATCH 1/4] Update piracy.js --- commands/piracy.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/commands/piracy.js b/commands/piracy.js index 3980608..e2de57a 100644 --- a/commands/piracy.js +++ b/commands/piracy.js @@ -1,6 +1,9 @@ -const { MessageEmbed } = require('discord.js'); +const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js'); const { SlashCommandBuilder } = require('@discordjs/builders'); - + const row = new MessageActionRow().addComponents(new MessageButton() + .setCustomId('hide') + .setStyle('SECONDARY') + .setEmoji('❌')) const text = `Piracy is not allowed in this server. Please read <#521711544925552642>! We will only support the dumping of games you own. If you don't want to do that, find out what to do yourself.`; @@ -14,6 +17,6 @@ module.exports = { .setName('piracy') .setDescription('Explains our piracy policy'), async execute(interaction) { - return interaction.reply({ embeds: [embed] }); + return interaction.reply({ embeds: [embed] ,components:[row]}); }, }; From 01e41219e0008ed17a65562feb06e69f845abafe Mon Sep 17 00:00:00 2001 From: NishantMajumdar Date: Thu, 9 Dec 2021 21:26:18 +0530 Subject: [PATCH 2/4] Update interactionCreate.js --- events/interactionCreate.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/events/interactionCreate.js b/events/interactionCreate.js index bfe35a2..20ed301 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -6,7 +6,17 @@ module.exports = { * @returns */ async execute(interaction) { - if (!interaction.isCommand()) return; + +if(interaction.isButton()) + { + if(interaction.customId === 'hide') + { + await interaction.deferUpdate(); + interaction.deleteReply(); + + } + } + const command = interaction.client.commands.get(interaction.commandName); From 8131bd871044e87993f5942425318a948104bb85 Mon Sep 17 00:00:00 2001 From: NishantMajumdar Date: Thu, 9 Dec 2021 21:27:07 +0530 Subject: [PATCH 3/4] Update interactionCreate.js --- events/interactionCreate.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/events/interactionCreate.js b/events/interactionCreate.js index 20ed301..52abe32 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -7,15 +7,15 @@ module.exports = { */ async execute(interaction) { -if(interaction.isButton()) - { - if(interaction.customId === 'hide') - { - await interaction.deferUpdate(); - interaction.deleteReply(); + if(interaction.isButton()) + { + if(interaction.customId === 'hide') + { + await interaction.deferUpdate(); + interaction.deleteReply(); - } - } + } + } const command = interaction.client.commands.get(interaction.commandName); From 01500506f634e664c7f92016f632d60efdcc86ac Mon Sep 17 00:00:00 2001 From: NishantMajumdar Date: Thu, 30 Jun 2022 14:21:33 +0000 Subject: [PATCH 4/4] Update interactionCreate.js --- events/interactionCreate.js | 75 ++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/events/interactionCreate.js b/events/interactionCreate.js index 52abe32..8e81b46 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -1,36 +1,49 @@ module.exports = { - name: 'interactionCreate', - /** - * - * @param {import('discord.js').CommandInteraction} interaction - * @returns - */ - async execute(interaction) { - - if(interaction.isButton()) - { - if(interaction.customId === 'hide') - { - await interaction.deferUpdate(); - interaction.deleteReply(); - - } - } + name: "interactionCreate", + /** + * + * @param {import('discord.js').CommandInteraction} interaction + * @returns + */ + async execute(interaction) { + if (interaction.isButton()) { + if (interaction.customId === "hide") { + if ( + interaction.member.roles.cache.some((r) => r.name === "Admin") || + interaction.member.roles.cache.some((r) => r.name === "Moderator") || + interaction.member.roles.cache.some((r) => r.name === "Support Staff") + ) { + await interaction.deferUpdate(); + interaction.deleteReply(); + } else { + interaction.reply({ + content: `Nice try! Only staff can delete this message`, + ephemeral: true, + }); + } + } + } + if (!interaction.isCommand()) return; + const command = interaction.client.commands.get(interaction.commandName); - const command = interaction.client.commands.get(interaction.commandName); + if (!command) return; - if (!command) return; - - try { - await command.execute(interaction); - } catch (error) { - console.error(error); - if (interaction.deferred || interaction.replied) { - return interaction.editReply({ content: 'There was an error while executing this command!', ephemeral: true }); - } else { - return interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }); - } - } - }, + try { + await command.execute(interaction); + } catch (error) { + console.error(error); + if (interaction.deferred || interaction.replied) { + return interaction.editReply({ + content: "There was an error while executing this command!", + ephemeral: true, + }); + } else { + return interaction.reply({ + content: "There was an error while executing this command!", + ephemeral: true, + }); + } + } + }, };