mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-03 04:29:54 +03:00
Keep adapting code to new guild data storage...
Fix #15, update InspectCode, make Dependabot use the correct label
This commit is contained in:
parent
fe2cfb3b3c
commit
4b2d98c440
16 changed files with 152 additions and 131 deletions
|
@ -49,6 +49,11 @@ public static partial class Utils {
|
|||
return ulong.TryParse(NumbersOnlyRegex().Replace(mention, ""), out var id) ? id : 0;
|
||||
}
|
||||
|
||||
public static async Task SendDirectMessage(ulong id, string toSend) {
|
||||
if (await Boyfriend.Client.GetUserAsync(id) is SocketUser user)
|
||||
await SendDirectMessage(user, toSend);
|
||||
}
|
||||
|
||||
public static async Task SendDirectMessage(SocketUser user, string toSend) {
|
||||
try { await user.SendMessageAsync(toSend); } catch (HttpException e) {
|
||||
if (e.DiscordCode is not DiscordErrorCode.CannotSendMessageToUser) throw;
|
||||
|
@ -133,6 +138,14 @@ public static partial class Utils {
|
|||
.Preferences["EventNotificationChannel"]));
|
||||
}
|
||||
|
||||
public static bool UserExists(ulong id) {
|
||||
return Boyfriend.Client.GetUser(id) is not null || UserInMemberData(id);
|
||||
}
|
||||
|
||||
private static bool UserInMemberData(ulong id) {
|
||||
return GuildData.GuildDataDictionary.Values.Any(gData => gData.MemberData.Values.Any(mData => mData.Id == id));
|
||||
}
|
||||
|
||||
[GeneratedRegex("[^0-9]")]
|
||||
private static partial Regex NumbersOnlyRegex();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue