[英]Discord.js not logging in
我無法弄清楚為什么我的機器人不工作。 有人可以告訴我為什么它沒有登錄嗎? 它顯示了徽標(console.log 的最后一行),但沒有說“以 foo#1234 身份登錄”。 (我也沒有收到任何錯誤。)
code removed because of answered question. the code worked fine ;)
使用client.once('ready', async () => {//code here});
作為client.on()
的一個姿勢
如discord.js Guide中所述,這是幫助您入門的基本代碼:
// Require the necessary discord.js classes
const { Client, Intents } = require('discord.js');
const { token } = require('./config.json');
// Create a new client instance
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
// When the client is ready, run this code (only once)
client.once('ready', () => {
console.log('Ready!');
});
// Login to Discord with your client's token
client.login(token);
打開您的終端並運行node index.js
(假設您的文件名為 index.js)以啟動該過程。 如果您看到“准備就緒!” 幾秒鍾后,你就可以走了!
我建議您遵循本指南,它對我使用不和諧機器人的第一步幫助很大。
令牌由於某種原因已重置,我不記得重置它,但更新令牌后,它工作正常。 感謝您的回答和有用的評論。
如果其他人遇到此問題,請嘗試再次重置令牌。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.