From 780aef27c5462f531386fb90ec956d0b45fda658 Mon Sep 17 00:00:00 2001 From: Supositware Date: Fri, 14 Apr 2023 17:46:12 +0200 Subject: [PATCH] guildOnly check --- events/client/interactionCreate.js | 5 +++++ events/client/messageCreate.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/events/client/interactionCreate.js b/events/client/interactionCreate.js index cc7ee93..e420b62 100644 --- a/events/client/interactionCreate.js +++ b/events/client/interactionCreate.js @@ -42,6 +42,11 @@ export default { return interaction.reply({ content: '❌ This command is reserved for the owner!', ephemeral: true }); } + // Guild only check + if (command.guildOnly && !interaction.guild) { + return interaction.reply({ content: '❌ This command only work in a server!', ephemeral: true }); + } + // Check if the bot has the needed permissions if (command.default_permission) { const clientMember = await interaction.guild.members.fetch(client.user.id); diff --git a/events/client/messageCreate.js b/events/client/messageCreate.js index e7924dc..75cfd18 100644 --- a/events/client/messageCreate.js +++ b/events/client/messageCreate.js @@ -307,6 +307,11 @@ export default { return message.reply({ content: '❌ This command is reserved for the owner!', ephemeral: true }); } + // Guild only check + if (command.guildOnly && !message.guild) { + return message.reply({ content: '❌ This command only work in a server!', ephemeral: true }); + } + // Check if the bot has the needed permissions if (command.clientPermissions) { const clientMember = await message.guild.members.fetch(client.user.id);