WhacK
WhacK
Explore posts from servers
DIAdiscord.js - Imagine a boo! 👻
Created by WhacK on 3/7/2024 in #djs-questions
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;
}
10 replies
DIAdiscord.js - Imagine a boo! 👻
Created by WhacK on 9/18/2023 in #djs-questions
Channel.messages.fetch(id) giving mixed results
My bot uses the embed fields to match an Array from the embed to their character stats. On Desktop this issue doesn't seem to happen. When testing the submit command from mobile the statRoll message is giving me 2 different values. Sometimes the embeds are there and sometimes they are gone. Everything else looks to be the same. Correct response (no errors):
{
channelId: "984143582027972681",
guildId: "984143580241211412",
id: "1152294200927334420",
createdTimestamp: 1694798746092,
type: 0,
system: false,
content: "<@1080207865861644328> rolled stats...",
author: {
id: "261302296103747584",
bot: true,
system: false,
flags: {
bitfield: 65536,
},
username: "Avrae",
globalName: null,
discriminator: "6944",
avatar: "b4926b52f7f1c966e01e25f0b33253f1",
banner: null,
accentColor: null,
avatarDecoration: null,
},
pinned: false,
tts: false,
nonce: null,
embeds: [
{
data: {
type: "rich",
title: "Generating Random Stats",
description: "**Server Settings:**\n● Minimum of 72\n● Maximum of 86\n● At least 2 over 14\n● At least 1 under 12",
color: 15036310,
fields: [
{
name: "Stats",
value: "**Stat 1:** 4d6kh3 (~~**1**~~, **6**, 3, **6**) = `15`\n**Stat 2:** 4d6kh3 (~~2~~, **6**, 4, **6**) = `16`\n**Stat 3:** 4d6kh3 (2, 5, ~~2~~, 3) = `10`\n**Stat 4:** 4d6kh3 (**6**, ~~3~~, 4, 5) = `15`\n**Stat 5:** 4d6kh3 (3, **6**, **6**, ~~2~~) = `15`\n**Stat 6:** 4d6kh3 (2, **6**, 3, ~~2~~) = `11`\n-----\nTotal = `82`",
inline: true,
},
],
},
},
],
components: [
],
attachments: {
},
stickers: {
},
position: null,
roleSubscriptionData: null,
editedTimestamp: null,
reactions: {
message: [Circular],
},
mentions: {
everyone: false,
users: {
},
roles: {
},
_members: null,
_channels: null,
_parsedUsers: null,
crosspostedChannels: {
},
repliedUser: null,
},
webhookId: null,
groupActivityApplication: null,
applicationId: null,
activity: null,
flags: {
bitfield: 0,
},
reference: null,
interaction: null,
}
{
channelId: "984143582027972681",
guildId: "984143580241211412",
id: "1152294200927334420",
createdTimestamp: 1694798746092,
type: 0,
system: false,
content: "<@1080207865861644328> rolled stats...",
author: {
id: "261302296103747584",
bot: true,
system: false,
flags: {
bitfield: 65536,
},
username: "Avrae",
globalName: null,
discriminator: "6944",
avatar: "b4926b52f7f1c966e01e25f0b33253f1",
banner: null,
accentColor: null,
avatarDecoration: null,
},
pinned: false,
tts: false,
nonce: null,
embeds: [
{
data: {
type: "rich",
title: "Generating Random Stats",
description: "**Server Settings:**\n● Minimum of 72\n● Maximum of 86\n● At least 2 over 14\n● At least 1 under 12",
color: 15036310,
fields: [
{
name: "Stats",
value: "**Stat 1:** 4d6kh3 (~~**1**~~, **6**, 3, **6**) = `15`\n**Stat 2:** 4d6kh3 (~~2~~, **6**, 4, **6**) = `16`\n**Stat 3:** 4d6kh3 (2, 5, ~~2~~, 3) = `10`\n**Stat 4:** 4d6kh3 (**6**, ~~3~~, 4, 5) = `15`\n**Stat 5:** 4d6kh3 (3, **6**, **6**, ~~2~~) = `15`\n**Stat 6:** 4d6kh3 (2, **6**, 3, ~~2~~) = `11`\n-----\nTotal = `82`",
inline: true,
},
],
},
},
],
components: [
],
attachments: {
},
stickers: {
},
position: null,
roleSubscriptionData: null,
editedTimestamp: null,
reactions: {
message: [Circular],
},
mentions: {
everyone: false,
users: {
},
roles: {
},
_members: null,
_channels: null,
_parsedUsers: null,
crosspostedChannels: {
},
repliedUser: null,
},
webhookId: null,
groupActivityApplication: null,
applicationId: null,
activity: null,
flags: {
bitfield: 0,
},
reference: null,
interaction: null,
}
Embeds missing:
{
channelId: "984143582027972681",
guildId: "984143580241211412",
id: "1152294200927334420",
createdTimestamp: 1694798746092,
type: 0,
system: false,
content: "<@1080207865861644328> rolled stats...",
author: {
id: "261302296103747584",
bot: true,
system: false,
flags: {
bitfield: 65536,
},
username: "Avrae",
globalName: null,
discriminator: "6944",
avatar: "b4926b52f7f1c966e01e25f0b33253f1",
banner: null,
accentColor: null,
avatarDecoration: null,
},
pinned: false,
tts: false,
nonce: null,
embeds: [
],
components: [
],
attachments: {
},
stickers: {
},
position: null,
roleSubscriptionData: null,
editedTimestamp: null,
reactions: {
message: [Circular],
},
mentions: {
everyone: false,
users: {
},
roles: {
},
_members: null,
_channels: null,
_parsedUsers: null,
crosspostedChannels: {
},
repliedUser: null,
},
webhookId: null,
groupActivityApplication: null,
applicationId: null,
activity: null,
flags: {
bitfield: 0,
},
reference: null,
interaction: null,
}
{
channelId: "984143582027972681",
guildId: "984143580241211412",
id: "1152294200927334420",
createdTimestamp: 1694798746092,
type: 0,
system: false,
content: "<@1080207865861644328> rolled stats...",
author: {
id: "261302296103747584",
bot: true,
system: false,
flags: {
bitfield: 65536,
},
username: "Avrae",
globalName: null,
discriminator: "6944",
avatar: "b4926b52f7f1c966e01e25f0b33253f1",
banner: null,
accentColor: null,
avatarDecoration: null,
},
pinned: false,
tts: false,
nonce: null,
embeds: [
],
components: [
],
attachments: {
},
stickers: {
},
position: null,
roleSubscriptionData: null,
editedTimestamp: null,
reactions: {
message: [Circular],
},
mentions: {
everyone: false,
users: {
},
roles: {
},
_members: null,
_channels: null,
_parsedUsers: null,
crosspostedChannels: {
},
repliedUser: null,
},
webhookId: null,
groupActivityApplication: null,
applicationId: null,
activity: null,
flags: {
bitfield: 0,
},
reference: null,
interaction: null,
}
26 replies