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

Fix more bugs and problems

This commit is contained in:
Octol1ttle 2023-01-18 11:48:38 +05:00
parent f1bd54d6f6
commit 7059c7576d
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
8 changed files with 46 additions and 19 deletions

View file

@ -96,7 +96,7 @@ public static partial class Utils {
if (sendPublic && systemChannel is not null) await SilentSendAsync(systemChannel, toSend);
}
public static string GetHumanizedTimeOffset(TimeSpan span) {
public static string GetHumanizedTimeSpan(TimeSpan span) {
return span.TotalSeconds < 1
? Messages.Ever
: $" {span.Humanize(2, minUnit: TimeUnit.Second, maxUnit: TimeUnit.Month, culture: Messages.Culture.Name.Contains("RU") ? CultureInfoCache["ru"] : Messages.Culture)}";
@ -145,7 +145,8 @@ public static partial class Utils {
if (role is not null) {
if (!toUnmute.Roles.Contains(role)) return false;
await toUnmute.AddRolesAsync(data.MemberData[toUnmute.Id].Roles, requestOptions);
if (data.Preferences["RemoveRolesOnMute"] is "true")
await toUnmute.AddRolesAsync(data.MemberData[toUnmute.Id].Roles, requestOptions);
await toUnmute.RemoveRoleAsync(role, requestOptions);
data.MemberData[toUnmute.Id].MutedUntil = null;
} else {
@ -157,6 +158,13 @@ public static partial class Utils {
return true;
}
public static async Task ReturnRolesAsync(SocketGuildUser user, List<ulong> roles) {
// ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
foreach (var role in roles)
if (role != user.Guild.Id)
await user.AddRoleAsync(role);
}
[GeneratedRegex("[^0-9]")]
private static partial Regex NumbersOnlyRegex();
}