diff --git a/src/NadekoBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelService.cs b/src/NadekoBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelService.cs index 962cfc5ea..266032291 100644 --- a/src/NadekoBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelService.cs +++ b/src/NadekoBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelService.cs @@ -116,7 +116,7 @@ public class GameVoiceChannelService : INService if (string.IsNullOrWhiteSpace(game)) return false; - game = game.TrimTo(50).ToLowerInvariant(); + game = game.TrimTo(50)!.ToLowerInvariant(); var vch = gUser.Guild.VoiceChannels.FirstOrDefault(x => x.Name.ToLowerInvariant() == game); if (vch is null) diff --git a/src/NadekoBot/Modules/Nsfw/_Common/Downloaders/GelbooruImageDownloader.cs b/src/NadekoBot/Modules/Nsfw/_Common/Downloaders/GelbooruImageDownloader.cs index 80086329d..09622dc31 100644 --- a/src/NadekoBot/Modules/Nsfw/_Common/Downloaders/GelbooruImageDownloader.cs +++ b/src/NadekoBot/Modules/Nsfw/_Common/Downloaders/GelbooruImageDownloader.cs @@ -1,5 +1,6 @@ #nullable disable using System.Text.Json; +using System.Text.Json.Serialization; namespace NadekoBot.Modules.Nsfw.Common; @@ -17,8 +18,8 @@ public class GelbooruImageDownloader : ImageDownloader CancellationToken cancel = default) { var tagString = ImageDownloaderHelper.GetTagString(tags, isExplicit); - var uri = "http://gelbooru.com/index.php?page=dapi&s=post&json=1&q=index&limit=100" - + $"&tags={tagString}&pid={page}"; + var uri = + $"http://gelbooru.com/index.php?page=dapi&s=post&json=1&q=index&limit=100&tags={tagString}&pid={page}"; using var req = new HttpRequestMessage(HttpMethod.Get, uri); using var res = await _http.SendAsync(req, cancel); res.EnsureSuccessStatusCode(); @@ -26,10 +27,16 @@ public class GelbooruImageDownloader : ImageDownloader if (string.IsNullOrWhiteSpace(resString)) return new(); - var images = JsonSerializer.Deserialize>(resString, _serializerOptions); - if (images is null) + var images = JsonSerializer.Deserialize(resString, _serializerOptions); + if (images is null or { Post: null }) return new(); - return images.Where(x => x.FileUrl is not null).ToList(); + return images.Post.Where(x => x.FileUrl is not null).ToList(); } +} + +public class GelbooruResponse +{ + [JsonPropertyName("post")] + public List Post { get; set; } } \ No newline at end of file