[英]how dose the bot.on('messageCreate') discord.js work? the bot wont detect a sent message, trying to make a discord chat bot
consts and requirements常量和要求
require('dotenv').config();
const OpenAI = require('openai-api');
// Load your key from an environment variable or secret management service
// (do not include your key directly in your code)
const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
const openai = new OpenAI(OPENAI_API_KEY);
const Discord = require('discord.js');
const TOKEN = process.env.TOKEN;
const { Client, Intents } = require('discord.js');
const bot = new Discord.Client({ intents: [Intents.FLAGS.GUILDS] });
const prefix = 'w!';
*on ready*
bot.on('ready', async() => {
console.log(`${bot.user.tag} is online!`);
bot.user.setActivity('with the code', {type: 'PLAYING'});
});
this is the one being the problem, it won't detect sent messages I've tried a few different ways but nothing, got nothing to do with the server permissions I'm testing on a blank server and node is up to date这是问题所在,它不会检测到发送的消息我尝试了几种不同的方法,但没有任何关系,与我在空白服务器上测试的服务器权限无关,节点是最新的
bot.on('messageCreate', message => {
if (message.content === 'ping') {
message.channel.send('pong');
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.