Gal*_*eld 9 javascript discord discord.js
最近,Discord 添加了新功能,当用户replies收到一条消息时,它会引用它并添加一条小线,即回复者的个人资料图片与原始发件人的个人资料图片和消息,如下所示(我回复来自机器人的消息):
是否可以使用 Discord.js 做到这一点?
目前,我使用 没有问题message.reply(),但是机器人只是发送一条消息,而不是实际回复它(发送“回复类型”消息),这是我通过应用程序的 GUI 回复消息时显示的内容,手动(如上图所示)。
你可以这样做:
client.api.channels[message.channel.id].messages.post({
data: {
content: "this is my message content!",
message_reference: {
message_id: message.id,
channel_id: message.channel.id,
guild_id: message.guild.id
}
}
})
Run Code Online (Sandbox Code Playgroud)
小智 6
使用不和谐回复: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');
Run Code Online (Sandbox Code Playgroud)
在命令处理程序上
/**
* No need to define it
* */
module.exports = {
name: 'reply',
category: 'Test',
run: (client, message, args) => {
message.lineReply('This is reply with @mention');
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17388 次 |
| 最近记录: |