mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-19 16:33:36 +03:00
correct comments, get rid of "else"s
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
c8fbb65dc2
commit
2fbd1a6a20
5 changed files with 38 additions and 46 deletions
|
@ -100,9 +100,8 @@ public class ClearCommandGroup : CommandGroup
|
|||
{
|
||||
var idList = new List<Snowflake>(messages.Count);
|
||||
var builder = new StringBuilder().AppendLine(Mention.Channel(channelId)).AppendLine();
|
||||
for (var i = messages.Count - 1; i >= 1; i--)
|
||||
for (var i = messages.Count - 1; i >= 1; i--) // '>= 1' to skip last message ('Boyfriend is thinking...')
|
||||
{
|
||||
// '>= 1' to skip last message ('Boyfriend is thinking...')
|
||||
var message = messages[i];
|
||||
idList.Add(message.ID);
|
||||
builder.AppendLine(string.Format(Messages.MessageFrom, Mention.User(message.Author)));
|
||||
|
|
|
@ -105,39 +105,37 @@ public class SettingsCommandGroup : CommandGroup
|
|||
|
||||
if (firstOptionOnPage >= AllOptions.Length)
|
||||
{
|
||||
var embed = new EmbedBuilder().WithSmallTitle(Messages.PageNotFound, currentUser)
|
||||
var errorEmbed = new EmbedBuilder().WithSmallTitle(Messages.PageNotFound, currentUser)
|
||||
.WithDescription(string.Format(Messages.PagesAllowed, Markdown.Bold(totalPages.ToString())))
|
||||
.WithColour(ColorsList.Red)
|
||||
.Build();
|
||||
|
||||
return await _feedback.SendContextualEmbedResultAsync(embed, ct);
|
||||
return await _feedback.SendContextualEmbedResultAsync(errorEmbed, ct);
|
||||
}
|
||||
else
|
||||
|
||||
footer.Append($"{Messages.Page} {page}/{totalPages} ");
|
||||
for (var i = 0; i < totalPages; i++)
|
||||
{
|
||||
footer.Append($"{Messages.Page} {page}/{totalPages} ");
|
||||
for (var i = 0; i < totalPages; i++)
|
||||
{
|
||||
footer.Append(i + 1 == page ? "●" : "○");
|
||||
}
|
||||
|
||||
for (var i = firstOptionOnPage; i < lastOptionOnPage; i++)
|
||||
{
|
||||
var optionName = AllOptions[i].Name;
|
||||
var optionValue = AllOptions[i].Display(cfg);
|
||||
|
||||
description.AppendLine($"- {$"Settings{optionName}".Localized()}")
|
||||
.Append($" - {Markdown.InlineCode(optionName)}: ")
|
||||
.AppendLine(optionValue);
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder().WithSmallTitle(Messages.SettingsListTitle, currentUser)
|
||||
.WithDescription(description.ToString())
|
||||
.WithColour(ColorsList.Default)
|
||||
.WithFooter(footer.ToString())
|
||||
.Build();
|
||||
|
||||
return await _feedback.SendContextualEmbedResultAsync(embed, ct);
|
||||
footer.Append(i + 1 == page ? "●" : "○");
|
||||
}
|
||||
|
||||
for (var i = firstOptionOnPage; i < lastOptionOnPage; i++)
|
||||
{
|
||||
var optionName = AllOptions[i].Name;
|
||||
var optionValue = AllOptions[i].Display(cfg);
|
||||
|
||||
description.AppendLine($"- {$"Settings{optionName}".Localized()}")
|
||||
.Append($" - {Markdown.InlineCode(optionName)}: ")
|
||||
.AppendLine(optionValue);
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder().WithSmallTitle(Messages.SettingsListTitle, currentUser)
|
||||
.WithDescription(description.ToString())
|
||||
.WithColour(ColorsList.Default)
|
||||
.WithFooter(footer.ToString())
|
||||
.Build();
|
||||
|
||||
return await _feedback.SendContextualEmbedResultAsync(embed, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -35,9 +35,9 @@ public class GuildLoadedResponder : IResponder<IGuildCreate>
|
|||
|
||||
public async Task<Result> RespondAsync(IGuildCreate gatewayEvent, CancellationToken ct = default)
|
||||
{
|
||||
if (!gatewayEvent.Guild.IsT0)
|
||||
if (!gatewayEvent.Guild.IsT0) // Guild is not IAvailableGuild
|
||||
{
|
||||
return Result.FromSuccess(); // Guild is not IAvailableGuild
|
||||
return Result.FromSuccess();
|
||||
}
|
||||
|
||||
var guild = gatewayEvent.Guild.AsT0;
|
||||
|
|
|
@ -165,8 +165,10 @@ public sealed partial class GuildUpdateService : BackgroundService
|
|||
if (!eventsResult.IsSuccess)
|
||||
{
|
||||
_logger.LogWarning("Error retrieving scheduled events.\n{ErrorMessage}", eventsResult.Error.Message);
|
||||
return;
|
||||
}
|
||||
else if (!GuildSettings.EventNotificationChannel.Get(data.Settings).Empty())
|
||||
|
||||
if (!GuildSettings.EventNotificationChannel.Get(data.Settings).Empty())
|
||||
{
|
||||
await TickScheduledEventsAsync(guildId, data, eventsResult.Entity, ct);
|
||||
}
|
||||
|
@ -272,15 +274,14 @@ public sealed partial class GuildUpdateService : BackgroundService
|
|||
{
|
||||
var unbanResult = await _guildApi.RemoveGuildBanAsync(
|
||||
guildId, user.ID, Messages.PunishmentExpired.EncodeHeader(), ct);
|
||||
if (unbanResult.IsSuccess)
|
||||
{
|
||||
memberData.BannedUntil = null;
|
||||
}
|
||||
else
|
||||
if (!unbanResult.IsSuccess)
|
||||
{
|
||||
_logger.LogWarning(
|
||||
"Error in automatic user unban request.\n{ErrorMessage}", unbanResult.Error.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
memberData.BannedUntil = null;
|
||||
}
|
||||
|
||||
for (var i = memberData.Reminders.Count - 1; i >= 0; i--)
|
||||
|
@ -307,8 +308,10 @@ public sealed partial class GuildUpdateService : BackgroundService
|
|||
{
|
||||
characterList.Remove(character);
|
||||
usernameChanged = true;
|
||||
continue;
|
||||
}
|
||||
else { break; }
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!usernameChanged)
|
||||
|
|
|
@ -180,15 +180,7 @@ public sealed class UtilityService : IHostedService
|
|||
}
|
||||
|
||||
builder = users.Where(
|
||||
user =>
|
||||
{
|
||||
if (!user.GuildMember.IsDefined(out var member))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return !member.Roles.Contains(role);
|
||||
})
|
||||
user => user.GuildMember.IsDefined(out var member) && !member.Roles.Contains(role))
|
||||
.Aggregate(builder, (current, user) => current.Append($"{Mention.User(user.User)} "));
|
||||
return builder.ToString();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue