replaced usages of ChannelPermission#ReadMessages with ViewChannel rename parameter of ChannelPermissions constructor made OverwritePermissions#ReadMessages obsolete, use ViewChannel insteadpull/874/head
| @@ -11,7 +11,9 @@ namespace Discord | |||||
| // Text | // Text | ||||
| AddReactions = 0x00_00_00_40, | AddReactions = 0x00_00_00_40, | ||||
| ReadMessages = 0x00_00_04_00, | |||||
| [Obsolete("Use ViewChannel instead.")] | |||||
| ReadMessages = ViewChannel, | |||||
| ViewChannel = 0x00_00_04_00, | |||||
| SendMessages = 0x00_00_08_00, | SendMessages = 0x00_00_08_00, | ||||
| SendTTSMessages = 0x00_00_10_00, | SendTTSMessages = 0x00_00_10_00, | ||||
| ManageMessages = 0x00_00_20_00, | ManageMessages = 0x00_00_20_00, | ||||
| @@ -41,7 +41,11 @@ namespace Discord | |||||
| /// <summary> If true, a user may add reactions. </summary> | /// <summary> If true, a user may add reactions. </summary> | ||||
| public bool AddReactions => Permissions.GetValue(RawValue, ChannelPermission.AddReactions); | public bool AddReactions => Permissions.GetValue(RawValue, ChannelPermission.AddReactions); | ||||
| /// <summary> If True, a user may join channels. </summary> | /// <summary> If True, a user may join channels. </summary> | ||||
| public bool ReadMessages => Permissions.GetValue(RawValue, ChannelPermission.ReadMessages); | |||||
| [Obsolete("Use ViewChannel instead.")] | |||||
| public bool ReadMessages => ViewChannel; | |||||
| /// <summary> If True, a user may view channels. </summary> | |||||
| public bool ViewChannel => Permissions.GetValue(RawValue, ChannelPermission.ViewChannel); | |||||
| /// <summary> If True, a user may send messages. </summary> | /// <summary> If True, a user may send messages. </summary> | ||||
| public bool SendMessages => Permissions.GetValue(RawValue, ChannelPermission.SendMessages); | public bool SendMessages => Permissions.GetValue(RawValue, ChannelPermission.SendMessages); | ||||
| /// <summary> If True, a user may send text-to-speech messages. </summary> | /// <summary> If True, a user may send text-to-speech messages. </summary> | ||||
| @@ -82,7 +86,7 @@ namespace Discord | |||||
| private ChannelPermissions(ulong initialValue, bool? createInstantInvite = null, bool? manageChannel = null, | private ChannelPermissions(ulong initialValue, bool? createInstantInvite = null, bool? manageChannel = null, | ||||
| bool? addReactions = null, | bool? addReactions = null, | ||||
| bool? readMessages = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null, | |||||
| bool? viewChannel = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null, | |||||
| bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null, | bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null, | ||||
| bool? useExternalEmojis = null, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null, | bool? useExternalEmojis = null, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null, | ||||
| bool? moveMembers = null, bool? useVoiceActivation = null, bool? manageRoles = null, bool? manageWebhooks = null) | bool? moveMembers = null, bool? useVoiceActivation = null, bool? manageRoles = null, bool? manageWebhooks = null) | ||||
| @@ -92,7 +96,7 @@ namespace Discord | |||||
| Permissions.SetValue(ref value, createInstantInvite, ChannelPermission.CreateInstantInvite); | Permissions.SetValue(ref value, createInstantInvite, ChannelPermission.CreateInstantInvite); | ||||
| Permissions.SetValue(ref value, manageChannel, ChannelPermission.ManageChannels); | Permissions.SetValue(ref value, manageChannel, ChannelPermission.ManageChannels); | ||||
| Permissions.SetValue(ref value, addReactions, ChannelPermission.AddReactions); | Permissions.SetValue(ref value, addReactions, ChannelPermission.AddReactions); | ||||
| Permissions.SetValue(ref value, readMessages, ChannelPermission.ReadMessages); | |||||
| Permissions.SetValue(ref value, viewChannel, ChannelPermission.ViewChannel); | |||||
| Permissions.SetValue(ref value, sendMessages, ChannelPermission.SendMessages); | Permissions.SetValue(ref value, sendMessages, ChannelPermission.SendMessages); | ||||
| Permissions.SetValue(ref value, sendTTSMessages, ChannelPermission.SendTTSMessages); | Permissions.SetValue(ref value, sendTTSMessages, ChannelPermission.SendTTSMessages); | ||||
| Permissions.SetValue(ref value, manageMessages, ChannelPermission.ManageMessages); | Permissions.SetValue(ref value, manageMessages, ChannelPermission.ManageMessages); | ||||
| @@ -1,4 +1,5 @@ | |||||
| using System.Collections.Generic; | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Diagnostics; | using System.Diagnostics; | ||||
| namespace Discord | namespace Discord | ||||
| @@ -27,7 +28,10 @@ namespace Discord | |||||
| /// <summary> If Allowed, a user may add reactions. </summary> | /// <summary> If Allowed, a user may add reactions. </summary> | ||||
| public PermValue AddReactions => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.AddReactions); | public PermValue AddReactions => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.AddReactions); | ||||
| /// <summary> If Allowed, a user may join channels. </summary> | /// <summary> If Allowed, a user may join channels. </summary> | ||||
| public PermValue ReadMessages => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.ReadMessages); | |||||
| [Obsolete("Use ViewChannel instead.")] | |||||
| public PermValue ReadMessages => ViewChannel; | |||||
| /// <summary> If Allowed, a user may join channels. </summary> | |||||
| public PermValue ViewChannel => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.ViewChannel); | |||||
| /// <summary> If Allowed, a user may send messages. </summary> | /// <summary> If Allowed, a user may send messages. </summary> | ||||
| public PermValue SendMessages => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.SendMessages); | public PermValue SendMessages => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.SendMessages); | ||||
| /// <summary> If Allowed, a user may send text-to-speech messages. </summary> | /// <summary> If Allowed, a user may send text-to-speech messages. </summary> | ||||
| @@ -72,7 +76,7 @@ namespace Discord | |||||
| private OverwritePermissions(ulong allowValue, ulong denyValue, PermValue? createInstantInvite = null, PermValue? manageChannel = null, | private OverwritePermissions(ulong allowValue, ulong denyValue, PermValue? createInstantInvite = null, PermValue? manageChannel = null, | ||||
| PermValue? addReactions = null, | PermValue? addReactions = null, | ||||
| PermValue? readMessages = null, PermValue? sendMessages = null, PermValue? sendTTSMessages = null, PermValue? manageMessages = null, | |||||
| PermValue? viewChannel = null, PermValue? sendMessages = null, PermValue? sendTTSMessages = null, PermValue? manageMessages = null, | |||||
| PermValue? embedLinks = null, PermValue? attachFiles = null, PermValue? readMessageHistory = null, PermValue? mentionEveryone = null, | PermValue? embedLinks = null, PermValue? attachFiles = null, PermValue? readMessageHistory = null, PermValue? mentionEveryone = null, | ||||
| PermValue? useExternalEmojis = null, PermValue? connect = null, PermValue? speak = null, PermValue? muteMembers = null, | PermValue? useExternalEmojis = null, PermValue? connect = null, PermValue? speak = null, PermValue? muteMembers = null, | ||||
| PermValue? deafenMembers = null, PermValue? moveMembers = null, PermValue? useVoiceActivation = null, PermValue? manageRoles = null, | PermValue? deafenMembers = null, PermValue? moveMembers = null, PermValue? useVoiceActivation = null, PermValue? manageRoles = null, | ||||
| @@ -81,7 +85,7 @@ namespace Discord | |||||
| Permissions.SetValue(ref allowValue, ref denyValue, createInstantInvite, ChannelPermission.CreateInstantInvite); | Permissions.SetValue(ref allowValue, ref denyValue, createInstantInvite, ChannelPermission.CreateInstantInvite); | ||||
| Permissions.SetValue(ref allowValue, ref denyValue, manageChannel, ChannelPermission.ManageChannels); | Permissions.SetValue(ref allowValue, ref denyValue, manageChannel, ChannelPermission.ManageChannels); | ||||
| Permissions.SetValue(ref allowValue, ref denyValue, addReactions, ChannelPermission.AddReactions); | Permissions.SetValue(ref allowValue, ref denyValue, addReactions, ChannelPermission.AddReactions); | ||||
| Permissions.SetValue(ref allowValue, ref denyValue, readMessages, ChannelPermission.ReadMessages); | |||||
| Permissions.SetValue(ref allowValue, ref denyValue, viewChannel, ChannelPermission.ViewChannel); | |||||
| Permissions.SetValue(ref allowValue, ref denyValue, sendMessages, ChannelPermission.SendMessages); | Permissions.SetValue(ref allowValue, ref denyValue, sendMessages, ChannelPermission.SendMessages); | ||||
| Permissions.SetValue(ref allowValue, ref denyValue, sendTTSMessages, ChannelPermission.SendTTSMessages); | Permissions.SetValue(ref allowValue, ref denyValue, sendTTSMessages, ChannelPermission.SendTTSMessages); | ||||
| Permissions.SetValue(ref allowValue, ref denyValue, manageMessages, ChannelPermission.ManageMessages); | Permissions.SetValue(ref allowValue, ref denyValue, manageMessages, ChannelPermission.ManageMessages); | ||||
| @@ -152,7 +152,7 @@ namespace Discord | |||||
| if (channel is ITextChannel textChannel) | if (channel is ITextChannel textChannel) | ||||
| { | { | ||||
| if (!GetValue(resolvedPermissions, ChannelPermission.ReadMessages)) | |||||
| if (!GetValue(resolvedPermissions, ChannelPermission.ViewChannel)) | |||||
| { | { | ||||
| //No read permission on a text channel removes all other permissions | //No read permission on a text channel removes all other permissions | ||||
| resolvedPermissions = 0; | resolvedPermissions = 0; | ||||
| @@ -234,7 +234,7 @@ namespace Discord.Rest | |||||
| if (model == null) | if (model == null) | ||||
| return null; | return null; | ||||
| var user = RestGuildUser.Create(client, guild, model); | var user = RestGuildUser.Create(client, guild, model); | ||||
| if (!user.GetPermissions(channel).ReadMessages) | |||||
| if (!user.GetPermissions(channel).ViewChannel) | |||||
| return null; | return null; | ||||
| return user; | return user; | ||||
| @@ -255,7 +255,7 @@ namespace Discord.Rest | |||||
| var models = await client.ApiClient.GetGuildMembersAsync(guild.Id, args, options).ConfigureAwait(false); | var models = await client.ApiClient.GetGuildMembersAsync(guild.Id, args, options).ConfigureAwait(false); | ||||
| return models | return models | ||||
| .Select(x => RestGuildUser.Create(client, guild, x)) | .Select(x => RestGuildUser.Create(client, guild, x)) | ||||
| .Where(x => x.GetPermissions(channel).ReadMessages) | |||||
| .Where(x => x.GetPermissions(channel).ViewChannel) | |||||
| .ToImmutableArray(); | .ToImmutableArray(); | ||||
| }, | }, | ||||
| nextPage: (info, lastPage) => | nextPage: (info, lastPage) => | ||||
| @@ -192,7 +192,7 @@ namespace Discord.Rest | |||||
| var channels = await GetTextChannelsAsync(options).ConfigureAwait(false); | var channels = await GetTextChannelsAsync(options).ConfigureAwait(false); | ||||
| var user = await GetCurrentUserAsync(options).ConfigureAwait(false); | var user = await GetCurrentUserAsync(options).ConfigureAwait(false); | ||||
| return channels | return channels | ||||
| .Where(c => user.GetPermissions(c).ReadMessages) | |||||
| .Where(c => user.GetPermissions(c).ViewChannel) | |||||
| .OrderBy(c => c.Position) | .OrderBy(c => c.Position) | ||||
| .FirstOrDefault(); | .FirstOrDefault(); | ||||
| } | } | ||||
| @@ -25,7 +25,7 @@ namespace Discord.WebSocket | |||||
| public override IReadOnlyCollection<SocketGuildUser> Users | public override IReadOnlyCollection<SocketGuildUser> Users | ||||
| => Guild.Users.Where(x => Permissions.GetValue( | => Guild.Users.Where(x => Permissions.GetValue( | ||||
| Permissions.ResolveChannel(Guild, x, this, Permissions.ResolveGuild(Guild, x)), | Permissions.ResolveChannel(Guild, x, this, Permissions.ResolveGuild(Guild, x)), | ||||
| ChannelPermission.ReadMessages)).ToImmutableArray(); | |||||
| ChannelPermission.ViewChannel)).ToImmutableArray(); | |||||
| internal SocketTextChannel(DiscordSocketClient discord, ulong id, SocketGuild guild) | internal SocketTextChannel(DiscordSocketClient discord, ulong id, SocketGuild guild) | ||||
| : base(discord, id, guild) | : base(discord, id, guild) | ||||
| @@ -107,7 +107,7 @@ namespace Discord.WebSocket | |||||
| { | { | ||||
| var guildPerms = Permissions.ResolveGuild(Guild, user); | var guildPerms = Permissions.ResolveGuild(Guild, user); | ||||
| var channelPerms = Permissions.ResolveChannel(Guild, user, this, guildPerms); | var channelPerms = Permissions.ResolveChannel(Guild, user, this, guildPerms); | ||||
| if (Permissions.GetValue(channelPerms, ChannelPermission.ReadMessages)) | |||||
| if (Permissions.GetValue(channelPerms, ChannelPermission.ViewChannel)) | |||||
| return user; | return user; | ||||
| } | } | ||||
| return null; | return null; | ||||