Пример #1
0
        internal static RestGuildCommand Create(BaseDiscordClient client, Model model, ulong guildId)
        {
            var entity = new RestGuildCommand(client, model.Id, guildId);

            entity.Update(model);
            return(entity);
        }
Пример #2
0
        internal static async Task <RestGuildCommand> ModifyGuildCommand(BaseDiscordClient client, RestGuildCommand command,
                                                                         Action <ApplicationCommandProperties> func, RequestOptions options = null)
        {
            ApplicationCommandProperties args = new ApplicationCommandProperties();

            func(args);

            if (args.Options.IsSpecified)
            {
                if (args.Options.Value.Count > 10)
                {
                    throw new ArgumentException("Option count must be 10 or less");
                }
            }

            var model = new Discord.API.Rest.ModifyApplicationCommandParams()
            {
                Name        = args.Name,
                Description = args.Description,
                Options     = args.Options.IsSpecified
                    ? args.Options.Value.Select(x => new Discord.API.ApplicationCommandOption(x)).ToArray()
                    : Optional <Discord.API.ApplicationCommandOption[]> .Unspecified
            };

            var msg = await client.ApiClient.ModifyGuildApplicationCommandAsync(model, command.GuildId, command.Id, options).ConfigureAwait(false);

            command.Update(msg);
            return(command);
        }