Skip to content

Commit

Permalink
chore: run codecleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanpth committed Sep 27, 2024
1 parent b46ea1f commit eeee802
Show file tree
Hide file tree
Showing 28 changed files with 189 additions and 189 deletions.
34 changes: 17 additions & 17 deletions src/AdvancedBot.Core/BotClient.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using Discord;
using Discord.WebSocket;
using AdvancedBot.Core.Services.DataStorage;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;
using AdvancedBot.Core.Commands;
using AdvancedBot.Core.Commands;
using AdvancedBot.Core.Entities;
using AdvancedBot.Core.Services;
using AdvancedBot.Core.Services.DataStorage;
using Discord;
using Discord.Interactions;
using System.Reflection;
using AdvancedBot.Core.Entities;
using Discord.WebSocket;
using GL.NET;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;

namespace AdvancedBot.Core
{
Expand Down Expand Up @@ -38,11 +38,11 @@ public BotClient(CustomCommandService commands = null, DiscordSocketClient clien
LogLevel = LogSeverity.Info,
BotInviteIsPrivate = false,
RepositoryUrl = "https://github.com/Galaxy-Life/DiscordBot",
#if DEBUG
#if DEBUG
LogChannelId = 697920194559082547
#else
#else
LogChannelId = 1090274237572468796
#endif
#endif
});

_interactions = new InteractionService(_client.Rest, new InteractionServiceConfig() { UseCompiledLambda = true });
Expand Down Expand Up @@ -97,13 +97,13 @@ private async Task OnReadyAsync()
Console.WriteLine($"Modules count: {_interactions.Modules.Count}");
Console.WriteLine($"SlashCommands count: {_interactions.SlashCommands.Count}");

#if DEBUG
Console.WriteLine("Registered all commands to test server");
await _interactions.RegisterCommandsToGuildAsync(696343127144923158, false);
#else
#if DEBUG
Console.WriteLine("Registered all commands to test server");
await _interactions.RegisterCommandsToGuildAsync(696343127144923158, false);
#else
Console.WriteLine("Registered all commands globally");
await _interactions.RegisterCommandsGloballyAsync();
#endif
#endif

_client.InteractionCreated += async (x) =>
{
Expand Down
16 changes: 8 additions & 8 deletions src/AdvancedBot.Core/Commands/CustomCommandService.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AdvancedBot.Core.Services;
using Discord;
using Discord.Commands;
using Humanizer;
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AdvancedBot.Core.Commands
{
Expand All @@ -30,9 +30,9 @@ public CustomCommandService(CustomCommandServiceConfig config) : base(config)
}

public async Task SendBotInfoAsync(IInteractionContext context)
{
{
var botName = context.Client.CurrentUser.Username;
var botAvatar = context.Client.CurrentUser.GetDisplayAvatarUrl();
var botAvatar = context.Client.CurrentUser.GetDisplayAvatarUrl();

var repoLink = string.IsNullOrEmpty(_sourceRepo) ? $"Unavailable" : $"[GitHub repository]({_sourceRepo})";
var docsLink = string.IsNullOrEmpty(_documentationUrl) ? $"Unavailable" : $"[Read the docs]({_documentationUrl})";
Expand Down Expand Up @@ -79,10 +79,10 @@ public static string GenerateCommandUsage(CommandInfo command, string prefix)
{
var pref = command.Parameters[i].IsOptional ? "[" : "<";
var suff = command.Parameters[i].IsOptional ? "]" : ">";

parameters.Append($"{pref}{command.Parameters[i].Name.Underscore().Dasherize()}{suff} ");
}

return $"{prefix}{command.Aliases[0]} {parameters}";
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/AdvancedBot.Core/Commands/Modules/ChannelInfoModule.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Threading.Tasks;
using AdvancedBot.Core.Commands.Preconditions;
using AdvancedBot.Core.Entities;
using AdvancedBot.Core.Entities.Enums;
using AdvancedBot.Core.Services;
using Discord;
using Discord.Interactions;
using System;
using System.Threading.Tasks;

namespace AdvancedBot.Core.Commands.Modules
{
Expand All @@ -20,11 +20,11 @@ public ChannelInfoModule(ChannelCounterService counter)
_counter = counter;
}

[SlashCommand("setup", "Set up the channel counter")]
[RequireBotPermission(GuildPermission.ManageChannels)]
[RequireBotPermission(GuildPermission.ManageRoles)]
[CommandContextType(InteractionContextType.Guild, InteractionContextType.PrivateChannel)]
public async Task SetupChannelCountersAsync()
[SlashCommand("setup", "Set up the channel counter")]
[RequireBotPermission(GuildPermission.ManageChannels)]
[RequireBotPermission(GuildPermission.ManageRoles)]
[CommandContextType(InteractionContextType.Guild, InteractionContextType.PrivateChannel)]
public async Task SetupChannelCountersAsync()
{
var voiceChannel = await Context.Guild.CreateVoiceChannelAsync($"Server Status");
await voiceChannel.AddPermissionOverwriteAsync(Context.Client.CurrentUser, new OverwritePermissions(connect: PermValue.Allow));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
using AdvancedBot.Core.Services;
using Discord.Interactions;
using System.Threading.Tasks;

namespace AdvancedBot.Core.Commands.Modules
{
Expand Down
12 changes: 6 additions & 6 deletions src/AdvancedBot.Core/Commands/Modules/DevModule.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AdvancedBot.Core.Commands.Preconditions;
using AdvancedBot.Core.Entities;
using Discord;
using Discord.Interactions;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AdvancedBot.Core.Commands.Modules
{
Expand All @@ -20,7 +20,7 @@ public DevModule(InteractionService interactions)
}

[SlashCommand("allstats", "Shows combined stats from all servers")]
public async Task ShowAllStatsAsync([Choice("All", "all"), Choice("Dms", "dms"), Choice("Guilds", "guilds")]string type)
public async Task ShowAllStatsAsync([Choice("All", "all"), Choice("Dms", "dms"), Choice("Guilds", "guilds")] string type)
{
Account[] accounts;

Expand Down Expand Up @@ -52,7 +52,7 @@ public async Task ShowAllStatsAsync([Choice("All", "all"), Choice("Dms", "dms"),

var templateEmbed = new EmbedBuilder()
.WithTitle(title);

await SendPaginatedMessageAsync(fields, null, templateEmbed);
}

Expand All @@ -61,7 +61,7 @@ public async Task ShowAllStatsAsync([Choice("All", "all"), Choice("Dms", "dms"),
public async Task AddModerationModuleToGuildAsync(string guildId, string modulename)
{
var module = _interactions.Modules.First(module => module.Name.ToLower() == modulename.ToLower());

if (module == null)
{
await ModifyOriginalResponseAsync(msg => msg.Content = $"Could not find any module named **{modulename}**.");
Expand Down
54 changes: 27 additions & 27 deletions src/AdvancedBot.Core/Commands/Modules/GLModule.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Discord;
using AdvancedBot.Core.Services;
using Discord;
using Discord.Interactions;
using GL.NET.Entities;
using System;
using System.Threading.Tasks;
using System.Linq;
using System.Collections.Generic;
using AdvancedBot.Core.Services;
using GL.NET.Entities;
using System.Linq;
using System.Threading.Tasks;

namespace AdvancedBot.Core.Commands.Modules
{
Expand All @@ -18,9 +18,9 @@ public async Task DisplayServerStatusAsync()
{
var status = await GLClient.Api.GetServerStatus();

var thumbnailUrl =
Context.Channel is IGuildChannel
? Context.Guild.IconUrl
var thumbnailUrl =
Context.Channel is IGuildChannel
? Context.Guild.IconUrl
: Context.Client.CurrentUser.GetDisplayAvatarUrl();

var embed = new EmbedBuilder()
Expand Down Expand Up @@ -57,7 +57,7 @@ public async Task ShowUserProfileAsync(string input = "")
[SlashCommand("stats", "Displays a user's Galaxy Life stats")]
public async Task ShowUserStatsAsync(string input = "")
{
var response = await GLService.GetUserStatsAsync(string.IsNullOrEmpty(input) ? Context.User.Username : input);
var response = await GLService.GetUserStatsAsync(string.IsNullOrEmpty(input) ? Context.User.Username : input);
await SendResponseMessage(response.Message, false);

// no gl data found
Expand Down Expand Up @@ -97,19 +97,19 @@ public async Task ShowAllianceMembersAsync(string input)

[SlashCommand("lb", "Retrieve a specific statistic leaderboard")]
public async Task GetLeaderboardAsync([
Choice("Experience", "xp"),
Choice("Experience from attacks", "attackXp"),
Choice("Rivals", "rivalsWon"),
Choice("Warpoints", "warpoints"),
Choice("Experience", "xp"),
Choice("Experience from attacks", "attackXp"),
Choice("Rivals", "rivalsWon"),
Choice("Warpoints", "warpoints"),
Choice("Alliances", "alliancewarpoints")
] string type)
{
List<string> displayTexts = new() { "Failed to get information" };
var title = "Galaxy Life Leaderboard";

var thumbnailUrl =
Context.Channel is IGuildChannel
? Context.Guild.IconUrl
var thumbnailUrl =
Context.Channel is IGuildChannel
? Context.Guild.IconUrl
: Context.Client.CurrentUser.GetDisplayAvatarUrl();

switch (type)
Expand Down Expand Up @@ -159,8 +159,8 @@ Context.Channel is IGuildChannel
}

await SendPaginatedMessageAsync(
null,
displayTexts,
null,
displayTexts,
new EmbedBuilder()
.WithTitle($"Leaderboard | {title}")
.WithColor(Color.Purple)
Expand All @@ -169,7 +169,7 @@ await SendPaginatedMessageAsync(
.WithText($"Leaderboard requested by {Context.User.Username}#{Context.User.Discriminator}")
.WithIconUrl(Context.User.GetDisplayAvatarUrl()))
.WithCurrentTimestamp()

);
}

Expand Down Expand Up @@ -197,9 +197,9 @@ public async Task CompareUsersAsync(string firstPlayer, string secondPlayer)
return;
}

var thumbnailUrl =
Context.Channel is IGuildChannel
? Context.Guild.IconUrl
var thumbnailUrl =
Context.Channel is IGuildChannel
? Context.Guild.IconUrl
: Context.Client.CurrentUser.GetDisplayAvatarUrl();

var baseUserStats = await GLClient.Api.GetUserStats(baseUser.Id);
Expand Down Expand Up @@ -231,11 +231,11 @@ private static string FormatNumber(decimal number)
return number switch
{
>= 1_000_000_000 => $"{Math.Round(number / 1_000_000_000, 2)}B",
>= 10_000_000 => $"{Math.Round(number / 1_000_000, 1)}M",
>= 1_000_000 => $"{Math.Round(number / 1_000_000, 2)}M",
>= 100_000 => $"{Math.Round(number / 1_000, 1)}K",
>= 10_000 => $"{Math.Round(number / 1_000, 2)}K",
_ => number.ToString()
>= 10_000_000 => $"{Math.Round(number / 1_000_000, 1)}M",
>= 1_000_000 => $"{Math.Round(number / 1_000_000, 2)}M",
>= 100_000 => $"{Math.Round(number / 1_000, 1)}K",
>= 10_000 => $"{Math.Round(number / 1_000, 2)}K",
_ => number.ToString()
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/AdvancedBot.Core/Commands/Modules/InfoModule.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Discord;
using Discord.Interactions;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Discord;
using Discord.Interactions;

namespace AdvancedBot.Core.Commands.Modules
{
Expand Down
Loading

0 comments on commit eeee802

Please sign in to comment.