Browse Source

rearrange to have voice fall through the switch first

pull/2329/head
Quin Lynch 3 years ago
parent
commit
dd7db1f5b7
1 changed files with 2 additions and 7 deletions
  1. +2
    -7
      src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs

+ 2
- 7
src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs View File

@@ -51,16 +51,11 @@ namespace Discord
/// <exception cref="ArgumentException">Unknown channel type.</exception>
public static ChannelPermissions All(IChannel channel)
{
// Because IVoiceChannel implements ITextChannel, the switch will allow voice to pass as text.
//
// This check will prevent that and first attempt to cast as voice instead.
if (channel is IVoiceChannel)
return Voice;

return channel switch
{
ITextChannel _ => Text,
IStageChannel _ => Stage,
IVoiceChannel _ => Voice,
ITextChannel _ => Text,
ICategoryChannel _ => Category,
IDMChannel _ => DM,
IGroupChannel _ => Group,


Loading…
Cancel
Save