【发布时间】:2022-11-14 06:07:13
【问题描述】:
在 discord v14 中,我尝试使用 messageCreate 事件,但是,在用户在 discord 中键入消息后,message.content 没有任何数据,如下所示:
Message {
channelId: '998889338475655188',
guildId: '948995127148425246',
id: '998925735668498433',
createdTimestamp: 1658232854526,
type: 0,
system: false,
content: '',
author: User
我已经尝试四处搜索,但找不到任何解决该问题的方法,我使用的与不和谐相关的代码是:
import { Client, GatewayIntentBits, Partials } from "discord.js";
const bot = new Client({
'intents': [
GatewayIntentBits.DirectMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildMessages
],
'partials': [Partials.Channel]
});
bot.on('messageCreate', async (message) => {
console.log(message);
});
bot.login(process.env.token1)
有谁知道新更新出了什么问题或需要改变什么?
【问题讨论】:
-
确认您设置了公会消息意图并且内容/味精不是部分的?
-
@0xLogN 如果消息是从自身发送的,它将起作用。例如我做了:
bot.on('ready', () => { console.log(`The Discord bot ${bot.user.username} is ready!`); bot.channels.cache.get(outputChannelID).send(`The Discord bot ${bot.user.username} is ready!`); });在来自'messageCreate' async (message)的console.log 中我得到content: The Discord bot bot.user.username is ready!但不适用于用户。
标签: javascript node.js discord discord.js