use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project Ree6 by Ree6-Applications.
the class Play method onPerform.
@Override
public void onPerform(CommandEvent commandEvent) {
if (!Main.getInstance().getMusicWorker().checkInteractPermission(commandEvent)) {
return;
}
if (commandEvent.isSlashCommand()) {
OptionMapping valueOption = commandEvent.getSlashCommandInteractionEvent().getOption("name");
if (valueOption != null) {
playSong(valueOption.getAsString(), commandEvent);
} else {
EmbedBuilder em = new EmbedBuilder();
em.setAuthor(BotInfo.botInstance.getSelfUser().getName(), Data.WEBSITE, BotInfo.botInstance.getSelfUser().getAvatarUrl());
em.setTitle("Music Player!");
em.setThumbnail(BotInfo.botInstance.getSelfUser().getAvatarUrl());
em.setColor(Color.GREEN);
em.setDescription("Usage: " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "play (Url)");
em.setFooter(commandEvent.getGuild().getName() + " - " + Data.ADVERTISEMENT, commandEvent.getGuild().getIconUrl());
sendMessage(em, 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
}
} else {
if (commandEvent.getArguments().length < 1) {
EmbedBuilder em = new EmbedBuilder();
em.setAuthor(BotInfo.botInstance.getSelfUser().getName(), Data.WEBSITE, BotInfo.botInstance.getSelfUser().getAvatarUrl());
em.setTitle("Music Player!");
em.setThumbnail(BotInfo.botInstance.getSelfUser().getAvatarUrl());
em.setColor(Color.GREEN);
em.setDescription("Usage: " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "play (Url)");
em.setFooter(commandEvent.getGuild().getName() + " - " + Data.ADVERTISEMENT, commandEvent.getGuild().getIconUrl());
sendMessage(em, 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
} else {
playSong(commandEvent.getArguments()[0], commandEvent);
}
}
}
use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project Ree6 by Ree6-Applications.
the class Level method onPerform.
@Override
public void onPerform(CommandEvent commandEvent) {
if (commandEvent.isSlashCommand()) {
OptionMapping targetOption = commandEvent.getSlashCommandInteractionEvent().getOption("target");
if (targetOption != null && targetOption.getAsMember() != null) {
sendLevel(targetOption.getAsMember(), commandEvent);
} else {
sendLevel(commandEvent.getMember(), commandEvent);
}
} else {
if (commandEvent.getArguments().length <= 1) {
if (commandEvent.getMessage().getMentionedMembers().isEmpty()) {
sendLevel(commandEvent.getMember(), commandEvent);
} else {
sendLevel(commandEvent.getMessage().getMentionedMembers().get(0), commandEvent);
}
} else {
sendMessage("Not enough Arguments!", commandEvent.getTextChannel(), commandEvent.getInteractionHook());
sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "level or " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "level @user", commandEvent.getTextChannel(), commandEvent.getInteractionHook());
}
}
}
use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project Ree6 by Ree6-Applications.
the class Kiss method onPerform.
@Override
public void onPerform(CommandEvent commandEvent) {
if (commandEvent.isSlashCommand()) {
OptionMapping targetOption = commandEvent.getSlashCommandInteractionEvent().getOption("target");
if (targetOption != null && targetOption.getAsMember() != null) {
sendKiss(targetOption.getAsMember(), commandEvent);
} else {
sendMessage("No User was given to Kiss!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
}
} else {
if (commandEvent.getArguments().length == 1) {
if (commandEvent.getMessage().getMentionedMembers().isEmpty()) {
sendMessage("No User mentioned!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "kiss @user", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
} else {
sendKiss(commandEvent.getMessage().getMentionedMembers().get(0), commandEvent);
}
} else {
sendMessage("Not enough Arguments!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "kiss @user", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
}
}
}
use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project MMDBot by MinecraftModDevelopment.
the class CmdHelp method execute.
/**
* Prepare the potential scrolling buttons for a help command,
* and send the message with the proper embeds.
* <p>
* See {@link #getEmbed(int)} for the implementation.
*/
public void execute(SlashCommandEvent e) {
OptionMapping commandName = e.getOption("command");
commands = CommandModule.getCommandClient().getCommands();
commands.addAll(CommandModule.getCommandClient().getSlashCommands());
updateMaximum(commands.size());
// If no command specified, show all.
if (commandName == null) {
sendPaginatedMessage(e);
} else {
Command command = CommandModule.getCommandClient().getCommands().stream().filter(// Find the command with the matching name
com -> com.getName().equals(commandName.getAsString())).findFirst().orElseGet(// And return it as Command.
CmdHelp::new);
// Build the embed that summarises the command.
EmbedBuilder embed = new EmbedBuilder();
embed.setAuthor(References.NAME, References.ISSUE_TRACKER, MMDBot.getJDA().getSelfUser().getAvatarUrl());
embed.setDescription("Command help:");
embed.addField(command.getName(), command.getHelp(), false);
// If we have arguments defined and there's content, add it to the embed
if (command.getArguments() != null && command.getArguments().length() > 0) {
embed.addField("Arguments", command.getArguments(), false);
}
embed.setFooter(References.NAME).setTimestamp(Instant.now());
e.replyEmbeds(embed.build()).queue();
}
}
use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project MMDBot by MinecraftModDevelopment.
the class CmdFabricVersion method execute.
/**
* Execute.
*
* @param event The {@link CommandEvent CommandEvent} that triggered this Command.
*/
@Override
protected void execute(final SlashCommandEvent event) {
if (!Utils.checkCommand(this, event)) {
return;
}
String minecraft = MinecraftVersionHelper.getLatest();
OptionMapping version = event.getOption("version");
if (version != null)
minecraft = version.getAsString();
var yarnVersion = FabricVersionHelper.getLatestYarn(minecraft);
if (yarnVersion == null) {
yarnVersion = "None";
}
final var embed = new EmbedBuilder();
embed.setTitle("Fabric Versions for Minecraft " + minecraft);
embed.addField("Latest Yarn", yarnVersion, true);
embed.addField("Latest API", FabricVersionHelper.getLatestApi(), true);
embed.addField("Latest Loader", FabricVersionHelper.getLatestLoader(), true);
embed.setColor(Color.WHITE);
embed.setTimestamp(Instant.now());
event.replyEmbeds(embed.build()).mentionRepliedUser(false).queue();
}
Aggregations