internal static RestGuildCommand Create(BaseDiscordClient client, Model model, ulong guildId) { var entity = new RestGuildCommand(client, model.Id, guildId); entity.Update(model); return(entity); }
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); }