Exemplo n.º 1
0
        private async Task Client_Ready()
        {
            return;

            var guild  = Client.GetGuild(000);
            var guild2 = Client.GetGuild(000);
            // Next, lets create our slash command builder. This is like the embed builder but for slash commands.
            var guildCommand = new SlashCommandBuilder();

            // Note: Names have to be all lowercase and match the regular expression ^[\w-]{3,32}$
            guildCommand.WithName("pixiv");

            // Descriptions can have a max length of 100.
            guildCommand.WithDescription("Pixiv command");
            guildCommand.AddOption(new SlashCommandOptionBuilder().WithName("id").WithDescription("Pixiv work").WithRequired(false).WithType(ApplicationCommandOptionType.Integer));

            try {
                var c1 = await guild.CreateApplicationCommandAsync(guildCommand.Build());

                var c2 = await guild2.CreateApplicationCommandAsync(guildCommand.Build());
            }
            catch (Exception exception) {
                Console.WriteLine(exception.Message + Environment.NewLine + exception.StackTrace);
            }
        }
        private async Task SetupCommands()
        {
            foreach (SocketApplicationCommand sac in await _client.GetGlobalApplicationCommandsAsync())
            {
                //await sac.DeleteAsync();
                if (sac.Name == "randomimage")
                {
                    Log(LogSeverity.Error, $"RandomImage command is already set up");
                    return;
                }
            }
            SlashCommandBuilder scb = new SlashCommandBuilder();

            scb.WithName("randomimage");
            scb.WithDescription("Post a random image");
            List <ChannelType> channelTypes = new List <ChannelType>();

            channelTypes.Add(ChannelType.Text);
            channelTypes.Add(ChannelType.DM);
            scb.AddOption("channel", ApplicationCommandOptionType.Channel, "Channel source", isRequired: true, channelTypes: channelTypes);
            try
            {
                Log(LogSeverity.Error, $"RandomImage command set up");
                await _client.CreateGlobalApplicationCommandAsync(scb.Build());
            }
            catch (Exception e)
            {
                Log(LogSeverity.Error, $"Error setting up slash command: {e.Message}");
            }
        }
Exemplo n.º 3
0
        public override ApplicationCommandProperties Build()
        {
            var builder = new SlashCommandBuilder()
                          .WithName(this.Name)
                          .WithDescription(this.Description)
                          .WithDefaultPermission(this.DefaultPermissions);

            SlashCommandOptionBuilder optionBuilder = new SlashCommandOptionBuilder()
            {
                Name        = "configure",
                Description = "Gets all match history for a team or teams.",
                Type        = ApplicationCommandOptionType.SubCommand
            };

            optionBuilder.AddOption(
                name: "configuration",
                type: ApplicationCommandOptionType.String,
                description: "The full JSON configuration for the CEA bot.",
                isRequired: true);


            builder.AddOption(optionBuilder);

            return(builder.Build());
        }
Exemplo n.º 4
0
        public static async Task ResetCommandsAsync(DiscordSocketClient client)
        {
            await client.Rest.DeleteAllGlobalCommandsAsync();

            var statsCommand = new SlashCommandBuilder();
            statsCommand.WithName("stats");
            statsCommand.WithDescription("Prints the player statistics");
            statsCommand.AddOption("user", ApplicationCommandOptionType.User, "the user to print the stats", required: false);
            await client.Rest.CreateGlobalCommand(statsCommand.Build());

            var leaderboardCommand = new SlashCommandBuilder();
            leaderboardCommand.WithName("leaderboard");
            leaderboardCommand.WithDescription("Prints the leaderboard");
            await client.Rest.CreateGlobalCommand(leaderboardCommand.Build());

            var aboutCommand = new SlashCommandBuilder();
            aboutCommand.WithName("about");
            aboutCommand.WithDescription("Prints information about the bot and its author");
            await client.Rest.CreateGlobalCommand(aboutCommand.Build());

            var helpCommand = new SlashCommandBuilder();
            helpCommand.WithName("help");
            helpCommand.WithDescription("Prints all available commands in a category");
            helpCommand.AddOption("category", ApplicationCommandOptionType.String, "the category to view its commands", required: false);
            await client.Rest.CreateGlobalCommand(helpCommand.Build());
        }
Exemplo n.º 5
0
        public override ApplicationCommandProperties Build()
        {
            var builder = new SlashCommandBuilder()
                          .WithName(this.Name)
                          .WithDescription(this.Description)
                          .WithDefaultPermission(this.DefaultPermissions);

            return(builder.Build());
        }
Exemplo n.º 6
0
        public override ApplicationCommandProperties Build()
        {
            var builder = new SlashCommandBuilder()
                          .WithName(this.Name)
                          .WithDescription(this.Description)
                          .WithDefaultPermission(this.DefaultPermissions);

            builder.AddOption(
                name: "number_only",
                type: ApplicationCommandOptionType.Boolean,
                description: "Outputs only the version number");

            return(builder.Build());
        }
Exemplo n.º 7
0
        /// <summary>
        ///  Build the command and put it in a state in which we can use to define it to Discord.
        /// </summary>
        public SlashCommandCreationProperties BuildCommand()
        {
            var builder = new SlashCommandBuilder();

            builder.WithName(Name);
            builder.WithDescription(Description);
            builder.Options = new List <SlashCommandOptionBuilder>();

            foreach (var parameter in Parameters)
            {
                builder.AddOptions(parameter);
            }

            return(builder.Build());
        }
Exemplo n.º 8
0
        public SlashCommandCreationProperties BuildTopLevelCommandGroup()
        {
            SlashCommandBuilder builder = new SlashCommandBuilder();

            builder.WithName(commandGroupInfo.groupName);
            builder.WithDescription(commandGroupInfo.description);
            foreach (var command in Commands)
            {
                builder.AddOption(command.BuildSubCommand());
            }
            foreach (var commandGroup in commandGroups)
            {
                builder.AddOption(commandGroup.BuildNestedCommandGroup());
            }
            return(builder.Build());
        }
Exemplo n.º 9
0
        public override SlashCommandProperties Build()
        {
            var addCmd = new SlashCommandOptionBuilder()
            {
                Name        = "add",
                Description = "Add your RL tracker for the next season of CEA!",
                Type        = ApplicationCommandOptionType.SubCommand
            };

            addCmd.AddOption("platform",
                             ApplicationCommandOptionType.String,
                             "Platorm you play on",
                             required: true,
                             choices:
                             new ApplicationCommandOptionChoiceProperties[] { new ApplicationCommandOptionChoiceProperties()
                                                                              {
                                                                                  Name = "epic", Value = "Epic"
                                                                              },
                                                                              new ApplicationCommandOptionChoiceProperties()
                                                                              {
                                                                                  Name = "steam", Value = "Steam"
                                                                              },
                                                                              new ApplicationCommandOptionChoiceProperties()
                                                                              {
                                                                                  Name = "playstation", Value = "Playstation"
                                                                              },
                                                                              new ApplicationCommandOptionChoiceProperties()
                                                                              {
                                                                                  Name = "xbox", Value = "Xbox"
                                                                              },
                                                                              new ApplicationCommandOptionChoiceProperties()
                                                                              {
                                                                                  Name = "tracker", Value = "Tracker"
                                                                              } });
            addCmd.AddOption("id", ApplicationCommandOptionType.String, "For steam use your id, others use username, tracker post full tracker", required: true);


            var builder = new SlashCommandBuilder()
                          .WithName(this.Name)
                          .WithDescription(this.Description)
                          .WithDefaultPermission(this.DefaultPermissions)
                          .AddOption(addCmd);

            return(builder.Build());
        }
Exemplo n.º 10
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());
        }
Exemplo n.º 11
0
        public override SlashCommandProperties Build()
        {
            // TODO: Add directly to a team
            var addCmd = new SlashCommandOptionBuilder()
            {
                Name        = "adminadd",
                Description = "Add a user to the recruiting board",
                Type        = ApplicationCommandOptionType.SubCommand
            };

            addCmd.AddOption("username", ApplicationCommandOptionType.User, "Username of user to move", isRequired: true);
            addCmd.AddOption("platform",
                             ApplicationCommandOptionType.String,
                             "Platorm you play on",
                             isRequired: true,
                             choices:
                             new ApplicationCommandOptionChoiceProperties[] { new ApplicationCommandOptionChoiceProperties()
                                                                              {
                                                                                  Name = "epic", Value = "Epic"
                                                                              },
                                                                              new ApplicationCommandOptionChoiceProperties()
                                                                              {
                                                                                  Name = "steam", Value = "Steam"
                                                                              },
                                                                              new ApplicationCommandOptionChoiceProperties()
                                                                              {
                                                                                  Name = "playstation", Value = "Playstation"
                                                                              },
                                                                              new ApplicationCommandOptionChoiceProperties()
                                                                              {
                                                                                  Name = "xbox", Value = "Xbox"
                                                                              },
                                                                              new ApplicationCommandOptionChoiceProperties()
                                                                              {
                                                                                  Name = "tracker", Value = "Tracker"
                                                                              } });
            addCmd.AddOption("id", ApplicationCommandOptionType.String, "For steam use your id, others use username, tracker post full tracker", isRequired: true);
            addCmd.AddOption("team", ApplicationCommandOptionType.String, "Team to add this user to. If left blank, defaults to Free Agents", isRequired: false);

            var moveCmd = new SlashCommandOptionBuilder()
            {
                Name        = "move",
                Description = "Move a tracked user to a team.",
                Type        = ApplicationCommandOptionType.SubCommand
            };

            moveCmd.AddOption("username", ApplicationCommandOptionType.User, "Username of user to move", isRequired: true);
            moveCmd.AddOption("team", ApplicationCommandOptionType.String, "Team to move user to", isRequired: true);
            moveCmd.AddOption("captain", ApplicationCommandOptionType.Boolean, "Is this user the captain of the team?", isRequired: false);

            var removeCmd = new SlashCommandOptionBuilder()
            {
                Name        = "remove",
                Description = "Remove a tracked user.",
                Type        = ApplicationCommandOptionType.SubCommand
            };

            removeCmd.AddOption("username", ApplicationCommandOptionType.User, "Username of user to remove", isRequired: true);

            var deleteTeamCmd = new SlashCommandOptionBuilder()
            {
                Name        = "deleteteam",
                Description = "Remove team.",
                Type        = ApplicationCommandOptionType.SubCommand
            };

            deleteTeamCmd.AddOption("team", ApplicationCommandOptionType.String, "Team to remove", isRequired: true);

            var lookingForPlayersCmd = new SlashCommandOptionBuilder()
            {
                Name        = "lookingforplayers",
                Description = "Mark your team as looking for players or not.",
                Type        = ApplicationCommandOptionType.SubCommand
            };

            lookingForPlayersCmd.AddOption("team", ApplicationCommandOptionType.String, "Team to mark as looking for players", isRequired: true);
            lookingForPlayersCmd.AddOption("looking", ApplicationCommandOptionType.Boolean, "Are you looking for new players", isRequired: true);

            var builder = new SlashCommandBuilder()
                          .WithName(this.Name)
                          .WithDescription(this.Description)
                          .WithDefaultPermission(this.DefaultPermissions)
                          .AddOptions(addCmd, moveCmd, removeCmd, deleteTeamCmd, lookingForPlayersCmd);

            return(builder.Build());
        }