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

            return(entity);
        }
Exemple #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
                });