示例#1
0
        public static async Task <Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client,
                                                     Action <TextChannelProperties> func,
                                                     RequestOptions options)
        {
            var args = new TextChannelProperties();

            func(args);
            var apiArgs = new API.Rest.ModifyTextChannelParams
            {
                Name             = args.Name,
                Position         = args.Position,
                CategoryId       = args.CategoryId,
                Topic            = args.Topic,
                IsNsfw           = args.IsNsfw,
                SlowModeInterval = args.SlowModeInterval,
                Overwrites       = args.PermissionOverwrites.IsSpecified
                    ? args.PermissionOverwrites.Value.Select(overwrite => new API.Overwrite
                {
                    TargetId   = overwrite.TargetId,
                    TargetType = overwrite.TargetType,
                    Allow      = overwrite.Permissions.AllowValue.ToString(),
                    Deny       = overwrite.Permissions.DenyValue.ToString()
                }).ToArray()
                    : Optional.Create <API.Overwrite[]>(),
            };

            return(await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false));
        }
示例#2
0
        public static async Task <Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client,
                                                     Action <TextChannelProperties> func,
                                                     RequestOptions options)
        {
            var args = new TextChannelProperties();

            func(args);
            var apiArgs = new API.Rest.ModifyTextChannelParams
            {
                Name     = args.Name,
                Position = args.Position,
                Topic    = args.Topic
            };

            return(await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false));
        }