如何在JavaScript中读取用户内容condordbot
您好,我为一个Discord聊天机器人编程,当命令“!help”将定向到某个文本频道时,该机器人将直接给写命令的人写一条直接消息,以回答一系列问题,这是代码我现在做的是:
const {Client, RichEmbed, Intents, MessageEmbed} = require('discord.js');
const bot = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES] });
const token = 'TOKEN';
const PREFIX = '!';
bot.on('ready', () => {
console.log(`Logged in as ${bot.user.tag}!`);
})
bot.on('messageCreate', message => {
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case 'help':
const Embed = new MessageEmbed()
.setTitle("Helper Embed")
.setColor(0xFF0000)
.setDescription("Make sure to use the !help to get access to the commands");
message.author.send(Embed);
break;
}
});
bot.login(token);
机器人写信给请求该命令的用户的DM,但我无法解决,根据用户回答的内容,机器人响应与其他信息,并且用户可以用反应回答。
Hello im programming a discord chat bot, that when the command '!help' is directed to a certain text channel, the bot writes a direct message to the person who wrote the command in order to answer a series of questions, this is the code that I did for now:
const {Client, RichEmbed, Intents, MessageEmbed} = require('discord.js');
const bot = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES] });
const token = 'TOKEN';
const PREFIX = '!';
bot.on('ready', () => {
console.log(`Logged in as ${bot.user.tag}!`);
})
bot.on('messageCreate', message => {
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case 'help':
const Embed = new MessageEmbed()
.setTitle("Helper Embed")
.setColor(0xFF0000)
.setDescription("Make sure to use the !help to get access to the commands");
message.author.send(Embed);
break;
}
});
bot.login(token);
The bot writes to the DM of the user that requested the command, but I have not been able to solve, that according to what the user answers, the robot response with other information, and also that the user can answer with reactions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只想等待一些消息,则可以使用
等待
。它有一些选项,例如要等待的消息数,收集消息的时间和可选过滤器。一个示例:但是,如果您正在使用按钮,则简单
MessageComponentCollector
会做。即使在此中,您也有与等待
,例如时间,最大消息数和过滤器。例子:If you just want to wait for some messages to come, you can use
awaitMessages
. It has a few options such as the number of messages to wait for, the time it will collect messages for and an optional filter. An example:But if you are using buttons, then a simple
messageComponentCollector
will do. Even in this, you have the same options as theawaitMessages
such as the time, the maximum number of messages and the filter. Example: