showing results for - "get message referenced in inline reply discord js"
Lacey
01 Feb 2018
1//ExtendedMessage.js
2const { APIMessage, Structures } = require("discord.js");
3
4class ExtAPIMessage extends APIMessage {
5    resolveData() {
6        if (this.data) return this;
7        super.resolveData();
8        if ((this.options.allowedMentions || {}).repliedUser !== undefined) {
9            if (this.data.allowed_mentions === undefined) this.data.allowed_mentions = {};
10            Object.assign(this.data.allowed_mentions, { replied_user: this.options.allowedMentions.repliedUser });
11            delete this.options.allowedMentions.repliedUser;
12        }
13        if (this.options.replyTo !== undefined) {
14            Object.assign(this.data, { message_reference: { message_id: this.options.replyTo.id } });
15        }
16        return this;
17    }
18}
19
20class Message extends Structures.get("Message") {
21    inlineReply(content, options) {
22        return this.channel.send(ExtAPIMessage.create(this, content, options, { replyTo: this }).resolveData());
23    }
24
25    edit(content, options) {
26        return super.edit(ExtAPIMessage.create(this, content, options).resolveData());
27    }
28}
29
30Structures.extend("Message", () => Message);
31
32
33//index.js
34const { Client } = require("discord.js");
35
36require("./ExtendedMessage");
37
38const client = new Client();
39
40client.on("message", msg => {
41    if (msg.author.bot) return;
42    if (msg.content === "hi") {
43        msg.inlineReply("hello");
44    }
45});
46
47client.login("ur token");
48
49//Credit: Allvaa on GitHub