Пример #1
0
        public bool AddPermissionOverwrite(PermissionOverwrite permission)
        {
            if (Client.AddChannelPermissionOverwrite(Id, permission))
            {
                PermissionOverwrites.Add(permission);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// Adds/edits a permission overwrite to a channel
        /// </summary>
        /// <param name="overwrite">The permission overwrite to add/edit</param>
        public void AddPermissionOverwrite(PermissionOverwrite overwrite)
        {
            Client.AddPermissionOverwrite(Id, overwrite);
            List <PermissionOverwrite> overwrites = PermissionOverwrites.ToList();

            if (overwrites.Where(pe => pe.Id == overwrite.Id).Count() > 0)
            {
                overwrites[overwrites.IndexOf(overwrites.First(pe => pe.Id == overwrite.Id))] = overwrite;
            }
            else
            {
                overwrites.Add(overwrite);
            }
            PermissionOverwrites = overwrites;
        }
Пример #3
0
        public void AddPermissionOverwrite(PermissionOverwrite overwrite)
        {
            Client.AddPermissionOverwrite(Id, overwrite);
            List <PermissionOverwrite> existing = PermissionOverwrites.Where(pe => pe.Id == overwrite.Id).ToList();
            var temp = PermissionOverwrites.ToList();

            if (existing.Count() > 0)
            {
                temp[temp.IndexOf(existing[0])] = overwrite;
            }
            else
            {
                temp.Add(overwrite);
            }
            PermissionOverwrites = temp;
        }
Пример #4
0
 /// <summary>
 /// Removes a permission overwrite from a channel
 /// </summary>
 /// <param name="overwrite">The overwrite to delete</param>
 public void RemovePermissionOverwrite(PermissionOverwrite overwrite)
 {
     RemovePermissionOverwrite(overwrite.Id);
 }
Пример #5
0
        public static bool AddChannelPermissionOverwrite(this DiscordClient client, long channelId, PermissionOverwrite permission)
        {
            var resp = client.HttpClient.Put($"/channels/{channelId}/permissions/{permission.Id}");

            if (resp.StatusCode == HttpStatusCode.NotFound)
            {
                throw new ChannelNotFoundException(client, channelId);
            }

            return(resp.StatusCode == HttpStatusCode.NoContent);
        }
Пример #6
0
 /// <summary>
 /// Adds/edits a permission overwrite to a channel
 /// </summary>
 /// <param name="channelId">ID of the channel</param>
 /// <param name="overwrite">The permission overwrite to add/edit</param>
 public static void AddPermissionOverwrite(this DiscordClient client, ulong channelId, PermissionOverwrite overwrite)
 {
     client.HttpClient.Put($"/channels/{channelId}/permissions/{overwrite.Id}", JsonConvert.SerializeObject(overwrite));
 }