Browse Source

Fix switch casting as text and not as voice

pull/2329/head
Armano den Boef 3 years ago
parent
commit
cc52756a39
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs

+ 6
- 1
src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs View File

@@ -51,11 +51,16 @@ 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,
ICategoryChannel _ => Category,
IDMChannel _ => DM,
IGroupChannel _ => Group,


Loading…
Cancel
Save