![](/img/trans.png)
[英]i am trying to make a discord bot using discord.js and im making an even handler but im getting this error
[英]im making a discord bot but it says i have an incorrect token
所以当我尝试运行它时,它会显示 (node:30096) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token is provided。
这是代码
const bot = new Discord.Client();
const token = 'the token but i won't show';
bot.on('ready', () =>{
console.log('This bot is online!');
})
bot.login('token');```
bot.login('token');
不做你认为它做的事。 由于您已将单词token
封装在引号 ( ''
) 中,因此您已将文字字符串token
作为参数传递给login()
方法。
删除引号,以便传递变量token
的内容,而不是:
bot.login(token);
更坦率地说,你真的应该考虑复习你的基本 JavaScript 语法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.