use of net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction in project cds by iamysko.
the class SlashCommandListener method onSlashCommand.
@Override
public void onSlashCommand(SlashCommandEvent event) {
boolean perm = false;
if (RoleUtils.findRole(event.getMember(), RoleUtils.ROLE_SERVER_MANAGER) != null) {
perm = true;
} else if (RoleUtils.findRole(event.getMember(), RoleUtils.ROLE_SENIOR_MODERATOR) != null) {
perm = true;
} else if (RoleUtils.findRole(event.getMember(), RoleUtils.ROLE_MODERATOR) != null) {
perm = true;
} else if (RoleUtils.findRole(event.getMember(), RoleUtils.ROLE_TRIAL_MODERATOR) != null) {
perm = true;
} else {
perm = false;
}
if (perm) {
final TextChannel commandChannel = event.getGuild().getTextChannelById(Properties.CHANNEL_COMMANDS_ID);
final Member author = event.getMember();
final String authorMention = author.getAsMention();
if (event.getName().equals(SlashCommandConstants.COMMAND_HELP)) {
event.reply(StringBuilds.getHelpMessage(authorMention)).queue();
} else if (event.getName().equals(SlashCommandConstants.COMMAND_ABOUT)) {
event.reply(StringBuilds.getAboutMessage(authorMention)).queue();
} else if (event.getName().equals(SlashCommandConstants.COMMAND_USER_INFO)) {
Member theMember = event.getGuild().getMemberById(event.getOption("user").getAsString());
RestAction<User> userData = event.getJDA().retrieveUserById(event.getOption("user").getAsString());
User theUser = userData.complete();
EmbedBuilder embed = EmbedBuilds.getUserInfoEmbed(theMember, theUser);
ReplyAction reply = event.replyEmbeds(embed.build());
if (theMember != null && theMember.getNickname() != null && RoleUtils.findRole(theMember, RoleUtils.ROLE_VERIFIED) != null) {
reply.addActionRow(Button.danger("RobloxInformation/" + theMember.getNickname() + "/" + theMember.getId(), "Roblox Information"));
}
reply.queue();
} else if (event.getName().equals(SlashCommandConstants.COMMAND_ROBLOX_USER_INFO)) {
try {
EmbedBuilder embed = EmbedBuilds.getRobloxUserInfoEmbed(event.getOption("username").getAsString(), null);
event.replyEmbeds(embed.build()).queue();
} catch (Exception e) {
event.reply("It appears the Roblox API is currently not responding! Please Try again later! :(" + e).queue();
}
} else if (event.getName().equals(SlashCommandConstants.COMMAND_SCAN_URL)) {
event.deferReply().queue();
InteractionHook hook = event.getHook();
new Thread(() -> {
EmbedBuilder embed = null;
try {
embed = EmbedBuilds.scanUrl(event.getOption("url").getAsString(), event.getJDA().getSelfUser().getEffectiveAvatarUrl());
} catch (InterruptedException e) {
embed = EmbedBuilds.ApiError();
}
hook.editOriginalEmbeds(embed.build()).queue();
}).start();
} else {
event.reply("The Command you tried to execute does not exist!").queue();
}
} else {
event.reply("Missing permissions!").setEphemeral(true).queue();
}
}
use of net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction in project Emolga by TecToast.
the class GenericCommandEvent method reply.
public void reply(MessageEmbed msg, @Nullable Consumer<MessageAction> ma, @Nullable Consumer<ReplyAction> ra, @Nullable Consumer<Message> m, @Nullable Consumer<InteractionHook> ih) {
if (slashCommandEvent != null) {
ReplyAction reply = slashCommandEvent.replyEmbeds(msg);
if (ra != null)
ra.accept(reply);
reply.queue(ih);
} else {
MessageAction ac = getChannel().sendMessageEmbeds(msg);
if (ma != null)
ma.accept(ac);
ac.queue(m);
}
logger.info("QUEUED! " + System.currentTimeMillis());
}
use of net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction in project Emolga by TecToast.
the class GenericCommandEvent method reply.
public void reply(String msg, @Nullable Consumer<MessageAction> ma, @Nullable Consumer<ReplyAction> ra, @Nullable Consumer<Message> m, @Nullable Consumer<InteractionHook> ih) {
if (slashCommandEvent != null) {
ReplyAction reply = slashCommandEvent.reply(msg);
if (ra != null)
ra.accept(reply);
reply.queue(ih);
} else {
MessageAction ac = getChannel().sendMessage(msg);
if (ma != null)
ma.accept(ac);
ac.queue(m);
}
}
use of net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction in project TJ-Bot by Together-Java.
the class TagCommand method onSlashCommand.
@Override
public void onSlashCommand(@NotNull SlashCommandEvent event) {
String id = Objects.requireNonNull(event.getOption(ID_OPTION)).getAsString();
OptionMapping replyToUserOption = event.getOption(REPLY_TO_USER_OPTION);
if (tagSystem.handleIsUnknownTag(id, event)) {
return;
}
ReplyAction message = event.replyEmbeds(new EmbedBuilder().setDescription(tagSystem.getTag(id).orElseThrow()).setFooter(event.getUser().getName() + " • used " + event.getCommandString()).setTimestamp(Instant.now()).setColor(TagSystem.AMBIENT_COLOR).build());
if (replyToUserOption != null) {
message = message.setContent(replyToUserOption.getAsUser().getAsMention());
}
message.queue();
}
Aggregations