Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
OoLunar committed Jul 12, 2024
1 parent c2682e5 commit d961d41
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion libs/DSharpPlus
Submodule DSharpPlus updated 103 files
2 changes: 1 addition & 1 deletion libs/XMLDocs.NET
2 changes: 1 addition & 1 deletion src/Commands/Common/InfoCommand/InfoCommand.Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion src/Commands/Common/PingCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using DSharpPlus.Commands;
using DSharpPlus.Commands.Trees;
using DSharpPlus.Commands.Trees.Metadata;
using Humanizer;

namespace OoLunar.Tomoe.Commands.Common
{
Expand All @@ -14,6 +15,6 @@ public static class PingCommand
/// Sends the latency of the bot's connection to Discord.
/// </summary>
[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)}.");
}
}
2 changes: 1 addition & 1 deletion src/Database/Models/PollModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public static async ValueTask PrepareAsync(NpgsqlConnection connection)

public static async ValueTask<bool> ExpireAsync(PollModel expirable, IServiceProvider serviceProvider)
{
DiscordClient? client = serviceProvider.GetRequiredService<DiscordShardedClient>().GetShard(expirable.GuildId);
DiscordClient? client = serviceProvider.GetRequiredService<DiscordClient>();
if (client is null)
{
return await PollEndedAsync(expirable.Id);
Expand Down
21 changes: 9 additions & 12 deletions src/Database/Models/ReminderModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,27 +237,25 @@ public static async ValueTask PrepareAsync(NpgsqlConnection connection)

public static async ValueTask<bool> ExpireAsync(ReminderModel expirable, IServiceProvider serviceProvider)
{
DiscordShardedClient? shardedClient = serviceProvider.GetRequiredService<DiscordShardedClient>();
if (shardedClient is null)
DiscordClient? client = serviceProvider.GetRequiredService<DiscordClient>();
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.
Expand All @@ -271,7 +269,7 @@ public static async ValueTask<bool> 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;
Expand All @@ -287,14 +285,14 @@ public static async ValueTask<bool> 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<bool> DmUserAsync(DiscordShardedClient shardedClient, ReminderModel reminderModel)
private static async ValueTask<bool> DmUserAsync(DiscordClient client, ReminderModel reminderModel)
{
IReadOnlyList<ulong> guildIds = await GuildMemberModel.FindMutualGuildsAsync(reminderModel.UserId);
if (guildIds.Count == 0)
Expand All @@ -307,8 +305,7 @@ private static async ValueTask<bool> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static async Task Main(string[] args)

DiscordEventManager eventManager = serviceProvider.GetRequiredService<DiscordEventManager>();
DiscordClientBuilder clientBuilder = DiscordClientBuilder.CreateDefault(tomoeConfiguration.Discord.Token, eventManager.Intents, serviceCollection);
//clientBuilder.ConfigureLogging(logger => logger.AddSerilo)
clientBuilder.DisableDefaultLogging();
eventManager.RegisterEventHandlers(clientBuilder);
return clientBuilder.Build();
});
Expand Down
10 changes: 5 additions & 5 deletions src/Tomoe.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
<PackageReference Include="Humanizer" Version="2.14.1" />
<PackageReference Include="LiveChartsCore.SkiaSharpView" Version="2.0.0-rc2" />
<PackageReference Include="LiveChartsCore" Version="2.0.0-rc2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.9.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.10.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Npgsql" Version="8.0.3" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.8" />
<PackageReference Include="ThisAssembly.Project" Version="1.4.3" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" PrivateAssets="all" />
Expand Down

0 comments on commit d961d41

Please sign in to comment.