From a44310b00f7a9a4558bb294a15fc0723f5c84e9a Mon Sep 17 00:00:00 2001 From: Ayden Jahola Date: Mon, 2 Sep 2024 23:05:25 +0100 Subject: [PATCH] ensure the /verify and /code only work in the specified channel, and add admin log channel to the .env.example --- .env.example | 3 ++- README.md | 1 + commands/code.js | 9 +++++++++ commands/verify.js | 9 +++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index dc0f817..98d0504 100644 --- a/.env.example +++ b/.env.example @@ -7,12 +7,13 @@ EMAIL_USER=example@example.com EMAIL_PASS=YOUR_EMAIL_PASS # Allowed domains for email verification -EMAIL_DOMAINS=example@example.com // or it can be a list, example: "example.com,example2.com" +EMAIL_DOMAINS=example@example.com // or it can be a list, example: example.com,example2.com # Discord GUILD_ID=YOUR_GUILD_ID VERIFICATION_CHANNEL_NAME=YOUR_VERIFICATION_CHANNEL_NAME VERIFIED_ROLE_NAME=YOUR_VERIFIED_ROLE_NAME +ADMIN_LOG_CHANNEL_ID=YOUR_ADMIN_LOG_CHANNEL_ID # Database MONGODB_URI=YOUR_MONGODB_URI \ No newline at end of file diff --git a/README.md b/README.md index 8375619..fc09bee 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ EMAIL_DOMAINS=example@example.com // or it can be a list, example: "example.com, GUILD_ID=YOUR_GUILD_ID VERIFICATION_CHANNEL_NAME=YOUR_VERIFICATION_CHANNEL_NAME VERIFIED_ROLE_NAME=YOUR_VERIFIED_ROLE_NAME +ADMIN_LOG_CHANNEL_ID=YOUR_ADMIN_LOG_CHANNEL_ID # Database MONGODB_URI=YOUR_MONGODB_URI diff --git a/commands/code.js b/commands/code.js index 7a1811a..aa83695 100644 --- a/commands/code.js +++ b/commands/code.js @@ -13,6 +13,15 @@ module.exports = { ), async execute(interaction, client) { + // Ensure command is only used in the specified verification channel + const verificationChannelName = process.env.VERIFICATION_CHANNEL_NAME; + if (interaction.channel.name !== verificationChannelName) { + return interaction.reply({ + content: `This command can only be used in the #${verificationChannelName} channel.`, + ephemeral: true, + }); + } + const code = interaction.options.getString("code"); if (!code) { diff --git a/commands/verify.js b/commands/verify.js index d855092..0e8ee8c 100644 --- a/commands/verify.js +++ b/commands/verify.js @@ -22,6 +22,15 @@ module.exports = { ), async execute(interaction, client) { + // Ensure command is only used in the specified verification channel + const verificationChannelName = process.env.VERIFICATION_CHANNEL_NAME; + if (interaction.channel.name !== verificationChannelName) { + return interaction.reply({ + content: `This command can only be used in the #${verificationChannelName} channel.`, + ephemeral: true, + }); + } + const email = interaction.options.getString("email"); const emailDomain = email.split("@")[1]; const EMAIL_DOMAINS = process.env.EMAIL_DOMAINS.split(",");