mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
Merge pull request #356 from spiralw/fix-cache-webhooks
Fix gateway event enricher crashing on webhook messages
This commit is contained in:
commit
57f3215651
1 changed files with 6 additions and 2 deletions
|
|
@ -11,7 +11,7 @@ namespace Myriad.Extensions
|
||||||
public static class PermissionExtensions
|
public static class PermissionExtensions
|
||||||
{
|
{
|
||||||
public static PermissionSet PermissionsFor(this IDiscordCache cache, MessageCreateEvent message) =>
|
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) =>
|
public static PermissionSet PermissionsFor(this IDiscordCache cache, ulong channelId, GuildMember member) =>
|
||||||
PermissionsFor(cache, channelId, member.User.Id, member.Roles);
|
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) =>
|
public static PermissionSet PermissionsFor(this IDiscordCache cache, ulong channelId, ulong userId, GuildMemberPartial member) =>
|
||||||
PermissionsFor(cache, channelId, userId, member.Roles);
|
PermissionsFor(cache, channelId, userId, member.Roles);
|
||||||
|
|
||||||
public static PermissionSet PermissionsFor(this IDiscordCache cache, ulong channelId, ulong userId, ICollection<ulong>? userRoles)
|
public static PermissionSet PermissionsFor(this IDiscordCache cache, ulong channelId, ulong userId, ICollection<ulong>? userRoles, bool isWebhook = false)
|
||||||
{
|
{
|
||||||
var channel = cache.GetChannel(channelId);
|
var channel = cache.GetChannel(channelId);
|
||||||
if (channel.GuildId == null)
|
if (channel.GuildId == null)
|
||||||
return PermissionSet.Dm;
|
return PermissionSet.Dm;
|
||||||
|
|
||||||
var guild = cache.GetGuild(channel.GuildId.Value);
|
var guild = cache.GetGuild(channel.GuildId.Value);
|
||||||
|
|
||||||
|
if (isWebhook)
|
||||||
|
return EveryonePermissions(guild);
|
||||||
|
|
||||||
return PermissionsFor(guild, channel, userId, userRoles);
|
return PermissionsFor(guild, channel, userId, userRoles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue