[英]DiscordJS V13 doesnt react to dms
我有一個非常基本的 discord 機器人的非常基本的代碼
由於新的 discord.js 版本 13,您需要聲明意圖。
我嘗試使用 bitmap 32767(基本上聲明所有意圖)執行此操作,但是當在 dms 中發送消息時機器人不會觸發“messageCreate”事件,它僅適用於服務器。
開發人員站點上的所有特權網關意圖都已設置為 true。
我錯過了什么?
const Discord = require("discord.js");
const allIntents = new Discord.Intents(32767);
const client = new Discord.Client({ intents: allIntents });
require("dotenv").config();
const botName = "Miku";
client.once("ready", () => {
//gets executed once at the start of the bot
console.log(botName + " is online!");
});
client.on("messageCreate", (message) => {
console.log("got a message");
});
(async() => {
//bot connects with Discord api
client.login(process.env.TOKEN);
})();
您不能在直接消息中收聽事件,除非它們是對初始消息的直接響應/回復/反應。
例如,您可以向新成員發送消息並等待回復:
client.on('guildMemberAdd', member =>{
member.send("Welcome to the server!");
message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then((collected) => {
//Now, write your code here that handles the reactions.
});
但是無法在私信中監聽事件。 就像client.on...
永遠不會因為 DM 事件而觸發。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.