Exemple #1
0
        public override async Task HandleCommandAsync(SocketSlashCommand command, DiscordSocketClient client, StorageClient storageClient, Guild guild)
        {
            var subCommand = command.Data.Options.Where(o => o.Type.Equals(ApplicationCommandOptionType.SubCommand)).First();
            IReadOnlyDictionary <SlashCommandOptions, string> options = SlashCommandUtils.OptionsToDictionary(subCommand.Options);

            Lazy <List <Team> > lazyTeams = new Lazy <List <Team> >(() => TeamResolver.ResolveTeam(options, command.User));

            if (subCommands.ContainsKey(subCommand.Name))
            {
                await subCommands[subCommand.Name].Run(command, client, options, lazyTeams);
            }
            else
            {
                await command.RespondAsync($"SubCommand {subCommand} not supported", ephemeral : true);
            }
        }
Exemple #2
0
        public override ApplicationCommandProperties Build()
        {
            var builder = new SlashCommandBuilder()
                          .WithName(this.Name)
                          .WithDescription(this.Description)
                          .WithDefaultPermission(this.DefaultPermissions);

            foreach (ICeaSubCommand subCommand in subCommands.Values)
            {
                SlashCommandOptionBuilder optionBuilder = subCommand.OptionBuilder;

                SlashCommandUtils.AddCommonOptionProperties(optionBuilder, subCommand.SupportedOptions);

                builder.AddOption(optionBuilder);
            }

            return(builder.Build());
        }