diff --git a/CHANGELOG.md b/CHANGELOG.md index f20c301..82d9e1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,21 @@ *a,c,f,r,o* -## [6.0.7] - 18.03.2025 +## [6.0.8] - 19.03.2025 + +### Added + + - Live channel commands + - `.lcha` adds a channel with a template message (supports placeholders, and works on category channels too!) + - Every 10 minutes, channel name will be updated + - example: `.lcha #my-channel --> Members: %server.members% <--` will display the number of members in the server as a channel name, updating once every 10 minutes + - `.lchl` lists all live channels (Up to 5) + - `.lchd <channel or channelId>` removed a live channel + +### Fixed + - `.antispamignore` fixed + +## [6.0.7] - 19.03.2025 ### Added diff --git a/src/EllieBot/EllieBot.csproj b/src/EllieBot/EllieBot.csproj index f8ab19d..5ba587d 100644 --- a/src/EllieBot/EllieBot.csproj +++ b/src/EllieBot/EllieBot.csproj @@ -4,7 +4,7 @@ <Nullable>enable</Nullable> <ImplicitUsings>true</ImplicitUsings> <SatelliteResourceLanguages>en</SatelliteResourceLanguages> - <Version>6.0.7</Version> + <Version>6.0.8</Version> <!-- Output/build --> <RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> diff --git a/src/EllieBot/Modules/Administration/Mute/MuteService.cs b/src/EllieBot/Modules/Administration/Mute/MuteService.cs index 62cc216..777bff4 100644 --- a/src/EllieBot/Modules/Administration/Mute/MuteService.cs +++ b/src/EllieBot/Modules/Administration/Mute/MuteService.cs @@ -1,4 +1,5 @@ #nullable disable +using System.Net; using LinqToDB; using LinqToDB.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; @@ -248,23 +249,21 @@ public class MuteService : IEService, IReadyExecutor { ArgumentNullException.ThrowIfNull(guild); - const string defaultMuteRoleName = "nadeko-mute"; + const string defaultMuteRoleName = "ellie-mute"; var muteRoleName = _guildMuteRoles.GetOrAdd(guild.Id, defaultMuteRoleName); var muteRole = guild.Roles.FirstOrDefault(r => r.Name == muteRoleName); if (muteRole is null) - //if it doesn't exist, create it { try { muteRole = await guild.CreateRoleAsync(muteRoleName, isMentionable: false); } - catch + catch (Exception ex) { - //if creations fails, maybe the name is not correct, find default one, if doesn't work, create default one - muteRole = guild.Roles.FirstOrDefault(r => r.Name == muteRoleName) - ?? await guild.CreateRoleAsync(defaultMuteRoleName, isMentionable: false); + Log.Warning(ex, "Unable to create mute role for guild {GuildId}", guild.Id); + return null; } } @@ -280,9 +279,10 @@ public class MuteService : IEService, IReadyExecutor await Task.Delay(200); } } - catch + catch (HttpException ex) when (ex.DiscordCode == DiscordErrorCode.MissingPermissions) { - // ignored + Log.Error(ex, "Error in Initializing mute role in guild {GuildId}: {Message}", guild.Id, ex.Message); + break; } } diff --git a/src/EllieBot/Modules/Administration/Protection/ProtectionCommands.cs b/src/EllieBot/Modules/Administration/Protection/ProtectionCommands.cs index d0f8d7e..eb99631 100644 --- a/src/EllieBot/Modules/Administration/Protection/ProtectionCommands.cs +++ b/src/EllieBot/Modules/Administration/Protection/ProtectionCommands.cs @@ -143,9 +143,9 @@ public partial class Administration return; await Response() - .Confirm(GetText(strs.prot_enable("Anti-Raid")), - $"{ctx.User.Mention} {GetAntiRaidString(stats)}") - .SendAsync(); + .Confirm(GetText(strs.prot_enable("Anti-Raid")), + $"{ctx.User.Mention} {GetAntiRaidString(stats)}") + .SendAsync(); } [Cmd] @@ -213,9 +213,9 @@ public partial class Administration var stats = await _service.StartAntiSpamAsync(ctx.Guild.Id, messageCount, action, time, role?.Id); await Response() - .Confirm(GetText(strs.prot_enable("Anti-Spam")), - $"{ctx.User.Mention} {GetAntiSpamString(stats)}") - .SendAsync(); + .Confirm(GetText(strs.prot_enable("Anti-Spam")), + $"{ctx.User.Mention} {GetAntiSpamString(stats)}") + .SendAsync(); } [Cmd] diff --git a/src/EllieBot/Modules/Administration/Protection/ProtectionService.cs b/src/EllieBot/Modules/Administration/Protection/ProtectionService.cs index 938ca9a..a6716e8 100644 --- a/src/EllieBot/Modules/Administration/Protection/ProtectionService.cs +++ b/src/EllieBot/Modules/Administration/Protection/ProtectionService.cs @@ -10,7 +10,7 @@ namespace EllieBot.Modules.Administration.Services; public class ProtectionService : IReadyExecutor, IEService { - public event Func<PunishmentAction, ProtectionType, IGuildUser[], Task> OnAntiProtectionTriggered = delegate + public event Func<PunishmentAction, ProtectionType, IGuildUser[], Task> OnAntiProtectionTriggered = static delegate { return Task.CompletedTask; }; @@ -301,7 +301,7 @@ public class ProtectionService : IReadyExecutor, IEService { if (_antiRaidGuilds.TryRemove(guildId, out _)) { - using var uow = _db.GetDbContext(); + await using var uow = _db.GetDbContext(); await uow.GetTable<AntiRaidSetting>() .Where(x => x.GuildId == guildId) .DeleteAsync(); @@ -316,7 +316,7 @@ public class ProtectionService : IReadyExecutor, IEService { if (_antiSpamGuilds.TryRemove(guildId, out _)) { - using var uow = _db.GetDbContext(); + await using var uow = _db.GetDbContext(); await uow.GetTable<AntiSpamSetting>() .Where(x => x.GuildId == guildId) .DeleteAsync(); @@ -335,7 +335,9 @@ public class ProtectionService : IReadyExecutor, IEService ulong? roleId) { var g = _client.GetGuild(guildId); - await _mute.GetMuteRole(g); + + if (action == PunishmentAction.Mute) + await _mute.GetMuteRole(g); if (!IsDurationAllowed(action)) punishDurationMinutes = 0; @@ -391,7 +393,7 @@ public class ProtectionService : IReadyExecutor, IEService }; await using var uow = _db.GetDbContext(); - var spam = await uow.GetTable<AntiSpamSetting>() + var spam = await uow.Set<AntiSpamSetting>() .Include(x => x.IgnoredChannels) .Where(x => x.GuildId == guildId) .FirstOrDefaultAsyncEF(); diff --git a/src/EllieBot/Modules/Utility/LiveChannel/LiveChannelCommands.cs b/src/EllieBot/Modules/Utility/LiveChannel/LiveChannelCommands.cs index a4b0cd5..3c3b7b5 100644 --- a/src/EllieBot/Modules/Utility/LiveChannel/LiveChannelCommands.cs +++ b/src/EllieBot/Modules/Utility/LiveChannel/LiveChannelCommands.cs @@ -22,15 +22,17 @@ public partial class Utility var eb = CreateEmbed() .WithOkColor() .WithDescription(GetText(strs.livechannel_added(channel.Name))) - .AddField(GetText(strs.template), template) + .AddField(GetText(strs.template), template, true) .AddField(GetText(strs.preview), await repSvc.ReplaceAsync(template, new( client: ctx.Client as DiscordSocketClient, guild: ctx.Guild - ))); + )), + true) + .WithFooter(GetText(strs.livechannel_please_wait)); await Response() - .Confirm(strs.livechannel_added(channel.Name)) + .Embed(eb) .SendAsync(); return; } diff --git a/src/EllieBot/Modules/Utility/LiveChannel/LiveChannelService.cs b/src/EllieBot/Modules/Utility/LiveChannel/LiveChannelService.cs index c2cd9d9..e2df525 100644 --- a/src/EllieBot/Modules/Utility/LiveChannel/LiveChannelService.cs +++ b/src/EllieBot/Modules/Utility/LiveChannel/LiveChannelService.cs @@ -83,7 +83,9 @@ public class LiveChannelService( if (channel.Name != text) await channel.ModifyAsync(x => x.Name = text); } - catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.Forbidden) + catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.Forbidden + || ex.DiscordCode == DiscordErrorCode.MissingPermissions + || ex.HttpCode == HttpStatusCode.NotFound) { await RemoveLiveChannelAsync(config.GuildId, config.ChannelId); Log.Warning( diff --git a/src/EllieBot/strings/responses/responses.en-US.json b/src/EllieBot/strings/responses/responses.en-US.json index 1021251..8346ad8 100644 --- a/src/EllieBot/strings/responses/responses.en-US.json +++ b/src/EllieBot/strings/responses/responses.en-US.json @@ -1230,6 +1230,7 @@ "livechannel_not_found": "Channel was not found in the live channels list.", "livechannel_list_title": "Live Channels in {0}", "livechannel_list_empty": "No live channels configured for this server.", + "livechannel_please_wait": "Please allow up to 10 minutes for the changes to take effect", "template": "Template", "preview": "Preview" } \ No newline at end of file