【发布时间】:2020-07-21 03:59:35
【问题描述】:
我正在尝试为我的 Discord Bot 创建报告功能。当前,如果用户输入 %report(用户名)(规则#已损坏)(详细信息)。该机器人在员工聊天中创建一个待处理的报告作为嵌入。我希望工作人员能够使用命令通过其 ID 获取嵌入,并将其发送到另一个不和谐频道以供进一步审查。目前我想不出任何想法来实现这个结果,我想知道这里是否有人能指出我正确的方向。
我打算让命令像这样工作,%review (message ID)。 这将获取当前在员工聊天中的消息,并将其发送给更高的权威机构以供进一步审查。
P.S 我的代码组织得不好,对此我深表歉意。我将尝试回答您可能遇到的任何问题,以便我消除困惑。
bot.on("message", async message => {
if(message.author.bot) return;
if(!message.content.startsWith(config.prefix)) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if(command === 'report'){
console.log((message.author.username)+ ' is trying to create a report');
let username = args[0]
let rule = args[1]
let notes = args.splice(2).join(" ")
const report = new discord.MessageEmbed()
.setColor('#0099ff')
.setTitle("Pending Report")
.setFooter("UMA Report")
.addField('username: ', username)
.addField('Rule Broken: ', rule)
.addField('Notes: ', notes)
.addField('Report Set By: ', "<@" + message.author.id + ">")
.setTimestamp()
bot.channels.cache.get('53453453345').send({ embed: report })
console.log((message.author.username)+ ' has created a report on: '+ username);
}
}
【问题讨论】:
标签: javascript discord discord.js