From e8706d400636355f08848b22d2798030e2abbd51 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 2 May 2023 09:36:27 +0200 Subject: [PATCH 1/8] Fixed -w 0 for .trivia which allows for infinite games, closes #413 --- src/NadekoBot/Modules/Games/Trivia/Games.cs | 2 +- src/NadekoBot/Modules/Games/Trivia/TriviaGame.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/Modules/Games/Trivia/Games.cs b/src/NadekoBot/Modules/Games/Trivia/Games.cs index 9dbdb87ee..a678350b0 100644 --- a/src/NadekoBot/Modules/Games/Trivia/Games.cs +++ b/src/NadekoBot/Modules/Games/Trivia/Games.cs @@ -36,7 +36,7 @@ public partial class Games var (opts, _) = OptionsParser.ParseFrom(new TriviaOptions(), args); var config = _gamesConfig.Data; - if (config.Trivia.MinimumWinReq > 0 && config.Trivia.MinimumWinReq > opts.WinRequirement) + if (opts.WinRequirement != 0 && config.Trivia.MinimumWinReq > 0 && config.Trivia.MinimumWinReq > opts.WinRequirement) return; var trivia = new TriviaGame(opts, _cache); diff --git a/src/NadekoBot/Modules/Games/Trivia/TriviaGame.cs b/src/NadekoBot/Modules/Games/Trivia/TriviaGame.cs index fc463f5e2..45d603a2a 100644 --- a/src/NadekoBot/Modules/Games/Trivia/TriviaGame.cs +++ b/src/NadekoBot/Modules/Games/Trivia/TriviaGame.cs @@ -157,7 +157,7 @@ public sealed class TriviaGame var isWin = false; // if user won the game, tell the game to stop - if (val >= _opts.WinRequirement) + if (_opts.WinRequirement != 0 && val >= _opts.WinRequirement) { _isStopped = true; isWin = true; From 4dd31d6a0b142446f394662013c4f3946be42478 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 3 May 2023 02:23:10 +0200 Subject: [PATCH 2/8] Fixed .showembed, closes #410 --- src/NadekoBot/Common/SmartText/SmartEmbedText.cs | 8 +++++--- .../Common/SmartText/SmartEmbedTextArray.cs | 3 +++ src/NadekoBot/Common/SmartText/SmartText.cs | 4 ++++ src/NadekoBot/Modules/Utility/Utility.cs | 13 +++++++++---- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/NadekoBot/Common/SmartText/SmartEmbedText.cs b/src/NadekoBot/Common/SmartText/SmartEmbedText.cs index f117fb734..ce1f765fc 100644 --- a/src/NadekoBot/Common/SmartText/SmartEmbedText.cs +++ b/src/NadekoBot/Common/SmartText/SmartEmbedText.cs @@ -1,5 +1,6 @@ #nullable disable warnings using SixLabors.ImageSharp.PixelFormats; +using System.Text.Json.Serialization; namespace NadekoBot; @@ -7,14 +8,14 @@ public sealed record SmartEmbedArrayElementText : SmartEmbedTextBase { public string Color { get; init; } = string.Empty; - public SmartEmbedArrayElementText() : base() + public SmartEmbedArrayElementText() { } public SmartEmbedArrayElementText(IEmbed eb) : base(eb) { - + Color = eb.Color is { } c ? new Rgba32(c.R, c.G, c.B).ToHex() : string.Empty; } protected override EmbedBuilder GetEmbedInternal() @@ -63,6 +64,7 @@ public abstract record SmartEmbedTextBase : SmartText public SmartTextEmbedFooter Footer { get; init; } public SmartTextEmbedField[] Fields { get; init; } + [JsonIgnore] public bool IsValid => !string.IsNullOrWhiteSpace(Title) || !string.IsNullOrWhiteSpace(Description) @@ -100,7 +102,7 @@ public abstract record SmartEmbedTextBase : SmartText IconUrl = ef.IconUrl } : null; - + if (eb.Fields.Length > 0) { Fields = eb.Fields.Select(field diff --git a/src/NadekoBot/Common/SmartText/SmartEmbedTextArray.cs b/src/NadekoBot/Common/SmartText/SmartEmbedTextArray.cs index 90e9f6696..889c59f03 100644 --- a/src/NadekoBot/Common/SmartText/SmartEmbedTextArray.cs +++ b/src/NadekoBot/Common/SmartText/SmartEmbedTextArray.cs @@ -1,4 +1,6 @@ #nullable disable +using System.Text.Json.Serialization; + namespace NadekoBot; public sealed record SmartEmbedTextArray : SmartText @@ -6,6 +8,7 @@ public sealed record SmartEmbedTextArray : SmartText public string Content { get; set; } public SmartEmbedArrayElementText[] Embeds { get; set; } + [JsonIgnore] public bool IsValid => Embeds?.All(x => x.IsValid) ?? false; diff --git a/src/NadekoBot/Common/SmartText/SmartText.cs b/src/NadekoBot/Common/SmartText/SmartText.cs index 2fb9f5ac0..daf05b476 100644 --- a/src/NadekoBot/Common/SmartText/SmartText.cs +++ b/src/NadekoBot/Common/SmartText/SmartText.cs @@ -1,16 +1,20 @@ #nullable disable using Newtonsoft.Json.Linq; +using System.Text.Json.Serialization; namespace NadekoBot; public abstract record SmartText { + [JsonIgnore] public bool IsEmbed => this is SmartEmbedText; + [JsonIgnore] public bool IsPlainText => this is SmartPlainText; + [JsonIgnore] public bool IsEmbedArray => this is SmartEmbedTextArray; diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 374bba0ac..eb744ed92 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -550,15 +550,20 @@ public partial class Utility : NadekoModule return; } - var embed = msg.Embeds.FirstOrDefault(); - if (embed is null) + if (!msg.Embeds.Any()) { await ReplyErrorLocalizedAsync(strs.not_found); return; } - var json = SmartEmbedText.FromEmbed(embed, msg.Content).ToJson(_showEmbedSerializerOptions); - await SendConfirmAsync(Format.Sanitize(json).Replace("](", "]\\(")); + var json = new SmartEmbedTextArray() + { + Content = msg.Content, + Embeds = msg.Embeds + .Map(x => new SmartEmbedArrayElementText(x)) + }.ToJson(_showEmbedSerializerOptions); + + await SendConfirmAsync(Format.Code(json, "json").Replace("](", "]\\(")); } [Cmd] From 6124e2fab568e96cc53f02fea5fb1f08106ea2e7 Mon Sep 17 00:00:00 2001 From: Hokuto Chen Date: Sun, 7 May 2023 16:14:48 +0000 Subject: [PATCH 3/8] %img:stuff% Deprecated --- docs/placeholders.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/placeholders.md b/docs/placeholders.md index 441503c57..6f2a13f31 100644 --- a/docs/placeholders.md +++ b/docs/placeholders.md @@ -89,6 +89,5 @@ Some features have their own specific placeholders which are noted in that featu - `%rngX-Y%` - Returns a random number between X and Y - `%target%` - Returns anything the user has written after the trigger (only works on Expressions) -- `%img:stuff%` - Returns an `imgur.com` search for "stuff" (only works on Expressions) ![img](https://puu.sh/B7mgI.png) From 073b832065bca992685f5683599e768168dea914 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 17 May 2023 17:34:23 +0200 Subject: [PATCH 4/8] Fixed .rps 'amount' field, closes #415 --- src/NadekoBot/Modules/Gambling/Gambling.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index 225ff59a8..c08f97e76 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -840,7 +840,7 @@ public partial class Gambling : GamblingModule else if (result.Result == RpsResultType.Win) { if ((long)result.Won > 0) - embed.AddField(GetText(strs.won), N(amount.Value)); + embed.AddField(GetText(strs.won), N((long)result.Won)); msg = GetText(strs.rps_win(ctx.User.Mention, GetRpsPick(pick), From 93df4f3bf3c527141e55733366c33bf029577f22 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 21 May 2023 00:37:29 +0200 Subject: [PATCH 5/8] Upped version to 4.3.15, Updated CHANGELOG.md --- CHANGELOG.md | 9 +++++++++ src/NadekoBot/Services/Impl/StatsService.cs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb9de9696..1fcfc9ac2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o +## [4.3.15] - 21.05.2023 + +### Fixed + +- Fixed -w 0 in trivia +- Fixed `.rps` amount field in the response +- Fixed `.showembed` output +- Fixed bank award's incorrect output message + ## [4.3.14] - 02.04.2023 ### Fixed diff --git a/src/NadekoBot/Services/Impl/StatsService.cs b/src/NadekoBot/Services/Impl/StatsService.cs index e66af86df..60889186a 100644 --- a/src/NadekoBot/Services/Impl/StatsService.cs +++ b/src/NadekoBot/Services/Impl/StatsService.cs @@ -7,7 +7,7 @@ namespace NadekoBot.Services; public sealed class StatsService : IStatsService, IReadyExecutor, INService { - public const string BOT_VERSION = "4.3.14"; + public const string BOT_VERSION = "4.3.15"; public string Author => "Kwoth#2452"; From 8f43b446774609d12e811d33bbe88fc71e7fd057 Mon Sep 17 00:00:00 2001 From: Hokuto Chen Date: Sat, 20 May 2023 22:42:56 +0000 Subject: [PATCH 6/8] Remove %users% placeholder from docs --- docs/placeholders.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/docs/placeholders.md b/docs/placeholders.md index 6f2a13f31..2b8a23f93 100644 --- a/docs/placeholders.md +++ b/docs/placeholders.md @@ -68,12 +68,7 @@ Some features have their own specific placeholders which are noted in that featu - `%ban.reason%` - Reason for the ban, if provided - `%ban.duration%` - Duration of the ban in the form Days.Hours:Minutes (6.05:04) -### Bot stats placeholders - -- `%servers%` - Server count bot has joined -- `%users%` - Combined user count on servers the bot has joined - -### Shard stats placeholders +### Shard stats placeholders - `%shard.servercount%` - Server count on current shard - `%shard.usercount%` - Combined user count on current shard From 41e4936f521af8d33e62e250d9cbc53520ccb0ff Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 24 May 2023 10:30:51 +0200 Subject: [PATCH 7/8] - Fixed .logevents and .log bugs related to thread logging - Upped version to 4.3.16 - closes #418 --- CHANGELOG.md | 7 ++++++ .../ServerLog/ServerLogCommandService.cs | 23 ++++++++++++++----- .../ServerLog/ServerLogCommands.cs | 6 +++++ src/NadekoBot/Services/Impl/StatsService.cs | 2 +- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fcfc9ac2..4bf72b020 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o +## [4.3.16] - 24.05.2023 + +### Fixed + +- Fixed missing events from `.logevents` +- Fixed `.log` thread deleted and thread created events not working properly + ## [4.3.15] - 21.05.2023 ### Fixed diff --git a/src/NadekoBot/Modules/Administration/ServerLog/ServerLogCommandService.cs b/src/NadekoBot/Modules/Administration/ServerLog/ServerLogCommandService.cs index 447bf2b1e..eb56ce2bb 100644 --- a/src/NadekoBot/Modules/Administration/ServerLog/ServerLogCommandService.cs +++ b/src/NadekoBot/Modules/Administration/ServerLog/ServerLogCommandService.cs @@ -150,9 +150,11 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor { try { - if (sch.HasValue || sch.Value is not IGuildChannel ch) + if (!sch.HasValue) return; + var ch = sch.Value; + if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out var logSetting) || logSetting.ThreadDeletedId is null) return; @@ -165,7 +167,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor await logChannel.EmbedAsync(_eb.Create() .WithOkColor() - .WithTitle("🆕 " + title) + .WithTitle("🗑 " + title) .WithDescription($"{ch.Name} | {ch.Id}") .WithFooter(CurrentTime(ch.Guild))); } @@ -177,15 +179,12 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor return Task.CompletedTask; } - private Task _client_ThreadCreated(SocketThreadChannel sch) + private Task _client_ThreadCreated(SocketThreadChannel ch) { _ = Task.Run(async () => { try { - if (sch.Guild is not IGuildChannel ch) - return; - if (!GuildLogSettings.TryGetValue(ch.Guild.Id, out var logSetting) || logSetting.ThreadCreatedId is null) return; @@ -456,6 +455,12 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor case LogType.UserWarned: channelId = logSetting.LogWarnsId = logSetting.LogWarnsId is null ? cid : default; break; + case LogType.ThreadDeleted: + channelId = logSetting.ThreadDeletedId = logSetting.ThreadDeletedId is null ? cid : default; + break; + case LogType.ThreadCreated: + channelId = logSetting.ThreadCreatedId = logSetting.ThreadCreatedId is null ? cid : default; + break; } uow.SaveChanges(); @@ -1267,6 +1272,12 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor case LogType.UserWarned: id = logSetting.LogWarnsId; break; + case LogType.ThreadCreated: + id = logSetting.ThreadCreatedId; + break; + case LogType.ThreadDeleted: + id = logSetting.ThreadDeletedId; + break; } if (id is null or 0) diff --git a/src/NadekoBot/Modules/Administration/ServerLog/ServerLogCommands.cs b/src/NadekoBot/Modules/Administration/ServerLog/ServerLogCommands.cs index 1ddba679c..a4bf6eee5 100644 --- a/src/NadekoBot/Modules/Administration/ServerLog/ServerLogCommands.cs +++ b/src/NadekoBot/Modules/Administration/ServerLog/ServerLogCommands.cs @@ -143,6 +143,12 @@ public partial class Administration return l.LogVoicePresenceTTSId; case LogType.UserMuted: return l.UserMutedId; + case LogType.UserWarned: + return l.LogWarnsId; + case LogType.ThreadDeleted: + return l.ThreadDeletedId; + case LogType.ThreadCreated: + return l.ThreadCreatedId; default: return null; } diff --git a/src/NadekoBot/Services/Impl/StatsService.cs b/src/NadekoBot/Services/Impl/StatsService.cs index 60889186a..e85fb0a6f 100644 --- a/src/NadekoBot/Services/Impl/StatsService.cs +++ b/src/NadekoBot/Services/Impl/StatsService.cs @@ -7,7 +7,7 @@ namespace NadekoBot.Services; public sealed class StatsService : IStatsService, IReadyExecutor, INService { - public const string BOT_VERSION = "4.3.15"; + public const string BOT_VERSION = "4.3.16"; public string Author => "Kwoth#2452"; From 775487ad476d23bc51a5b7fe7dc1ebfea2a92199 Mon Sep 17 00:00:00 2001 From: Amie Date: Fri, 30 Jun 2023 14:15:15 +0000 Subject: [PATCH 8/8] Added Trim() to activity names since apparently some activities have trailing spaces. --- src/NadekoBot/Modules/Utility/Utility.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index eb744ed92..825d576cf 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -94,7 +94,7 @@ public partial class Utility : NadekoModule var rng = new NadekoRandom(); var arr = await Task.Run(() => socketGuild.Users - .Where(u => u.Activities.FirstOrDefault()?.Name?.ToUpperInvariant() + .Where(u => u.Activities.FirstOrDefault()?.Name?.Trim().ToUpperInvariant() == game) .Select(u => u.Username) .OrderBy(_ => rng.Next()) @@ -639,4 +639,4 @@ public partial class Utility : NadekoModule else await ReplyConfirmLocalizedAsync(strs.verbose_errors_disabled); } -} \ No newline at end of file +}