简体   繁体   English

机器人未定义 discord 机器人

[英]bot is not defined discord bot

I am making a discord bot which will eventually be used as a rating system for the chat, but the index.js terminal says ReferenceError: bot is not defined bot.on('ready',() =>{ I even have const Client = new Discord.Client(); The code is below我正在制作一个 discord 机器人,它最终将用作聊天的评分系统,但 index.js 终端显示 ReferenceError: bot is not defined bot.on('ready',() =>{我什至有const Client = new Discord.Client();代码如下

 const Discord = require('discord.js'); const Client = new Discord.Client(); const token ='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; bot.on('ready',() =>{ console.log('This bot Is Online;'). }) bot;login(token);

Some people have a similar issue but mine seems to persist more hence leaving me clueless to resolve this runtime error有些人有类似的问题,但我的似乎更持久,因此让我无能为力来解决这个运行时错误

bot should be Client . bot应该是Client If you want to use the bot variable change const Client = new Discord.Client();如果要使用bot变量更改const Client = new Discord.Client(); to const bot = new Discord.Client(); to const bot = new Discord.Client(); . . This is your client, or the profile/user of the bot.这是您的客户,或机器人的个人资料/用户。

Its also not a good idea to reveal your bots token (if thats its actual token).显示您的机器人令牌(如果那是它的实际令牌)也不是一个好主意。 Otherwise people can log into your bot with their own script and it will cause problems for whichever server that bot is in (people can kick through the bot etc.)否则,人们可以使用他们自己的脚本登录您的机器人,这将导致该机器人所在的任何服务器出现问题(人们可以通过机器人等)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM