예제 #1
0
        public async Task <IActionResult> ModifyGuildAsync(Snowflake guildId, [FromBody] ModifyGuildParams args)
        {
            args.Validate();

            var guild = new Guild
            {
                Id = guildId
            };

            if (args.AfkChannelId.IsSpecified)
            {
                guild.AfkChannelId = args.AfkChannelId.Value;
            }
            if (args.AfkTimeout.IsSpecified)
            {
                guild.AfkTimeout = args.AfkTimeout.Value;
            }
            if (args.DefaultMessageNotifications.IsSpecified)
            {
                guild.DefaultMessageNotifications = args.DefaultMessageNotifications.Value;
            }
            if (args.ExplicitContentFilter.IsSpecified)
            {
                guild.ExplicitContentFilter = args.ExplicitContentFilter.Value;
            }
            if (args.Icon.IsSpecified)
            {
                guild.Icon = args.Icon.Value;
            }
            if (args.Name.IsSpecified)
            {
                guild.Name = args.Name.Value;
            }
            if (args.OwnerId.IsSpecified)
            {
                guild.OwnerId = args.OwnerId.Value;
            }
            if (args.Region.IsSpecified)
            {
                guild.Region = args.Region.Value;
            }
            if (args.Splash.IsSpecified)
            {
                guild.Splash = args.Splash.Value;
            }
            if (args.SystemChannelId.IsSpecified)
            {
                guild.SystemChannelId = args.SystemChannelId.Value;
            }
            if (args.VerificationLevel.IsSpecified)
            {
                guild.VerificationLevel = args.VerificationLevel.Value;
            }

            return(Ok(guild));
        }
예제 #2
0
파일: Guild.cs 프로젝트: faulty15/Faulty
        public async Task ModifyAsync(Action <ModifyGuildParams> func)
        {
            if (func == null)
            {
                throw new NullReferenceException(nameof(func));
            }

            var args = new ModifyGuildParams();

            func(args);

            if (args._splash.IsSpecified && _splashId != null)
            {
                args._splash = new API.Image(_splashId);
            }
            if (args._icon.IsSpecified && _iconId != null)
            {
                args._icon = new API.Image(_iconId);
            }

            var model = await Discord.ApiClient.ModifyGuildAsync(Id, args).ConfigureAwait(false);

            Update(model, UpdateSource.Rest);
        }