Add MaxUploadLimit to guilds (#2001)
This commit is contained in:
@@ -354,6 +354,11 @@ namespace Discord
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
bool IsBoostProgressBarEnabled { get; }
|
bool IsBoostProgressBarEnabled { get; }
|
||||||
|
|
||||||
|
/// <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>
|
/// <summary>
|
||||||
/// Modifies this guild.
|
/// Modifies this guild.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -100,6 +100,9 @@ namespace Discord.Rest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
public ulong MaxUploadLimit
|
||||||
|
=> GuildHelper.GetUploadLimit(this);
|
||||||
|
/// <inheritdoc />
|
||||||
public NsfwLevel NsfwLevel { get; private set; }
|
public NsfwLevel NsfwLevel { get; private set; }
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool IsBoostProgressBarEnabled { get; private set; }
|
public bool IsBoostProgressBarEnabled { get; private set; }
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user