From c46177f2f5b91a052ea13f3bf548085595a0d5a1 Mon Sep 17 00:00:00 2001 From: spiral Date: Mon, 14 Jun 2021 09:57:58 -0400 Subject: [PATCH] Check if user is webhook in PermissionsFor --- Myriad/Extensions/PermissionExtensions.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Myriad/Extensions/PermissionExtensions.cs b/Myriad/Extensions/PermissionExtensions.cs index 6eafbbfa..9c403a3f 100644 --- a/Myriad/Extensions/PermissionExtensions.cs +++ b/Myriad/Extensions/PermissionExtensions.cs @@ -11,7 +11,7 @@ namespace Myriad.Extensions public static class PermissionExtensions { public static PermissionSet PermissionsFor(this IDiscordCache cache, MessageCreateEvent message) => - PermissionsFor(cache, message.ChannelId, message.Author.Id, message.Member?.Roles); + PermissionsFor(cache, message.ChannelId, message.Author.Id, message.Member?.Roles, isWebhook: message.Author.Discriminator == "0000"); public static PermissionSet PermissionsFor(this IDiscordCache cache, ulong channelId, GuildMember member) => PermissionsFor(cache, channelId, member.User.Id, member.Roles); @@ -19,13 +19,17 @@ namespace Myriad.Extensions public static PermissionSet PermissionsFor(this IDiscordCache cache, ulong channelId, ulong userId, GuildMemberPartial member) => PermissionsFor(cache, channelId, userId, member.Roles); - public static PermissionSet PermissionsFor(this IDiscordCache cache, ulong channelId, ulong userId, ICollection? userRoles) + public static PermissionSet PermissionsFor(this IDiscordCache cache, ulong channelId, ulong userId, ICollection? userRoles, bool isWebhook = false) { var channel = cache.GetChannel(channelId); if (channel.GuildId == null) return PermissionSet.Dm; var guild = cache.GetGuild(channel.GuildId.Value); + + if (isWebhook) + return EveryonePermissions(guild); + return PermissionsFor(guild, channel, userId, userRoles); }