久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

即使沒有任何錯誤,我的 discord.js 機器人也不會

my discord.js bot doesn#39;t reply to a user message even if there isn#39;t any error(即使沒有任何錯誤,我的 discord.js 機器人也不會回復用戶消息)
本文介紹了即使沒有任何錯誤,我的 discord.js 機器人也不會回復用戶消息的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我的 discord.js 機器人版本是 13.1.0,我的節點版本是 16.7.0.我在終端中輸入了這些命令:npm init 創建 package.jsonnpm install discord.js 安裝 discord 包.

my discord.js bot has version 13.1.0, and my node's version is 16.7.0. I entered these commands in the terminal : npm init to create package.json and npm install discord.js to install discord package.

我在 index.js 中編寫了代碼,并創建了 config.json 將令牌放在那里.

I writed the code in index.js, and I created config.json to put the token there.

當我運行代碼時,它會顯示準備就緒!"在控制臺中并在 Discord 中在線.我還可以毫無問題地更改機器人的狀態和活動.這里的問題是機器人不發送或回復消息.

When I run then the code it shows me 'Ready!' in the console and being online in Discord. I also can change the status and the activity of the bot without a problem. The problem here is the bot doesn't send or reply to a message.

下面是代碼

const { Client, Intents } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

client.once('ready', () => {
    console.log('Ready!');
});

client.on ('messageCreate', (message) => {
    if (message.content === 'hello') {
        message.reply('Hello')
    };
});

client.login(token);

這是 config.json 的代碼,以防萬一.

this's config.json's code just in case.

{
    "token": "my_bot_token!"
}

推薦答案

問題是由于缺少意圖引起的.要收聽消息,您需要指定 GUILD_MESSAGES 標志:

The issue is caused by missing intents. To listen to messages, you need to specify the GUILD_MESSAGES flag:

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

這篇關于即使沒有任何錯誤,我的 discord.js 機器人也不會回復用戶消息的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 成人自拍视频网站 | 国产一级一级毛片 | 国产中文字幕网 | 欧美1区2区 | 午夜久久 | av在线视| 日韩在线| 一区二区福利视频 | 亚洲精品一区二区在线观看 | 亚洲一区二区三区四区五区午夜 | 影音先锋中文在线 | 国产丝袜一区二区三区免费视频 | 久久久久久中文字幕 | 91精品国产日韩91久久久久久 | 精品一区二区三区四区五区 | 午夜私人影院 | 国产成人99久久亚洲综合精品 | 亚洲国产欧美国产综合一区 | 国产一区二区在线免费视频 | 欧美成人免费在线视频 | 亚洲 91 | 中文字幕二区 | 成人一级视频在线观看 | 国产99视频精品免费视频7 | 国产第1页| a级毛片免费高清视频 | 欧美日韩一二三区 | 日韩精品四区 | 国产激情视频在线免费观看 | 黑人精品欧美一区二区蜜桃 | 欧美成人免费在线视频 | 国产欧美精品 | 成人激情视频在线播放 | 女人毛片a毛片久久人人 | 九九亚洲| 亚洲精品99999| h视频在线播放 | 欧美一级片中文字幕 | 91在线网 | 亚洲精品国产电影 | 久久久久久国产精品 |