discord.js回复留言(实际回复加回复装饰)
最近,Discord 添加了新功能,当用户replies收到一条消息时,它会引用它并添加一条小线,即回复者的个人资料图片与原始发件人的个人资料图片和消息,如下所示(我回复来自机器人的消息):
是否可以使用 Discord.js 做到这一点?
目前,我使用 没有问题message.reply(),但是机器人只是发送一条消息,而不是实际回复它(发送“回复类型”消息),这是我通过应用程序的 GUI 回复消息时显示的内容,手动(如上图所示)。
回答
djs 模块的维护者已经在官方 djs 服务器的 faq 频道中对此发表了评论。该功能预计13版本才会实现,如果要实现需要fork djs,自己写回复代码使用官方discord API网关中的消息引用参数
- Link inside the message: https://github.com/discordjs/discord.js/pull/4874
回答
使用不和谐回复:https : //www.npmjs.com/package/discord-reply
主文件
const discord = require('discord.js');
require('discord-reply'); //?? IMPORTANT: put this before your discord.Client()
const client = new discord.Client();
client.on('ready', () => {
console.log(client.user.tag)
});
client.on('message', async message => {
if (message.content.startsWith('!reply')) {
message.lineReply('Hey'); //Line (Inline) Reply with mention
message.lineReplyNoMention(`My name is ${client.user.username}`); //Line (Inline) Reply without mention
}
});
client.login('TOKEN');
在命令处理程序上
/**
* No need to define it
* */
module.exports = {
name: 'reply',
category: 'Test',
run: (client, message, args) => {
message.lineReply('This is reply with @mention');
}
}