TypeError: Cannot read property 'execute' of undefined (Discord.js)
Currently having an issue where I'm getting the error "TypeError: Cannot read property of 'execute' of undefined". I'm currently working on learning Javascript, and copied the pastebin of code from the testing video, and it seems even his code isn't working on my compiler.
index.js
const fs = require('fs');
const Discord = require('discord.js');
const bot = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION" ]});
const { prefix, token } = require('./config.json');
bot.commands = new Discord.Collection();
//File Reading
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
bot.commands.set(command.name, command);
}
//Command Callbacks
bot.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();
if (command === 'queue') {
bot.commands.get('queue').execute(message, args, Discord, bot);
}
})
//Bot is Running
bot.once('ready', () => {
console.log('Good Noodle Bot is online!');
});
//Login
bot.login(token);
queue.js
module.exports = {
name: 'queue',
description: "Begins a Competitive Queue",
async execute(message, args, Discord, bot) {
const channel = '802325198191067146';
const silverRank = ':silver:803746337468186665';
const novaRank = ':nova:803746340009279538';
let embed = new Discord.MessageEmbed()
.setColor('#e42643')
.setTitle('Choose a rank to play with!')
.setDescription('Choosing a rank will begin a queue for that rank!\n\n'
+ `${silverRank} for Silver\n`,
+ `${novaRank} for Nova`);
let messageEmbed = await message.channel.send(embed);
messageEmbed.react(silverRank);
messageEmbed.react(novaRank);
}
}
Error:
TypeError: Cannot read property 'execute' of undefined
at Client.<anonymous> (E:\Visual Studio\Discord\index.js:25:34)
at Client.emit (node:events:379:20)
at MessageCreateAction.handle (E:\Visual Studio\Discord\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (E:\Visual Studio\Discord\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (E:\Visual Studio\Discord\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (E:\Visual Studio\Discord\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (E:\Visual Studio\Discord\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (E:\Visual Studio\Discord\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (node:events:379:20)
at Receiver.receiverOnMessage (E:\Visual Studio\Discord\node_modules\ws\lib\websocket.js:825:20)
from Recent Questions - Stack Overflow https://ift.tt/3qUxm49
https://ift.tt/eA8V8J
Comments
Post a Comment