diff --git a/libs/DSharpPlus b/libs/DSharpPlus index 2f84b9c..35b698d 160000 --- a/libs/DSharpPlus +++ b/libs/DSharpPlus @@ -1 +1 @@ -Subproject commit 2f84b9c6376635112b62bf7cd95599ee350e91db +Subproject commit 35b698de2d0ec3e99d6bfdd0bfb2ee4ca92fbc10 diff --git a/libs/XMLDocs.NET b/libs/XMLDocs.NET index 29c0af6..922f5a7 160000 --- a/libs/XMLDocs.NET +++ b/libs/XMLDocs.NET @@ -1 +1 @@ -Subproject commit 29c0af6153a532ab5a0cb055f75f2f08a19725eb +Subproject commit 922f5a78866cafb7f744e4a9e3fea897c03af96f diff --git a/src/Commands/Common/InfoCommand/InfoCommand.Bot.cs b/src/Commands/Common/InfoCommand/InfoCommand.Bot.cs index 5ddd3b6..7db0563 100644 --- a/src/Commands/Common/InfoCommand/InfoCommand.Bot.cs +++ b/src/Commands/Common/InfoCommand/InfoCommand.Bot.cs @@ -51,7 +51,7 @@ public async ValueTask BotInfoAsync(CommandContext context) embedBuilder.AddField("Operating System", _operatingSystem, true); embedBuilder.AddField("Uptime", _getLastCommaRegex().Replace((Process.GetCurrentProcess().StartTime - DateTime.Now).Humanize(3), " and "), true); - embedBuilder.AddField("Discord Latency", _getLastCommaRegex().Replace(context.Client.Ping.Milliseconds().Humanize(3), " and "), true); + embedBuilder.AddField("Discord Latency", _getLastCommaRegex().Replace(context.Client.GetConnectionLatency(context.Guild?.Id ?? 0).Humanize(3), " and "), true); embedBuilder.AddField("Guild Count", (await GuildMemberModel.CountGuildsAsync()).ToString("N0", CultureInfo.InvariantCulture), true); embedBuilder.AddField("User Count", (await GuildMemberModel.CountMembersAsync()).ToString("N0", CultureInfo.InvariantCulture), true); diff --git a/src/Commands/Common/PingCommand.cs b/src/Commands/Common/PingCommand.cs index 65d8233..c153468 100644 --- a/src/Commands/Common/PingCommand.cs +++ b/src/Commands/Common/PingCommand.cs @@ -2,6 +2,7 @@ using DSharpPlus.Commands; using DSharpPlus.Commands.Trees; using DSharpPlus.Commands.Trees.Metadata; +using Humanizer; namespace OoLunar.Tomoe.Commands.Common { @@ -14,6 +15,6 @@ public static class PingCommand /// Sends the latency of the bot's connection to Discord. /// [Command("ping"), TextAlias("pong")] - public static ValueTask ExecuteAsync(CommandContext context) => context.RespondAsync($"Pong! Latency is {context.Client.Ping}ms."); + public static ValueTask ExecuteAsync(CommandContext context) => context.RespondAsync($"Pong! Latency is {context.Client.GetConnectionLatency(context.Guild?.Id ?? 0).Humanize(3)}."); } } diff --git a/src/Database/Models/PollModel.cs b/src/Database/Models/PollModel.cs index a6aab49..d806207 100644 --- a/src/Database/Models/PollModel.cs +++ b/src/Database/Models/PollModel.cs @@ -181,7 +181,7 @@ public static async ValueTask PrepareAsync(NpgsqlConnection connection) public static async ValueTask ExpireAsync(PollModel expirable, IServiceProvider serviceProvider) { - DiscordClient? client = serviceProvider.GetRequiredService().GetShard(expirable.GuildId); + DiscordClient? client = serviceProvider.GetRequiredService(); if (client is null) { return await PollEndedAsync(expirable.Id); diff --git a/src/Database/Models/ReminderModel.cs b/src/Database/Models/ReminderModel.cs index 25ce20b..851fbb8 100644 --- a/src/Database/Models/ReminderModel.cs +++ b/src/Database/Models/ReminderModel.cs @@ -237,27 +237,25 @@ public static async ValueTask PrepareAsync(NpgsqlConnection connection) public static async ValueTask ExpireAsync(ReminderModel expirable, IServiceProvider serviceProvider) { - DiscordShardedClient? shardedClient = serviceProvider.GetRequiredService(); - if (shardedClient is null) + DiscordClient? client = serviceProvider.GetRequiredService(); + if (client is null) { // If this happens we'll have much bigger problems but // Don't remove the reminder from the database. return false; } - // Since we're not manually sharding, client should never be null as the shard is calculated from the guild id. - DiscordClient? client = shardedClient.GetShard(expirable.GuildId); - if (client is null || expirable.GuildId == 0 || !client.Guilds.TryGetValue(expirable.GuildId, out DiscordGuild? guild) || guild.IsUnavailable) + if (expirable.GuildId == 0 || !client.Guilds.TryGetValue(expirable.GuildId, out DiscordGuild? guild) || guild.IsUnavailable) { // If it does though, try finding the user through a separate guild and DM'ing them. - return await DmUserAsync(shardedClient, expirable); + return await DmUserAsync(client, expirable); } // Make sure the user is still in the guild. GuildMemberModel? memberModel = await GuildMemberModel.FindMemberAsync(expirable.UserId, guild.Id); if (memberModel is null || memberModel.State.HasFlag(GuildMemberState.Absent) || !guild.Channels.TryGetValue(expirable.ChannelId, out DiscordChannel? channel)) { - return await DmUserAsync(shardedClient, expirable); + return await DmUserAsync(client, expirable); } // If the reminder was sent in a thread, try to send the reminder in the thread. @@ -271,7 +269,7 @@ public static async ValueTask ExpireAsync(ReminderModel expirable, IServic if (await client.GetChannelAsync(expirable.ThreadId) is not DiscordThreadChannel threadChannel || threadChannel.ThreadMetadata.IsLocked.GetValueOrDefault()) { - return await DmUserAsync(shardedClient, expirable); + return await DmUserAsync(client, expirable); } channel = threadChannel; @@ -287,14 +285,14 @@ public static async ValueTask ExpireAsync(ReminderModel expirable, IServic if ((!channel.IsThread && !channelPermissionsForBot.HasPermission(DiscordPermissions.SendMessages)) || (channel.IsThread && !channelPermissionsForBot.HasPermission(DiscordPermissions.SendMessagesInThreads))) { - return await DmUserAsync(shardedClient, expirable); + return await DmUserAsync(client, expirable); } await channel.SendMessageAsync(CreateReminderMessage(expirable, expirable.GuildId)); return true; } - private static async ValueTask DmUserAsync(DiscordShardedClient shardedClient, ReminderModel reminderModel) + private static async ValueTask DmUserAsync(DiscordClient client, ReminderModel reminderModel) { IReadOnlyList guildIds = await GuildMemberModel.FindMutualGuildsAsync(reminderModel.UserId); if (guildIds.Count == 0) @@ -307,8 +305,7 @@ private static async ValueTask DmUserAsync(DiscordShardedClient shardedCli bool guildUnavailable = false; foreach (ulong guildId in guildIds) { - DiscordClient? client = shardedClient.GetShard(guildId); - if (client is null || !client.Guilds.TryGetValue(guildId, out DiscordGuild? guild)) + if (!client.Guilds.TryGetValue(guildId, out DiscordGuild? guild)) { continue; } diff --git a/src/Program.cs b/src/Program.cs index ea9d1a4..587ce83 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -120,7 +120,7 @@ public static async Task Main(string[] args) DiscordEventManager eventManager = serviceProvider.GetRequiredService(); DiscordClientBuilder clientBuilder = DiscordClientBuilder.CreateDefault(tomoeConfiguration.Discord.Token, eventManager.Intents, serviceCollection); - //clientBuilder.ConfigureLogging(logger => logger.AddSerilo) + clientBuilder.DisableDefaultLogging(); eventManager.RegisterEventHandlers(clientBuilder); return clientBuilder.Build(); }); diff --git a/src/Tomoe.csproj b/src/Tomoe.csproj index 1815ebd..e377720 100644 --- a/src/Tomoe.csproj +++ b/src/Tomoe.csproj @@ -14,17 +14,17 @@ - + - + - + - - + +