mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
feat(Rest): show the data that is sent to Discord when an errors occurs (#5701)
This commit is contained in:
@@ -125,6 +125,9 @@ class APIMessage {
|
||||
*/
|
||||
resolveData() {
|
||||
if (this.data) return this;
|
||||
const isInteraction = this.isInteraction;
|
||||
const isWebhook = this.isWebhook;
|
||||
const isWebhookLike = isInteraction || isWebhook;
|
||||
|
||||
const content = this.makeContent();
|
||||
const tts = Boolean(this.options.tts);
|
||||
@@ -139,7 +142,7 @@ class APIMessage {
|
||||
}
|
||||
|
||||
const embedLikes = [];
|
||||
if (this.isInteraction || this.isWebhook) {
|
||||
if (isWebhookLike) {
|
||||
if (this.options.embeds) {
|
||||
embedLikes.push(...this.options.embeds);
|
||||
}
|
||||
@@ -150,7 +153,7 @@ class APIMessage {
|
||||
|
||||
let username;
|
||||
let avatarURL;
|
||||
if (this.isWebhook) {
|
||||
if (isWebhook) {
|
||||
username = this.options.username || this.target.name;
|
||||
if (this.options.avatarURL) avatarURL = this.options.avatarURL;
|
||||
}
|
||||
@@ -159,7 +162,7 @@ class APIMessage {
|
||||
if (this.isMessage) {
|
||||
// eslint-disable-next-line eqeqeq
|
||||
flags = this.options.flags != null ? new MessageFlags(this.options.flags).bitfield : this.target.flags.bitfield;
|
||||
} else if (this.isInteraction && this.options.ephemeral) {
|
||||
} else if (isInteraction && this.options.ephemeral) {
|
||||
flags = MessageFlags.FLAGS.EPHEMERAL;
|
||||
}
|
||||
|
||||
@@ -191,8 +194,8 @@ class APIMessage {
|
||||
content,
|
||||
tts,
|
||||
nonce,
|
||||
embed: this.options.embed === null ? null : embeds[0],
|
||||
embeds,
|
||||
embed: !isWebhookLike ? (this.options.embed === null ? null : embeds[0]) : undefined,
|
||||
embeds: isWebhookLike ? embeds : undefined,
|
||||
username,
|
||||
avatar_url: avatarURL,
|
||||
allowed_mentions:
|
||||
|
||||
Reference in New Issue
Block a user