Correct impl. of HasFlag and ResolveChannel (#966)
HasFlag was checking if any of the flags were set, not the ones specified, and ResolveChannel was still treating the ChannelPermission enum as before it was changed to a bitflag.
This commit is contained in:
committed by
Christopher F
parent
b1eaa44021
commit
32ebdd51f7
@@ -80,7 +80,7 @@ namespace Discord
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private static bool HasFlag(ulong value, ulong flag) => (value & flag) != 0;
|
private static bool HasFlag(ulong value, ulong flag) => (value & flag) == flag;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void SetFlag(ref ulong value, ulong flag) => value |= flag;
|
public static void SetFlag(ref ulong value, ulong flag) => value |= flag;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@@ -161,10 +161,10 @@ namespace Discord
|
|||||||
else if (!GetValue(resolvedPermissions, ChannelPermission.SendMessages))
|
else if (!GetValue(resolvedPermissions, ChannelPermission.SendMessages))
|
||||||
{
|
{
|
||||||
//No send permissions on a text channel removes all send-related permissions
|
//No send permissions on a text channel removes all send-related permissions
|
||||||
resolvedPermissions &= ~(1UL << (int)ChannelPermission.SendTTSMessages);
|
resolvedPermissions &= ~(ulong)ChannelPermission.SendTTSMessages;
|
||||||
resolvedPermissions &= ~(1UL << (int)ChannelPermission.MentionEveryone);
|
resolvedPermissions &= ~(ulong)ChannelPermission.MentionEveryone;
|
||||||
resolvedPermissions &= ~(1UL << (int)ChannelPermission.EmbedLinks);
|
resolvedPermissions &= ~(ulong)ChannelPermission.EmbedLinks;
|
||||||
resolvedPermissions &= ~(1UL << (int)ChannelPermission.AttachFiles);
|
resolvedPermissions &= ~(ulong)ChannelPermission.AttachFiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolvedPermissions &= mask; //Ensure we didnt get any permissions this channel doesnt support (from guildPerms, for example)
|
resolvedPermissions &= mask; //Ensure we didnt get any permissions this channel doesnt support (from guildPerms, for example)
|
||||||
@@ -173,4 +173,4 @@ namespace Discord
|
|||||||
return resolvedPermissions;
|
return resolvedPermissions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user