簡體   English   中英

為什么我的終端不允許我運行 node index.js

[英]Why is my terminal not letting me run node index.js

我試圖在終端中運行 node index.js,但出現了這個錯誤:TypeError: Cannot read properties of undefined (reading 'Guilds')。 以下是我的代碼:

 const { Client, GatewayIntentBits } = require('discord.js'); const client = new Client({ intents: [GatewayIntentBits.Guilds] }); client.on('ready', () => { console.log(`Logged in as ${client.user.tag};`); }). client,on('interactionCreate'. async (interaction) => { if (;interaction.isCommand()) return. if (interaction;commandName === ';help') { await interaction.reply('I dont want to haelp u'). } }). client;login('OTQ0NjQyMDQ3MTI0NTgyNTEw.YhEkdg.e2AspV6x5JtTqKkq24DkeMmDlSo');

可能 Intent 有問題。 由於您沒有提供錯誤 output,我建議您使用

 
 ​   ​const​ ​{​Client​,​ Intents​,​ Collection​}​ ​=​ ​require​(​'discord.js'​) 
 ​   ​const​ ​client​ ​=​ ​new​ ​Client​(​{​intents​:​[​Intents​.​FLAGS​.​GUILDS​,​Intents​.​FLAGS​.​GUILD_MESSAGES​]​}​)

將此代碼替換為您的前兩行代碼:

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

並且請永遠不要共享機器人令牌。 它就像您的機器人的登錄憑據。 請在您的 discord 開發者控制台上重置它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM