Discord Bot 不输出任何内容 client.on('ready')

0 javascript node.js discord discord.js

基本上,当我node .在命令提示符下运行时,不会输出任何内容。

我的代码:

const Discord = require("discord.js");

const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });

client.on("ready", () => {
    console.log(`Logged in as ${client.user.tag}`);
});
//My key is located here but I've taken it out for obvious reasons
client.login = "key";
Run Code Online (Sandbox Code Playgroud)

Can*_*ide 5

client.login = ('key');
Run Code Online (Sandbox Code Playgroud)

如果这就是您的代码的外观,并且不仅仅是问题中的拼写错误,那么这是无效的语法。client.login()是一种方法。它应该是这样的:

client.login('key');
Run Code Online (Sandbox Code Playgroud)

这很可能是你的问题。