Add MaxUploadLimit to guilds (#2001)

This commit is contained in:
Quin Lynch
2021-12-24 15:58:01 -04:00
committed by GitHub
parent 2a416a355c
commit 7745558bdc
5 changed files with 30 additions and 0 deletions

View File

@@ -372,6 +372,16 @@ namespace Discord.Rest
Preconditions.NotNullOrEmpty(attachment.FileName, nameof(attachment.FileName), "File Name must not be empty or null");
}
if (channel is ITextChannel guildTextChannel)
{
var contentSize = (ulong)attachments.Sum(x => x.Stream.Length);
if (contentSize > guildTextChannel.Guild.MaxUploadLimit)
{
throw new ArgumentOutOfRangeException(nameof(attachments), $"Collective file size exceeds the max file size of {guildTextChannel.Guild.MaxUploadLimit} bytes in that guild!");
}
}
// check that user flag and user Id list are exclusive, same with role flag and role Id list
if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue)
{