55 lines
1.5 KiB
Java
55 lines
1.5 KiB
Java
package me.bobert.netneutrality.context;
|
|
/*
|
|
* Copyright (c) anthorob
|
|
*
|
|
* https://discord.gg/qUa6zNFZsd
|
|
*/
|
|
|
|
import me.bobert.netneutrality.core.context.CommandContext;
|
|
import me.bobert.netneutrality.core.context.InteractionContext;
|
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
|
import net.dv8tion.jda.api.interactions.InteractionHook;
|
|
import net.dv8tion.jda.api.interactions.modals.Modal;
|
|
|
|
public class SlashCommandContext extends CommandContext implements InteractionContext {
|
|
private final SlashCommandInteractionEvent event;
|
|
|
|
public SlashCommandContext(SlashCommandInteractionEvent event) {
|
|
super(event.getJDA(), event.getGuild(), event.getChannel(), event.getMember(), event.getUser());
|
|
this.event = event;
|
|
}
|
|
|
|
@Override
|
|
public SlashCommandInteractionEvent getEvent() {
|
|
return event;
|
|
}
|
|
|
|
@Override
|
|
public InteractionHook getInteractionHook() {
|
|
if (!event.isAcknowledged())
|
|
throw new RuntimeException("Interaction isn't acknowledged yet");
|
|
|
|
return event.getHook();
|
|
}
|
|
|
|
@Override
|
|
public void deleteMessage() {
|
|
// not implemented
|
|
}
|
|
|
|
@Override
|
|
public void reply(Modal modal) {
|
|
event.replyModal(modal).queue();
|
|
}
|
|
|
|
@Override
|
|
public String parseCommandName() {
|
|
return event.getName();
|
|
}
|
|
|
|
@Override
|
|
public String getSubCommand() {
|
|
return event.getFullCommandName().split(" ")[1];
|
|
}
|
|
}
|