| @@ -164,7 +164,7 @@ namespace Discord.WebSocket | |||||
| for (int i = 0; i < _shards.Length; i++) | for (int i = 0; i < _shards.Length; i++) | ||||
| await _shards[i].LoginAsync(tokenType, token); | await _shards[i].LoginAsync(tokenType, token); | ||||
| if(_defaultStickers.Length == 0) | |||||
| if(_defaultStickers.Length == 0 && _baseConfig.AlwaysDownloadDefaultStickers) | |||||
| await DownloadDefaultStickersAsync().ConfigureAwait(false); | await DownloadDefaultStickersAsync().ConfigureAwait(false); | ||||
| } | } | ||||
| @@ -65,7 +65,7 @@ namespace Discord.WebSocket | |||||
| private Optional<IActivity> _activity; | private Optional<IActivity> _activity; | ||||
| #endregion | #endregion | ||||
| //From DiscordSocketConfig | |||||
| // From DiscordSocketConfig | |||||
| internal int TotalShards { get; private set; } | internal int TotalShards { get; private set; } | ||||
| internal int MessageCacheSize { get; private set; } | internal int MessageCacheSize { get; private set; } | ||||
| internal int LargeThreshold { get; private set; } | internal int LargeThreshold { get; private set; } | ||||
| @@ -74,6 +74,8 @@ namespace Discord.WebSocket | |||||
| internal WebSocketProvider WebSocketProvider { get; private set; } | internal WebSocketProvider WebSocketProvider { get; private set; } | ||||
| internal bool AlwaysDownloadUsers { get; private set; } | internal bool AlwaysDownloadUsers { get; private set; } | ||||
| internal int? HandlerTimeout { get; private set; } | internal int? HandlerTimeout { get; private set; } | ||||
| internal bool AlwaysDownloadDefaultStickers { get; private set; } | |||||
| internal bool AlwaysResolveStickers { get; private set; } | |||||
| internal new DiscordSocketApiClient ApiClient => base.ApiClient; | internal new DiscordSocketApiClient ApiClient => base.ApiClient; | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public override IReadOnlyCollection<SocketGuild> Guilds => State.Guilds; | public override IReadOnlyCollection<SocketGuild> Guilds => State.Guilds; | ||||
| @@ -143,6 +145,8 @@ namespace Discord.WebSocket | |||||
| UdpSocketProvider = config.UdpSocketProvider; | UdpSocketProvider = config.UdpSocketProvider; | ||||
| WebSocketProvider = config.WebSocketProvider; | WebSocketProvider = config.WebSocketProvider; | ||||
| AlwaysDownloadUsers = config.AlwaysDownloadUsers; | AlwaysDownloadUsers = config.AlwaysDownloadUsers; | ||||
| AlwaysDownloadDefaultStickers = config.AlwaysDownloadDefaultStickers; | |||||
| AlwaysResolveStickers = config.AlwaysResolveStickers; | |||||
| HandlerTimeout = config.HandlerTimeout; | HandlerTimeout = config.HandlerTimeout; | ||||
| State = new ClientState(0, 0); | State = new ClientState(0, 0); | ||||
| Rest = new DiscordSocketRestClient(config, ApiClient); | Rest = new DiscordSocketRestClient(config, ApiClient); | ||||
| @@ -209,7 +213,7 @@ namespace Discord.WebSocket | |||||
| internal override async Task OnLoginAsync(TokenType tokenType, string token) | internal override async Task OnLoginAsync(TokenType tokenType, string token) | ||||
| { | { | ||||
| if(_shardedClient == null && _defaultStickers.Length == 0) | |||||
| if (_shardedClient == null && _defaultStickers.Length == 0 && AlwaysDownloadDefaultStickers) | |||||
| { | { | ||||
| var models = await ApiClient.ListNitroStickerPacksAsync().ConfigureAwait(false); | var models = await ApiClient.ListNitroStickerPacksAsync().ConfigureAwait(false); | ||||
| @@ -49,8 +49,31 @@ namespace Discord.WebSocket | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets or sets the total number of shards for this application. | /// Gets or sets the total number of shards for this application. | ||||
| /// </summary> | /// </summary> | ||||
| /// <remarks> | |||||
| /// If this is left <see langword="null"/> in a sharded client the bot will get the recommended shard | |||||
| /// count from discord and use that. | |||||
| /// </remarks> | |||||
| public int? TotalShards { get; set; } = null; | public int? TotalShards { get; set; } = null; | ||||
| /// <summary> | |||||
| /// Gets or sets whether or not the client should download the default stickers on startup. | |||||
| /// </summary> | |||||
| /// <remarks> | |||||
| /// When this is set to <see langword="false"/> default stickers arn't present and cannot be resolved by the client. | |||||
| /// This will make all default stickers have the type of <see cref="SocketUnknownSticker"/>. | |||||
| /// </remarks> | |||||
| public bool AlwaysDownloadDefaultStickers { get; set; } = false; | |||||
| /// <summary> | |||||
| /// Gets or sets whether or not the client should automatically resolve the stickers sent on a message. | |||||
| /// </summary> | |||||
| /// <remarks> | |||||
| /// Note if a sticker isn't cached the client will preform a rest request to resolve it. This | |||||
| /// may be very rest heavy depending on your bots size, it isn't recommended to use this with large scale bots as you | |||||
| /// can get ratelimited easily. | |||||
| /// </remarks> | |||||
| public bool AlwaysResolveStickers { get; set; } = false; | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets or sets the number of messages per channel that should be kept in cache. Setting this to zero | /// Gets or sets the number of messages per channel that should be kept in cache. Setting this to zero | ||||
| /// disables the message cache entirely. | /// disables the message cache entirely. | ||||
| @@ -154,6 +154,12 @@ namespace Discord.WebSocket | |||||
| if (sticker == null) | if (sticker == null) | ||||
| sticker = Discord.GetSticker(stickerItem.Id); | sticker = Discord.GetSticker(stickerItem.Id); | ||||
| // if they want to auto resolve | |||||
| if (Discord.AlwaysResolveStickers) | |||||
| { | |||||
| sticker = Task.Run(async () => await Discord.GetStickerAsync(stickerItem.Id).ConfigureAwait(false)).GetAwaiter().GetResult(); | |||||
| } | |||||
| // if its still null, create an unknown | // if its still null, create an unknown | ||||
| if (sticker == null) | if (sticker == null) | ||||
| sticker = SocketUnknownSticker.Create(Discord, stickerItem); | sticker = SocketUnknownSticker.Create(Discord, stickerItem); | ||||