簡體   English   中英

Discord.js - 發送消息時檢測

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

我試圖檢測何時有人使用此代碼發送消息。 遺憾的是,由於某種原因它無法正常工作。 它應該在控制台中給出 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);
})

const bot與交互一起工作,所以它可能不是問題。 誰能幫我?

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