internal static async Task <RestGlobalCommand> ModifyGlobalCommand(BaseDiscordClient client, RestGlobalCommand 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.ModifyGlobalApplicationCommandAsync(model, command.Id, options).ConfigureAwait(false); command.Update(msg); return(command); }
internal static RestGlobalCommand Create(BaseDiscordClient client, Model model) { var entity = new RestGlobalCommand(client, model.Id); entity.Update(model); return(entity); }