/// <summary> /// TODO Documentation comment /// </summary> /// <param name="member"></param> /// <param name="requestedPublicity"></param> /// <param name="requestedRegion"></param> /// <param name="error"></param> /// <returns></returns> public bool CheckPermission(DiscordMember member, string name, ChannelPublicity requestedPublicity, VoiceRegion requestedRegion, out string error) { VoiceChannelCreationPermissions highestPrecedencePermissions = null; int existingChannels = (CreatedChannels.ContainsKey(member) ? CreatedChannels[member]?.Count : 0) ?? 0; int highestRolePosition = -1; DiscordRole highestRole = null; foreach (DiscordRole role in member.Roles) { if (highestRolePosition < role.Position) { highestRole = role; highestRolePosition = role.Position; } } if (RolewisePermissions.ContainsKey(highestRole)) { highestPrecedencePermissions = RolewisePermissions[highestRole]; } if (MemberwisePermissions.ContainsKey(member)) { highestPrecedencePermissions = MemberwisePermissions[member]; } return((highestPrecedencePermissions ?? EveryonePermission).ValidateChannelCreationAuthority(!((name is null) || name == string.Empty), requestedPublicity, existingChannels, requestedRegion, out error)); }
/// <summary> /// /// </summary> /// <param name="member"></param> /// <returns></returns> public List <DiscordChannel> GetChannels(DiscordMember member) { if (CreatedChannels.ContainsKey(member)) { return(CreatedChannels[member]); } return(null); }
/// <summary> /// /// </summary> /// <param name="member"></param> /// <param name="channel"></param> /// <returns></returns> public bool RemoveChannel(DiscordMember member, DiscordChannel channel) { if (CreatedChannels.ContainsKey(member) && !(CreatedChannels[member] is null) && CreatedChannels[member].Count > 0) { return(CreatedChannels[member].Remove(channel)); } return(false); }
/// <summary> /// /// </summary> /// <param name="member"></param> /// <param name="channel"></param> public void AddChannel(DiscordMember member, DiscordChannel channel) { if (CreatedChannels.ContainsKey(member)) { CreatedChannels[member].Add(channel); return; } CreatedChannels.Add(member, new List <DiscordChannel>(new DiscordChannel[] { channel })); }