fix(embed): Allow attachment protocols for thumbnails and images (#10795)

fix(embed): allow attachment protocols for thumbnails and images

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Jiralite
2025-03-07 20:19:14 +00:00
committed by GitHub
parent c78407e751
commit 12638cd43c
2 changed files with 23 additions and 11 deletions

View File

@@ -207,6 +207,12 @@ describe('Embed', () => {
expect(embed.toJSON()).toStrictEqual({ ...base, thumbnail: { url: 'https://discord.js.org/static/logo.svg' } });
});
test('GIVEN an embed using Embed#setThumbnail with attachment protocol THEN returns valid toJSON data', () => {
const embed = new EmbedBuilder();
embed.setThumbnail('attachment://discordjs.webp');
expect(embed.toJSON()).toStrictEqual({ ...base, thumbnail: { url: 'attachment://discordjs.webp' } });
});
test('GIVEN an embed with a pre-defined thumbnail THEN unset thumbnail THEN return valid toJSON data', () => {
const embed = new EmbedBuilder({ thumbnail: { url: 'https://discord.js.org/static/logo.svg' }, ...dummy });
embed.clearThumbnail();
@@ -228,6 +234,12 @@ describe('Embed', () => {
expect(embed.toJSON()).toStrictEqual({ ...base, image: { url: 'https://discord.js.org/static/logo.svg' } });
});
test('GIVEN an embed using Embed#setImage with attachment protocol THEN returns valid toJSON data', () => {
const embed = new EmbedBuilder();
embed.setImage('attachment://discordjs.webp');
expect(embed.toJSON()).toStrictEqual({ ...base, image: { url: 'attachment://discordjs.webp' } });
});
test('GIVEN an embed using Embed#setImage THEN returns valid toJSON data', () => {
const embed = new EmbedBuilder();
embed.setImage('https://discord.js.org/static/logo.svg');