adjust the email domain to take multiple arguments/domains and add .env.example

This commit is contained in:
Ayden Jahola 2024-08-31 10:03:09 +01:00
parent 21de9bccd3
commit 5e219a154c
No known key found for this signature in database
GPG key ID: 71DD90AE4AE92742
3 changed files with 44 additions and 13 deletions

18
.env.example Normal file
View file

@ -0,0 +1,18 @@
# Bot token
BOT_TOKEN=YOUR_BOT_TOKEN
# Nodemailer
EMAIL_NAME="Example"
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"
# Discord
GUILD_ID=YOUR_GUILD_ID
VERIFICATION_CHANNEL_NAME=YOUR_VERIFICATION_CHANNEL_NAME
VERIFIED_ROLE_NAME=YOUR_VERIFIED_ROLE_NAME
# Database
MONGODB_URI=YOUR_MONGODB_URI

View file

@ -1,6 +1,6 @@
# Esports Verification Bot
# Discord Verification Bot
Welcome to the **Esports Verification Bot**! This bot is designed to handle user verification for Discord servers, specifically for esports communities. It verifies users through their student email addresses and manages roles based on their verification status.
Welcome to the **Discord Verification Bot**! This bot is designed to handle user verification for Discord servers. It verifies users through their student email addresses and manages roles based on their verification status.
## Features
@ -39,15 +39,28 @@ npm install
Create a `.env` file in the root directory and add the following:
```env
BOT_TOKEN=your_discord_bot_token
MONGODB_URI=your_mongodb_connection_string
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_email_password
VERIFIED_ROLE_NAME=YourVerifiedRoleName
EMAIL_DOMAIN=mail.dcu.ie
GUILD_ID=your_discord_guild_id
# Bot token
BOT_TOKEN=YOUR_BOT_TOKEN
# Nodemailer
EMAIL_NAME="Example"
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"
# Discord
GUILD_ID=YOUR_GUILD_ID
VERIFICATION_CHANNEL_NAME=YOUR_VERIFICATION_CHANNEL_NAME
VERIFIED_ROLE_NAME=YOUR_VERIFIED_ROLE_NAME
# Database
MONGODB_URI=YOUR_MONGODB_URI
```
this can also be seen in in the [.env.example](./.env.example)
4. **Run the Bot**
```sh

8
bot.js
View file

@ -13,7 +13,7 @@ const client = new Client({
});
const VERIFIED_ROLE_NAME = process.env.VERIFIED_ROLE_NAME; // Role name to assign after verification
const EMAIL_DOMAIN = process.env.EMAIL_DOMAIN; // Domain to verify against
const EMAIL_DOMAINS = process.env.EMAIL_DOMAINS.split(","); // Domains to verify against, converted to an array
const GUILD_ID = process.env.GUILD_ID; // Guild ID to restrict the bot
const VERIFICATION_CHANNEL_NAME = process.env.VERIFICATION_CHANNEL_NAME; // Channel name to restrict the bot
@ -56,14 +56,14 @@ client.on("messageCreate", async (message) => {
if (!email) {
return verificationChannel.send(
"Please provide your email address. Usage: `!verify your_email@mail.dcu.ie`"
"Please provide your email address. Usage: `!verify your_email@example.com`"
);
}
const emailDomain = email.split("@")[1];
if (emailDomain !== EMAIL_DOMAIN) {
if (!EMAIL_DOMAINS.includes(emailDomain)) {
return verificationChannel.send(
"You must use a valid DCU student email address."
"You must use a valid DCU email address."
);
}