As I embark on creating my debut Discord bot to enhance my coding skills, I have encountered numerous hurdles along the way. While most of these challenges were overcome by me independently, this particular issue has left me stumped.
The objective of the code is to trigger a command that prompts the bot to set up verification in a designated channel. However, upon issuing the command, the bot remains unresponsive with no errors displayed in the command prompt.
In an attempt to pinpoint the problem area, I inserted the line "console.log('Verification process has started')", but surprisingly, this did not appear in the logs either.
Here is the Verification code snippet:
const { DiscordAPIError } = require("discord.js");
const { execute } = require("./ping");
const Discord = require("discord.js")
module.exports = {
name: 'verify',
description: 'Let them verify',
aliases: ['Verify', 'Verification'],
async execute(client, message, args){
console.log('Verification process has started.')
if(!message.member.roles.cache.has('955164630936850483')) return;
const channel = '954717049890955334'
const memberRole = '955164944482058240'
const verifyEmoji = '✅'
let embed = new MessageEmbed()
.setColor("GREEN")
.setTitle('React To Verify!')
.setDescription('React with "✅" to get verified in the server.')
let messageEmbed = await message.channel.send({ embeds: [embed]})
messageEmbed.react(verifyEmoji)
client.on('messageReactionAdd', async (reaction. user))
if (reaction.message.partial) await reaction.message.fetch();
if (reaction.partial) await reaction.fetch();
if (user.bot) return;
if (!reaction.message.guild) return;
if(reaction.message.channel.id == channel) {
if(reaction.emoji.name === verifyEmoji) {
await reaction.message.guild.members.cache.get(user.id).roles.add(memberRole);
await reaction.message.guild.members.cache.get(user.id).roles.remove('<@955185557544263721>');
}
} else {
return;
}
}
}
Below is the Main code snippet:
> const Discord = require("discord.js") require('dotenv').config();
>
> const generateImage = require("./generateImage") const { MessageEmbed
> } = require("discord.js")
>
>
> const client = new Discord.Client({
> intents: [
> "GUILDS",
> "GUILD_MESSAGES",
> "GUILD_MEMBERS",
> "GUILD_MESSAGES",
> "GUILD_MESSAGE_REACTIONS"
> ],
> partials: [
> "messageCreate",
> "CHANNEL",
> "REACTION"
> ] });
>
> // Prefix const prefix = '-';
>
> const fs = require('fs');
>
> client.commands = []
>
> // Command file filter for (const file of
> fs.readdirSync('./commands')) {
> const command = require(`./commands/${file}`);
>
> client.commands.push(command); }
>
> // Message when bot starts up client.once('ready', () => {
> console.log('<Omnia> is online!');
> client.channels.cache.get(`955163442472419460`).send(`I am now back online, if you see me offline contact staff in
> <#955167864422301736>.`) });
>
> // Automatically gives "Unverified" when someone joins the server
>
>
> client.on("message", async message => {
> if (message.author.bot) return false;
> const Role1 = message.guild.roles.cache.get("RoleID");
>
>
> })
>
> // Prefix filter client.on('message', message =>{
> if (!message.content.startsWith(prefix) || message.author.bot) return;
> const args = message.content.slice(prefix.length).split(/ +/);
> const command = args.shift().toLowerCase();
>
> // Go through all the commands the bot has
> for (const cmd of client.commands) {
> // Check if the command name matches any of the aliases
> if (cmd.aliases.includes(command)) {
> // TODO: Check if the command has the required permissions
>
> // If the command is found, run it
> cmd.execute(client, message, args)
> }
> } });
>
> const welcomeChannelId = "954724625076600872"
>
> client.on("guildMemberAdd", async (member) => {
> const img = await generateImage(member);
> member.guild.channels.cache.get(welcomeChannelId).send({
> content: `<@${member.id}> *Make sure to invite your friends!*`,
> files: [img]
> }) }) client.login(process.env.DISCORD_TOKEN);