1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-05-05 05:26:28 +03:00

Made guild settings code 10x better

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-07-11 00:28:49 +05:00
parent c00585e639
commit bbddb3790a
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
26 changed files with 452 additions and 303 deletions

View file

@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Text;
using Boyfriend.locale;
using DiffPlex.DiffBuilder.Model;
using Remora.Discord.API;
using Remora.Discord.API.Abstractions.Objects;
@ -170,10 +171,11 @@ public static class Extensions {
return user.Discriminator is 0000 ? $"@{user.Username}" : $"{user.Username}#{user.Discriminator:0000}";
}
public static Snowflake ToDiscordSnowflake(this ulong id) {
public static Snowflake ToSnowflake(this ulong id) {
return DiscordSnowflake.New(id);
}
public static TResult? MaxOrDefault<TSource, TResult>(
this IEnumerable<TSource> source, Func<TSource, TResult> selector) {
var list = source.ToList();
@ -190,4 +192,8 @@ public static class Extensions {
&& context.TryGetChannelID(out channelId)
&& context.TryGetUserID(out userId);
}
public static bool Empty(this Snowflake snowflake) {
return snowflake.Value is 0;
}
}