discord.js | Reply to Message (Actual Reply with Reply Decoration)
Solution 1
The maintainers of the djs module have made a comment about this in the official djs server's faq channel. This feature is expected to be implemented only in version 13, if you want to implement this you have to fork djs and write your own reply code to use the message reference parameter in the official discord API gateway
Solution 2
You can do this:
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
}
}
})
Solution 3
Using discord-reply: https://www.npmjs.com/package/discord-reply
Main file
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');
On command handler
/**
* No need to define it
* */
module.exports = {
name: 'reply',
category: 'Test',
run: (client, message, args) => {
message.lineReply('This is reply with @mention');
}
}
Solution 4
According to version 12 of Discord.js, this behavior does not seem to be supported yet. See: https://discord.js.org/#/docs/main/master/class/Message
Solution 5
In Discord.JS versions 13+ you can now use the Message#reply()
method to send inline replies.
message.reply("woohoo, inline reply support!").then(/* ... */).catch(console.error);
![Gal Grünfeld](https://i.stack.imgur.com/gL7sL.png?s=256&g=1)
Gal Grünfeld
Web developer and data scientist, power user of life, with interest in mathematics, science, technology, history and music. I good UI and UX, nature, playing guitar, singing, listening to music, traveling, gaming, and, sure, why not, long walks on the beach.
Updated on August 13, 2021Comments
-
Gal Grünfeld almost 3 years
Recently, Discord added new functionality that when a user
replies
to a message, it quotes it and adds a little line that the replier's profile picture with the original sender's profile picture and message, as seen here (me replying to a message from a bot):Is it possible to do it with Discord.js?
Currently, I've no problem using
message.reply()
, however the bot just sends a message, rather than actually reply to it (sends a "reply-typed" message), which is what is shown when I reply to a message via the app's GUI, manually (as shown above). -
Gal Grünfeld over 3 yearsThanks, that what I thought - I couldn't find it in the docs. Do you know if the Discord API itself offers it just yet?
-
dolor3sh4ze over 3 yearsI think in the next month
-
leumasme over 3 yearsLink inside the message: github.com/discordjs/discord.js/pull/4874