Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7190

Discord bot will not respond, shuts down

$
0
0

I am new to programming a Discord bot (and I love it), and it has problems responding. When I start it with node main.js, it works as normal until I do something like -ping, upon which it stops working.

Here is the error that I receive:

ReferenceError: clicent is not defined    at Client.<anonymous> (C:\Users\Eric Müller\Desktop\Discord bot\Main.js:27:9)           at Client.emit (events.js:315:20)    at MessageCreateAction.handle (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)            at WebSocketManager.handlePacket (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)    at WebSocketShard.onPacket (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)    at WebSocketShard.onMessage (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)    at WebSocket.onMessage (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\ws\lib\event-target.js:132:16)    at WebSocket.emit (events.js:315:20)    at Receiver.receiverOnMessage (C:\Users\Eric Müller\Desktop\Discord bot\node_modules\ws\lib\websocket.js:825:20)

Here is my code:

const Discord = require('discord.js');const client = new Discord.Client();const prefix = '-';const fs = require('fs');client.commands = new Discord.Collection();const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));for(const file of commandFiles){const command = require(`./commands/${file}`);    client.commands.set(command.name, command);}client.once('ready', () => {    console.log('Codelyon is online!');});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();if(command === 'ping'){        client.commands.get('ping').execute(message, args);}});client.login(''); (DISCLAMER! THE TOKEN IS FILLED IN AND CORRECT)

ping.js:

module.exports = {name: 'ping',description: "this is a ping command!",execute(message, args){message.channel.send('pong!');    }}

Viewing all articles
Browse latest Browse all 7190

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>