예제 #1
0
        public static async Task ModifyChannelAsync(RestSimpleChannel channel, Action <ModifyChannelParams> options)
        {
            if (!TokenHelper.TryGetToken(channel.Client, channel.Id, out RestTokenInfo info))
            {
                throw new MissingScopeException("channel_editor");
            }
            if (!info.Authorization.Scopes.Contains("channel_editor"))
            {
                throw new MissingScopeException("channel_editor");
            }

            var changes = new ModifyChannel();

            options.Invoke(changes.Parameters);

            var model = await channel.Client.RestClient.ModifyChannelInternalAsync(info.Token, channel.Id, changes);

            channel.Update(model);

            if (channel is RestChannel rc)
            {
                await rc.UpdateAsync();
            }
            if (channel is RestSelfChannel rsc)
            {
                await rsc.UpdateAsync();
            }
        }
예제 #2
0
 public ModifyChannelRequest(string token, ulong channelId, ModifyChannel changes)
     : base("PUT", $"channels/{channelId}", token)
 {
     JsonBody = JsonConvert.SerializeObject(changes);
 }