简体   繁体   English

为什么我的终端不允许我运行 node index.js

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

I tried to run node index.js in terminal but this error came up: TypeError: Cannot read properties of undefined (reading 'Guilds').我试图在终端中运行 node index.js,但出现了这个错误:TypeError: Cannot read properties of undefined (reading 'Guilds')。 The following is my code:以下是我的代码:

 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');

Maybe there is an issue with the Intent.可能 Intent 有问题。 Since you have not provided the error output, I suggest you to use由于您没有提供错误 output,我建议您使用

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

Replace this code with your first two lines of code which is:将此代码替换为您的前两行代码:

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

And please don't share bot Token ever.并且请永远不要共享机器人令牌。 Its like login Credentials for your bot.它就像您的机器人的登录凭据。 Please reset it on your discord developer console.请在您的 discord 开发者控制台上重置它。

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

相关问题 如何让 $node index.js 在我的命令行中运行 index.js? - How can I get $node index.js to run index.js in my command line? MySQL 数据库连接的 Node.JS 错误:使用命令“NODE INDEX.JS”运行服务器时,终端给我两个错误 - Node.JS Error with MySQL Database Connection: Terminal is giving me two errors when running my server using the command "NODE INDEX.JS" 每当我运行“node index.js”时,我的不和谐机器人就无法连接 - My discord bot does not connect whenever I run 'node index.js' 为什么我在运行 node index.js 时出现这个错误以及如何修复它 - Why i have this error when run node index.js and how to fix it 我如何在Ubuntu中运行“ node index.js” - How can i run “node index.js” in ubuntu 为什么 Node.js 无法在终端中运行我的 JavaScript 代码? - Why Node.js cannot run my JavaScript code in the terminal? 节点我的应用程序如何找到index.js - node how can My app find index.js 为什么我的JS代码的其余部分不让我的JQuery运行? - Why is the rest of my JS code not letting my JQuery run? 为什么无法识别我的Index.js文件? - Why won't my Index.js file be recognized? 我是 discord 机器人场景的新手,每次我输入终端“node index.js”时它都不起作用 - Im new at the discord bot scene and everytime i type in the terminal “node index.js” it doesnt work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM