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

Update to .NET 7

This commit is contained in:
Octol1ttle 2022-12-08 13:51:49 +05:00
parent 2596b48bde
commit fc00558dce
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
5 changed files with 26 additions and 18 deletions

View file

@ -11,7 +11,7 @@ using Humanizer.Localisation;
namespace Boyfriend;
public static class Utils {
public static partial class Utils {
private static readonly Dictionary<string, string> ReflectionMessageCache = new();
public static readonly Dictionary<string, CultureInfo> CultureInfoCache = new() {
@ -48,7 +48,7 @@ public static class Utils {
}
public static ulong ParseMention(string mention) {
return ulong.TryParse(Regex.Replace(mention, "[^0-9]", ""), out var id) ? id : 0;
return ulong.TryParse(NumbersOnlyRegex().Replace(mention, ""), out var id) ? id : 0;
}
public static async Task SendDirectMessage(SocketUser user, string toSend) {
@ -70,7 +70,7 @@ public static class Utils {
}
public static void RemoveMuteRoleFromCache(ulong id) {
if (MuteRoleCache.ContainsKey(id)) MuteRoleCache.Remove(id);
MuteRoleCache.Remove(id);
}
public static async Task SilentSendAsync(SocketTextChannel? channel, string text, bool allowRoles = false) {
@ -189,4 +189,7 @@ public static class Utils {
public static SocketTextChannel? GetEventNotificationChannel(SocketGuild guild) {
return guild.GetTextChannel(ParseMention(Boyfriend.GetGuildConfig(guild.Id)["EventNotificationChannel"]));
}
[GeneratedRegex("[^0-9]")]
private static partial Regex NumbersOnlyRegex();
}