久久久久久久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 服務器時的歡迎消息)
主站蜘蛛池模板: 日本中文字幕在线观看 | 国产在线www | 国产精品我不卡 | 性色av一区 | 成人性视频免费网站 | 国产日韩免费视频 | 国产羞羞视频在线观看 | 久久久精 | 午夜爽爽爽男女免费观看影院 | 成人日韩| 日韩第一页 | 日韩中文字幕一区二区 | 日韩二三区 | 中文字幕在线观看一区二区 | 免费视频一区二区三区在线观看 | 国产日韩精品在线 | 日韩一区二区三区av | 中文字幕在线观看一区二区 | 国产精品久久久久久久免费大片 | 免费成人午夜 | 日韩一区中文字幕 | 精品久久影院 | 国产专区视频 | 99精品视频一区二区三区 | 精品欧美乱码久久久久久1区2区 | 欧美男人天堂 | 亚洲第1页 | 午夜视频免费在线观看 | 亚洲品质自拍视频 | 欧美日韩国产精品一区 | 国产高清在线精品 | 日韩一级欧美一级 | 综合亚洲视频 | 欧美精品在线视频 | 罗宾被扒开腿做同人网站 | 欧美性极品xxxx做受 | 亚洲国产精品一区 | 亚洲精品一区二三区不卡 | 蜜桃视频在线观看www社区 | 日韩中文视频 | 亚洲一区免费 |