Skip to content

Commit e557a15

Browse files
fix: check if embed color out of range
1 parent d96cae6 commit e557a15

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/lib/messages/cache.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ const saveMessageToCache = ({
5959
"The embed exceeds one or more of limits on embeds."
6060
);
6161
}
62+
if (
63+
data.embed?.color !== undefined &&
64+
(data.embed.color > 16777215 || data.embed.color < 0)
65+
) {
66+
throw new ExpectedFailure(
67+
InteractionOrRequestFinalStatus.EMBED_EXCEEDS_DISCORD_LIMITS,
68+
"The embed color exceeds the maximum value of 16777215."
69+
);
70+
}
6271
}
6372
return instance.redisCache.setMessageCache(key, data);
6473
};

src/lib/messages/edit.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ async function editMessage({
160160
"The embed exceeds one or more of limits on embeds."
161161
);
162162
}
163+
if (
164+
embed?.color !== undefined &&
165+
(embed.color > 16777215 || embed.color < 0)
166+
) {
167+
throw new ExpectedFailure(
168+
InteractionOrRequestFinalStatus.EMBED_EXCEEDS_DISCORD_LIMITS,
169+
"The embed color exceeds the maximum value of 16777215."
170+
);
171+
}
163172

164173
// Also check if title and / or description is set on the embed
165174
if (embed.title === undefined && embed.description === undefined) {

src/lib/messages/send.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ async function sendMessage({
161161
"The embed exceeds one or more of limits on embeds."
162162
);
163163
}
164+
if (embed?.color !== undefined && (embed.color > 16777215 || embed.color < 0)) {
165+
throw new ExpectedFailure(
166+
InteractionOrRequestFinalStatus.EMBED_EXCEEDS_DISCORD_LIMITS,
167+
"The embed color exceeds the maximum value of 16777215."
168+
);
169+
}
164170
// Also check if title and / or description is set on the embed
165171
// Also a discord restriction
166172
if (embed.title === undefined && embed.description === undefined) {

0 commit comments

Comments
 (0)