如何获取嵌入并将其发布到另一个频道



我正在尝试为我的Discord Bot创建一个报告功能%报告(用户名((规则#已破坏((详细信息(。机器人程序在员工聊天中创建一个挂起的报告作为嵌入。我希望工作人员能够使用命令通过其ID获取嵌入,并将其发送到另一个不协调通道进行进一步审查。目前我想不出任何想法来实现这个结果,我想知道这里是否有人能为我指明正确的方向。

我本来打算让命令像这样工作,%review(消息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);


}
}

这应该从人员通道获得消息,并将其重新发送到另一个通道。

} else if (command === 'review') {
let ID = args[0];
const embedMessage = await message.channel.messages.fetch(ID);
const embed = embedMessage.embeds[0];
(await bot.channels.fetch(/* other channel ID */)).send(embedMessage.content, { embed });
}

参考文献:

  • Message.channel
  • TextChannel.messages
  • MessageManager.fetch()
  • Channel.embeds
  • Client.channels
  • ChannelManager.fetch()
  • TextChannel.send()

最新更新