use of net.dv8tion.jda.api.interactions.commands.build.OptionData in project discord-bot-reddit-java by Glaxier0.
the class GivePermissionCommand method addCommandsToGuild.
private void addCommandsToGuild(Guild guild) {
CommandListUpdateAction guildCommands = guild.updateCommands();
guildCommands.addCommands(Commands.slash("play", "Play a song on your voice channel.").addOptions(new OptionData(OptionType.STRING, "query", "Song url or name.").setRequired(true)), Commands.slash("skip", "Skip the current song."), Commands.slash("pause", "Pause the current song."), Commands.slash("resume", "Resume paused song."), Commands.slash("leave", "Make bot leave voice channel."), Commands.slash("queue", "List song queue."), Commands.slash("swap", "Swap order of two songs in queue").addOptions(new OptionData(OptionType.INTEGER, "songnum1", "Song number in the queue to be changed.").setRequired(true), new OptionData(OptionType.INTEGER, "songnum2", "Song number in queue to be changed.").setRequired(true)), Commands.slash("shuffle", "Shuffle the queue."), Commands.slash("mhelp", "Help page for music commands.")).queue();
}
use of net.dv8tion.jda.api.interactions.commands.build.OptionData in project discord-bot-reddit-java by Glaxier0.
the class Bot method addCommands.
private void addCommands(JDA jda) {
while (jda.getGuildById(TEST_SERVER) == null) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Guild testServer = jda.getGuildById(TEST_SERVER);
CommandListUpdateAction testServerCommands = testServer.updateCommands();
CommandListUpdateAction globalCommands = jda.updateCommands();
testServerCommands.addCommands(// admin commands
Commands.slash("givepermission", "Give permission to guild").addOptions(new OptionData(OptionType.STRING, "guildid", "Guild id.").setRequired(true), new OptionData(OptionType.STRING, "guildname", "Guild name.").setRequired(false)), Commands.slash("retrievepermission", "Retrieve permission from guild").addOptions(new OptionData(OptionType.STRING, "guildid", "Guild id.").setRequired(true)), Commands.slash("guilds", "Get guild list that bot is in."), Commands.slash("status", "Get reddit post statuses."), Commands.slash("stats", "Get user stats.").addOptions(new OptionData(OptionType.MENTIONABLE, "user", "User with mention.").setRequired(true)), Commands.slash("users", "Get bot users."), Commands.slash("logs", "Get logs."), Commands.slash("getguild", "Get guild id."), Commands.slash("addguild", "Add guild to the premium list.").addOptions(new OptionData(OptionType.STRING, "guildname", "Guild name.").setRequired(true)).addOptions(new OptionData(OptionType.STRING, "guildid", "Guild ID.").setRequired(true)), Commands.slash("removeguild", "Remove guild from premium list.").addOptions(new OptionData(OptionType.STRING, "guildid", "Guild ID.").setRequired(true)), Commands.slash("getguilds", "Get premium guilds."), // Music Commands
Commands.slash("play", "Play a song on your voice channel.").addOptions(new OptionData(OptionType.STRING, "query", "Song url or name.").setRequired(true)), Commands.slash("skip", "Skip the current song."), Commands.slash("pause", "Pause the current song."), Commands.slash("resume", "Resume paused song."), Commands.slash("leave", "Make bot leave voice channel."), Commands.slash("queue", "List song queue."), Commands.slash("swap", "Swap order of two songs in queue").addOptions(new OptionData(OptionType.INTEGER, "songnum1", "Song number in the queue to be changed.").setRequired(true), new OptionData(OptionType.INTEGER, "songnum2", "Song number in queue to be changed.").setRequired(true)), Commands.slash("shuffle", "Shuffle the queue."), Commands.slash("mhelp", "Help page for music commands.")).queue();
globalCommands.addCommands(// nsfw commands
Commands.slash("hentai", "Get random hentai image/gif/video."), Commands.slash("porn", "Get random porn image/gif/video."), // reddit commands
Commands.slash("unexpected", "Get top r/unexpected posts."), Commands.slash("dankmemes", "Get top r/dankmemes posts."), Commands.slash("memes", "Get top r/memes posts."), Commands.slash("greentext", "Get top r/greentext posts."), Commands.slash("blursedimages", "Get top r/blursedimages posts."), Commands.slash("perfectlycutscreams", "Get top r/perfectlycutscreams posts."), Commands.slash("interestingasfuck", "Get top r/interestingasfuck posts."), Commands.slash("facepalm", "Get top r/facepalm posts."), // test commands
Commands.slash("help", "Info page about bot commands"), Commands.slash("monke", "Get my favorite random monke video."), Commands.slash("github", "My github page and source code of bot."), Commands.slash("howgay", "Calculate how gay is someone.").addOptions(new OptionData(OptionType.USER, "user", "User to calculate how gay.").setRequired(true)), Commands.slash("errrkek", "Calculate how man is someone.").addOptions(new OptionData(OptionType.USER, "user", "User to calculate how man.").setRequired(true)), Commands.slash("topgg", "Top.gg page of Glaxier bot."), // to-do commands
Commands.slash("todoadd", "Add a task to your to-do list.").addOptions(new OptionData(OptionType.STRING, "task", "A to-do task.").setRequired(true)), Commands.slash("todolist", "Shows your to-do list."), Commands.slash("todoremove", "Remove a task from your to-do list.").addOptions(new OptionData(OptionType.INTEGER, "taskid", "To-do task id to remove.").setRequired(true)), Commands.slash("todoupdate", "Update a task in your to-do list.").addOptions(new OptionData(OptionType.INTEGER, "taskid", "To-do task id to remove.").setRequired(true), new OptionData(OptionType.STRING, "task", "Updated to-do task.").setRequired(true)), Commands.slash("todocomplete", "Complete a task in your to-do list.").addOptions(new OptionData(OptionType.INTEGER, "taskid", "To-do task id to remove.").setRequired(true)), Commands.slash("todoclear", "Clears your to-do list.")).queue();
}
use of net.dv8tion.jda.api.interactions.commands.build.OptionData in project triumph-cmds by TriumphTeam.
the class SlashSubCommand method getJdaOptions.
public List<OptionData> getJdaOptions() {
final List<OptionData> options = new ArrayList<>();
final List<InternalArgument<S, ?>> internalArguments = getArguments();
for (int i = 0; i < internalArguments.size(); i++) {
final InternalArgument<S, ?> internalArgument = internalArguments.get(i);
final OptionData option = new OptionData(JdaOptionUtil.fromType(internalArgument.getType()), internalArgument.getName(), internalArgument.getDescription(), !internalArgument.isOptional());
options.add(option);
final Choice suggestion = getChoice(i);
if (suggestion instanceof EmptyChoice)
continue;
option.addChoices(suggestion.getChoices().stream().map(it -> new Command.Choice(it, it)).limit(25).collect(Collectors.toList()));
}
return options;
}
use of net.dv8tion.jda.api.interactions.commands.build.OptionData in project Lauren by Yuhtin.
the class CommandRegistry method argsInterpreter.
private void argsInterpreter(CommandInfo handler, CommandDataImpl commandData, SubcommandData subcommandData) {
for (val option : handler.args()) {
val split = option.split("-");
val argName = split[0];
OptionType optionType;
if (argName.contains("@"))
optionType = OptionType.USER;
else if (argName.contains("%"))
optionType = OptionType.ROLE;
else if (argName.contains("#"))
optionType = OptionType.CHANNEL;
else if (argName.contains("!"))
optionType = OptionType.INTEGER;
else
optionType = OptionType.STRING;
val reformatedName = argName.replace("[", "").replace("]", "").replace("!", "").replace("<", "").replace(">", "").replace("@", "").replace("%", "").replace("#", "");
val optionData = new OptionData(optionType, reformatedName, split[1], argName.contains("<"));
if (commandData != null)
commandData.addOptions(optionData);
if (subcommandData != null)
subcommandData.addOptions(optionData);
}
}
use of net.dv8tion.jda.api.interactions.commands.build.OptionData in project Bean by Xirado.
the class CommandsRoute method handle.
@Override
public Object handle(Request request, Response response) throws Exception {
List<SlashCommand> commands = Bean.getInstance().isDebug() ? Bean.getInstance().getInteractionCommandHandler().getRegisteredGuildCommands().get(DEV_GUILD_ID).stream().filter(cmd -> cmd instanceof SlashCommand).map(cmd -> (SlashCommand) cmd).toList() : Bean.getInstance().getInteractionCommandHandler().getRegisteredSlashCommands();
DataArray commandArray = DataArray.empty();
for (SlashCommand command : commands) {
DataObject commandObject = DataObject.empty();
SlashCommandData slashCommandData = command.getData();
DataArray options = DataArray.empty();
DataArray subCommands = DataArray.empty();
for (OptionData option : slashCommandData.getOptions()) {
DataObject optionObject = DataObject.empty().put("name", option.getName()).put("type", option.getType().toString()).put("description", option.getDescription()).put("required", option.isRequired());
options.add(optionObject);
}
for (SubcommandData subcommandData : slashCommandData.getSubcommands()) {
DataObject subCommandObject = DataObject.empty();
DataArray subCommandOptions = DataArray.empty();
for (OptionData option : subcommandData.getOptions()) {
DataObject optionObject = DataObject.empty().put("name", option.getName()).put("type", option.getType().toString()).put("description", option.getDescription()).put("required", option.isRequired());
subCommandOptions.add(optionObject);
}
subCommandObject.put("name", subcommandData.getName()).put("description", subcommandData.getDescription());
subCommandObject.put("options", subCommandOptions);
subCommands.add(subCommandObject);
}
commandObject.put("name", slashCommandData.getName()).put("description", slashCommandData.getDescription()).put("options", options).put("sub_commands", subCommands);
commandArray.add(commandObject);
}
return commandArray.toString();
}
Aggregations