@@ -355,6 +355,11 @@ namespace Discord | |||||
bool IsBoostProgressBarEnabled { get; } | bool IsBoostProgressBarEnabled { get; } | ||||
/// <summary> | /// <summary> | ||||
/// Gets the upload limit in bytes for this guild. This number is dependent on the guild's boost status. | |||||
/// </summary> | |||||
ulong MaxUploadLimit { get; } | |||||
/// <summary> | |||||
/// Modifies this guild. | /// Modifies this guild. | ||||
/// </summary> | /// </summary> | ||||
/// <param name="func">The delegate containing the properties to modify the guild with.</param> | /// <param name="func">The delegate containing the properties to modify the guild with.</param> | ||||
@@ -372,6 +372,16 @@ namespace Discord.Rest | |||||
Preconditions.NotNullOrEmpty(attachment.FileName, nameof(attachment.FileName), "File Name must not be empty or null"); | 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 | // check that user flag and user Id list are exclusive, same with role flag and role Id list | ||||
if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue) | if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue) | ||||
{ | { | ||||
@@ -124,6 +124,15 @@ namespace Discord.Rest | |||||
{ | { | ||||
await client.ApiClient.DeleteGuildAsync(guild.Id, options).ConfigureAwait(false); | await client.ApiClient.DeleteGuildAsync(guild.Id, options).ConfigureAwait(false); | ||||
} | } | ||||
public static ulong GetUploadLimit(IGuild guild) | |||||
{ | |||||
return guild.PremiumTier switch | |||||
{ | |||||
PremiumTier.Tier2 => 50ul * 1000000, | |||||
PremiumTier.Tier3 => 100ul * 1000000, | |||||
_ => 8ul * 1000000 | |||||
}; | |||||
} | |||||
#endregion | #endregion | ||||
#region Bans | #region Bans | ||||
@@ -99,6 +99,9 @@ namespace Discord.Rest | |||||
}; | }; | ||||
} | } | ||||
} | } | ||||
/// <inheritdoc/> | |||||
public ulong MaxUploadLimit | |||||
=> GuildHelper.GetUploadLimit(this); | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public NsfwLevel NsfwLevel { get; private set; } | public NsfwLevel NsfwLevel { get; private set; } | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
@@ -201,6 +201,9 @@ namespace Discord.WebSocket | |||||
}; | }; | ||||
} | } | ||||
} | } | ||||
/// <inheritdoc/> | |||||
public ulong MaxUploadLimit | |||||
=> GuildHelper.GetUploadLimit(this); | |||||
/// <summary> | /// <summary> | ||||
/// Gets the widget channel (i.e. the channel set in the guild's widget settings) in this guild. | /// Gets the widget channel (i.e. the channel set in the guild's widget settings) in this guild. | ||||
/// </summary> | /// </summary> | ||||