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

Seal all possible classes, add LICENSE, follow async naming conventions

This commit is contained in:
Octol1ttle 2022-09-18 19:41:29 +05:00
parent ac63719a0b
commit e767205c1a
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
20 changed files with 873 additions and 123 deletions

View file

@ -2,6 +2,7 @@
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using Boyfriend.Commands;
using Discord;
using Discord.Net;
using Discord.WebSocket;
@ -55,10 +56,6 @@ public static class Utils {
return user;
}
public static SocketGuildUser? ParseMember(SocketGuild guild, string mention) {
return guild.GetUser(ParseMention(mention));
}
public static async Task SendDirectMessage(SocketUser user, string toSend) {
try { await user.SendMessageAsync(toSend); } catch (HttpException e) {
if (e.DiscordCode != DiscordErrorCode.CannotSendMessageToUser)
@ -115,7 +112,8 @@ public static class Utils {
return toReturn;
}
public static async Task SendFeedback(string feedback, ulong guildId, string mention, bool sendPublic = false) {
public static async Task
SendFeedbackAsync(string feedback, ulong guildId, string mention, bool sendPublic = false) {
var adminChannel = GetAdminLogChannel(guildId);
var systemChannel = Boyfriend.Client.GetGuild(guildId).SystemChannel;
var toSend = string.Format(Messages.FeedbackFormat, mention, feedback);
@ -153,4 +151,15 @@ public static class Utils {
appendTo.AppendLine(appendWhat);
}
}
public static async Task DelayedUnbanAsync(CommandProcessor cmd, ulong banned, string reason, TimeSpan duration) {
await Task.Delay(duration);
await UnbanCommand.UnbanUserAsync(cmd, banned, reason);
}
public static async Task DelayedUnmuteAsync(CommandProcessor cmd, SocketGuildUser muted, string reason,
TimeSpan duration) {
await Task.Delay(duration);
await UnmuteCommand.UnmuteMemberAsync(cmd, muted, reason);
}
}