diff --git a/SahneeBot/CHANGELOG.md b/SahneeBot/CHANGELOG.md index f64ccf7..569ccba 100644 --- a/SahneeBot/CHANGELOG.md +++ b/SahneeBot/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## 1.0.1 + +The Sahnee-Bot is currently generating an increased amount of errors related to changelog permissions. +Functionality may be impacted while we work on a solution. Thank you for your patience. + ## 1.0.0 Sahnee-Bot 1.0.0 is a complete rewrite of the Sahnee-Bot using the new Discord slash commands, with a more modern and stable architecture that will allow us to implement even more & better features in the future! diff --git a/SahneeBot/SahneeBotDiscordError.cs b/SahneeBot/SahneeBotDiscordError.cs index 640419c..e686e0e 100644 --- a/SahneeBot/SahneeBotDiscordError.cs +++ b/SahneeBot/SahneeBotDiscordError.cs @@ -107,13 +107,6 @@ private ISuccess GetMissingRolePermissionsError(string prefix) { var inviteUrl = _cfg["BotSettings:InviteUrl"]; return new Error("The Sahnee-Bot does not have enough permissions on your server.\n" + - "-----------------\n" + - $"**Due to the update of the Sahnee-Bot on {_release.StartedAt.ToShortDateString()} " + - "the bot does not have all permissions required.\n" + - $"Please kick the bot and re-invite it using [this link]({inviteUrl}).**\n" + - "**Please note that since a lot of people are currently updating the bot you may need to " + - "wait a minute or two after the bot has been invited for commands to appear. If nothing " + - "happens after 15 minutes feel free to join the support server.**\n" + "-----------------\n" + "Please drag the Sahnee-Bot role above all other roles starting with " + $"\"{prefix.TrimEnd()}\" in your Server Settings and make sure that it has the \"Manage " + diff --git a/SahneeBot/Tasks/SahneeBotPostChangelogsToGuildTask.cs b/SahneeBot/Tasks/SahneeBotPostChangelogsToGuildTask.cs index f08e70a..9cd7f98 100644 --- a/SahneeBot/Tasks/SahneeBotPostChangelogsToGuildTask.cs +++ b/SahneeBot/Tasks/SahneeBotPostChangelogsToGuildTask.cs @@ -1,4 +1,5 @@ -using SahneeBot.Formatter; +using Microsoft.Extensions.Logging; +using SahneeBot.Formatter; using SahneeBotController; using SahneeBotController.Tasks; @@ -11,23 +12,27 @@ public class SahneeBotPostChangelogsToGuildTask : PostChangelogsToGuildTask private readonly Bot _bot; private readonly SahneeBotDiscordError _discordError; private readonly GetBoundChannelTask _boundChannelTask; + private readonly ILogger _logger; public SahneeBotPostChangelogsToGuildTask(Changelog changelog , ChangelogVersionDiscordFormatter fmt , GetBoundChannelTask boundChannelTask , Bot bot - , SahneeBotDiscordError discordError) + , SahneeBotDiscordError discordError + , ILogger logger) { _changelog = changelog; _fmt = fmt; _bot = bot; _discordError = discordError; + _logger = logger; _boundChannelTask = boundChannelTask; } public override async Task> Execute(ITaskContext ctx, Args arg) { var (guildId, enumerable) = arg; + _logger.LogDebug("Will now send changelogs to guild {Guild}", guildId); var set = new HashSet(enumerable); var changelogs = _changelog.Versions .Where(v => set.Contains(v.Version)) @@ -36,6 +41,7 @@ public override async Task> Execute(ITaskContext ctx, Args arg) var guild = await _bot.Client.GetGuildAsync(guildId); if (guild == null) { + _logger.LogWarning("Could not found the guild {GuildId}", guildId); return new Error("Could not find the server."); } @@ -44,6 +50,7 @@ public override async Task> Execute(ITaskContext ctx, Args arg) : await guild.GetDefaultChannelAsync(); if (channel == null) { + _logger.LogWarning("Could not find a channel to post the changelogs in {GuildId}", guildId); return new Error("Could not find a channel to post the changelogs in."); } @@ -51,13 +58,18 @@ public override async Task> Execute(ITaskContext ctx, Args arg) { if (await _fmt.FormatAndSendMany(changelogs, channel.SendMessageAsync)) { + _logger.LogDebug("Sent the changelog to guild {Guild}", guildId); return new Success((uint) changelogs.Count); } } catch(Exception exception) { - var error = await _discordError.TryGetError( - ctx, new SahneeBotDiscordError.ErrorOptions {Exception = exception, GuildId = guildId}); + _logger.LogWarning(exception, "Failed to post changelogs in guild {Guild} due to error", guildId); + var error = await _discordError.TryGetError(ctx + , new SahneeBotDiscordError.ErrorOptions { + Exception = exception + , GuildId = guildId + }); if (error != null) { return error; @@ -66,6 +78,7 @@ public override async Task> Execute(ITaskContext ctx, Args arg) throw; } + _logger.LogDebug("No changelogs to post to {Guild}", guildId); return new Error("No changelogs to post."); } -} \ No newline at end of file +} diff --git a/SahneeBotController/Tasks/UpdateGuildChangelogTask.cs b/SahneeBotController/Tasks/UpdateGuildChangelogTask.cs index 5642630..75b0499 100644 --- a/SahneeBotController/Tasks/UpdateGuildChangelogTask.cs +++ b/SahneeBotController/Tasks/UpdateGuildChangelogTask.cs @@ -50,7 +50,7 @@ protected UpdateGuildChangelogTask(IServiceProvider provider) if (!post.IsSuccess) { _logger.LogWarning(EventIds.Changelog - , "Failed to post warnings to guild {Guild}: {Error}" + , "Failed to post changelog to guild {Guild}: {Error}" , arg.GuildId, post.Message); success = new Error(post.Message); }