|
6 | 6 | ClientEvents,
|
7 | 7 | MessageFlags,
|
8 | 8 | UserFlags as DiscordUserFlags,
|
| 9 | + MAX_ATTACHMENT_SIZE, |
9 | 10 | } from 'detritus-client/lib/constants';
|
10 | 11 | import { Embed, Markup, Snowflake, intToHex, intToRGB } from 'detritus-client/lib/utils';
|
11 | 12 | import { Endpoints as DiscordEndpoints, RequestTypes } from 'detritus-client-rest';
|
@@ -341,7 +342,7 @@ class GuildLoggingStore extends Store<string, GuildLogStorage> {
|
341 | 342 | const promises: Array<Promise<any>> = [];
|
342 | 343 | for (let [loggerType, queue] of queues) {
|
343 | 344 | // add embed length checks since the max character amount of 6000 is spread through all 10 embeds
|
344 |
| - const unfilteredPayloads = queue.splice(0, 10).map((event) => createLogPayload(event)); |
| 345 | + const unfilteredPayloads = queue.splice(0, 10).map((event) => createLogPayload(event, shard)); |
345 | 346 | const payloads: Array<RequestTypes.ExecuteWebhook> = [];
|
346 | 347 | while (unfilteredPayloads.length) {
|
347 | 348 | const embeds: Array<Embed> = [];
|
@@ -782,6 +783,7 @@ export default new GuildLoggingStore();
|
782 | 783 |
|
783 | 784 | export function createLogPayload(
|
784 | 785 | event: GuildLoggingEventItem,
|
| 786 | + shard: ShardClient, |
785 | 787 | ): {
|
786 | 788 | embed: Embed,
|
787 | 789 | files: Array<{filename: string, value: any}>,
|
@@ -1801,13 +1803,19 @@ export function createLogPayload(
|
1801 | 1803 | embed.setColor(EmbedColors.LOG_UPDATE);
|
1802 | 1804 |
|
1803 | 1805 | if (avatars) {
|
1804 |
| - if (avatars.current) { |
1805 |
| - embed.setAuthor(undefined, `attachment://${avatars.current.filename}`); |
1806 |
| - files.push(avatars.current); |
1807 |
| - } |
1808 |
| - if (avatars.old) { |
1809 |
| - embed.setThumbnail(`attachment://${avatars.old.filename}`); |
1810 |
| - files.push(avatars.old); |
| 1806 | + const guild = shard.guilds.get(guildId); |
| 1807 | + const maxFileSize = (guild) ? guild.maxAttachmentSize : MAX_ATTACHMENT_SIZE; |
| 1808 | + |
| 1809 | + const total = ((avatars.current) ? avatars.current.value.length : 0) + ((avatars.old) ? avatars.old.value.length : 0); |
| 1810 | + if (total && total < maxFileSize) { |
| 1811 | + if (avatars.current) { |
| 1812 | + embed.setAuthor(undefined, `attachment://${avatars.current.filename}`); |
| 1813 | + files.push(avatars.current); |
| 1814 | + } |
| 1815 | + if (avatars.old) { |
| 1816 | + embed.setThumbnail(`attachment://${avatars.old.filename}`); |
| 1817 | + files.push(avatars.old); |
| 1818 | + } |
1811 | 1819 | }
|
1812 | 1820 | }
|
1813 | 1821 |
|
|
0 commit comments