Ejemplo n.º 1
0
        internal new static async Task <RestSlashCommand> CreateAsync(DiscordRestClient client, Model model, bool doApiCall)
        {
            var entity = new RestSlashCommand(client, model);
            await entity.UpdateAsync(client, model, doApiCall).ConfigureAwait(false);

            return(entity);
        }
Ejemplo n.º 2
0
        internal static async Task <RestInteraction> CreateAsync(DiscordRestClient client, Model model)
        {
            if (model.Type == InteractionType.Ping)
            {
                return(await RestPingInteraction.CreateAsync(client, model));
            }

            if (model.Type == InteractionType.ApplicationCommand)
            {
                var dataModel = model.Data.IsSpecified
                    ? (DataModel)model.Data.Value
                    : null;

                if (dataModel == null)
                {
                    return(null);
                }

                return(dataModel.Type switch
                {
                    ApplicationCommandType.Slash => await RestSlashCommand.CreateAsync(client, model).ConfigureAwait(false),
                    ApplicationCommandType.Message => await RestMessageCommand.CreateAsync(client, model).ConfigureAwait(false),
                    ApplicationCommandType.User => await RestUserCommand.CreateAsync(client, model).ConfigureAwait(false),
                    _ => null
                });