reply to message with channel webhook

Is it possible to use Webhook.send() to reply to a message in the same channel? I followed the docs and it makes it look like you could add the reply parameter to the MessagePayload.create() and set the reference like described in this question in this forum https://discord.com/channels/222078108977594368/1171346142823460886. This is the code I am using. The message sends to the right channel and everything but it doesn't show the reference like other replies.
public async sendRpMessage(options: WebhookMessageCreateOptions, channel: GuildTextBasedChannel, char: Character, msgToReply: Message = null) {
let opts = {
username: parseServerNickname(char),
avatarURL: char.avatar_url,
...options
};
if (channel.isThread()) {
opts = { threadId: channel.id, ...opts };
}
const rpHook = await this.findOrCreateRpHook(channel);
if (rpHook) {
if (msgToReply) {
const payload = MessagePayload.create(rpHook, { reply: { messageReference: msgToReply.id }, ...opts });
return rpHook.send(payload);
}

return rpHook.send(opts);
} else {
console.log('unable to find or create webhook for:' + channel.id);
}
return null;
}
public async sendRpMessage(options: WebhookMessageCreateOptions, channel: GuildTextBasedChannel, char: Character, msgToReply: Message = null) {
let opts = {
username: parseServerNickname(char),
avatarURL: char.avatar_url,
...options
};
if (channel.isThread()) {
opts = { threadId: channel.id, ...opts };
}
const rpHook = await this.findOrCreateRpHook(channel);
if (rpHook) {
if (msgToReply) {
const payload = MessagePayload.create(rpHook, { reply: { messageReference: msgToReply.id }, ...opts });
return rpHook.send(payload);
}

return rpHook.send(opts);
} else {
console.log('unable to find or create webhook for:' + channel.id);
}
return null;
}
7 Replies
d.js toolkit
d.js toolkit9mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
WhacK
WhacKOP9mo ago
[email protected] /Users/sr/Engrimoore/Beholder └── [email protected] -> % node -v v18.18.2
WhacK
WhacKOP9mo ago
No description
Amgelo
Amgelo9mo ago
webhooks can't reply to a message
d.js docs
d.js docs9mo ago
:method: (static) MessagePayload.create() Creates a MessagePayload from user-level arguments. :interface: MessagePayloadOption A possible payload option. :interface: WebhookMessageCreateOptions Options that can be passed into send.
Amgelo
Amgelo9mo ago
as you can see there's no option for replying within a WebhookMessageCreateOptions
WhacK
WhacKOP9mo ago
It also accepts a MessagePayload so I thought it might be possible but I'll have to go back to copying the prior content and appending with markdown
Want results from more Discord servers?
Add your server