use of net.essentialsx.api.v2.services.discord.InteractionEvent in project Essentials by drtshock.
the class InteractionControllerImpl method onSlashCommand.
@Override
public void onSlashCommand(@NotNull SlashCommandEvent event) {
if (event.getGuild() == null || event.getMember() == null || !commandMap.containsKey(event.getName())) {
return;
}
final InteractionCommand command = commandMap.get(event.getName());
if (command.isDisabled()) {
event.reply(tl("discordErrorCommandDisabled")).setEphemeral(true).queue();
return;
}
event.deferReply(command.isEphemeral()).queue(null, failure -> logger.log(Level.SEVERE, "Error while deferring Discord command", failure));
final InteractionEvent interactionEvent = new InteractionEventImpl(event);
if (!DiscordUtil.hasRoles(event.getMember(), jda.getSettings().getCommandSnowflakes(command.getName()))) {
interactionEvent.reply(tl("noAccessCommand"));
return;
}
jda.getPlugin().getEss().scheduleSyncDelayedTask(() -> command.onCommand(interactionEvent));
}
use of net.essentialsx.api.v2.services.discord.InteractionEvent in project Essentials by EssentialsX.
the class InteractionControllerImpl method onSlashCommand.
@Override
public void onSlashCommand(@NotNull SlashCommandEvent event) {
if (event.getGuild() == null || event.getMember() == null || !commandMap.containsKey(event.getName())) {
return;
}
final InteractionCommand command = commandMap.get(event.getName());
if (command.isDisabled()) {
event.reply(tl("discordErrorCommandDisabled")).setEphemeral(true).queue();
return;
}
event.deferReply(command.isEphemeral()).queue(null, failure -> logger.log(Level.SEVERE, "Error while deferring Discord command", failure));
final InteractionEvent interactionEvent = new InteractionEventImpl(event);
if (!DiscordUtil.hasRoles(event.getMember(), jda.getSettings().getCommandSnowflakes(command.getName()))) {
interactionEvent.reply(tl("noAccessCommand"));
return;
}
jda.getPlugin().getEss().scheduleSyncDelayedTask(() -> command.onCommand(interactionEvent));
}
Aggregations