简体   繁体   English

Discord.js - 发送消息时检测

[英]Discord.js - Detect when message is send

Im trying to detect when someone sends an message with this code.我试图检测何时有人使用此代码发送消息。 Sadly its not working for some reason.遗憾的是,由于某种原因它无法正常工作。 It should give an output in the console and send an reply but both doesnt happen.它应该在控制台中给出 output 并发送回复,但两者都没有发生。

const bot= new CommandClient(`Bot ${token}`, { intents: ['guilds'], maxShards: 'auto',restMode: true })

bot.on('message', (message) => {
    message.reply('This is a reply!')
    .then(() => console.log("test"))
    .catch(console.error);
})

The const bot works with interaction so its probably not the problem. const bot与交互一起工作,所以它可能不是问题。 Can anyone help me?谁能帮我?

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

bot.on('messageCreate', async message => {
message.reply("This is a reply!")
    .then(() => console.log("test"))
    .catch(console.error);

})


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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM