feat(Rest): show the data that is sent to Discord when an errors occurs (#5701)

This commit is contained in:
Vlad Frangu
2021-06-03 11:35:09 +03:00
committed by GitHub
parent af2fad9473
commit ef92339d07
4 changed files with 50 additions and 15 deletions

View File

@@ -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: