use of com.dynxsty.dih4jda.commands.interactions.context_command.dao.BaseContextCommand in project DIH4JDA by DynxstyGIT.
the class InteractionHandler method registerContextCommands.
/**
* Registers all context commands. Loops through all classes found in the commands package that is a subclass of {@link BaseContextCommand}.
*/
private void registerContextCommands() {
Reflections commands = new Reflections(this.dih4jda.getCommandsPackage());
Set<Class<? extends BaseContextCommand>> classes = commands.getSubTypesOf(BaseContextCommand.class);
for (Class<? extends BaseContextCommand> c : classes) {
if (c.getSuperclass().equals(GlobalContextCommand.class)) {
globalContexts.add(c);
} else if (c.getSuperclass().equals(GuildContextCommand.class)) {
guildContexts.add(c);
}
}
}
use of com.dynxsty.dih4jda.commands.interactions.context_command.dao.BaseContextCommand in project DIH4JDA by DynxstyGIT.
the class InteractionHandler method getGlobalContextCommandData.
/**
* Gets all Global Context commands registered in {@link InteractionHandler#registerContextCommands()} and
* returns their {@link CommandData} as a List.
*
* @throws Exception If an error occurs.
*/
private Set<CommandData> getGlobalContextCommandData() throws Exception {
Set<CommandData> commands = new HashSet<>();
for (Class<? extends BaseContextCommand> contextCommandClass : this.globalContexts) {
BaseContextCommand instance = (BaseContextCommand) this.getClassInstance(null, contextCommandClass);
CommandData data = this.getContextCommandData(instance, contextCommandClass);
if (data != null) {
commands.add(data);
}
}
DIH4JDALogger.info("[*] Queuing Global Context Commands", DIH4JDALogger.Type.CONTEXT_COMMANDS_QUEUED);
return commands;
}
use of com.dynxsty.dih4jda.commands.interactions.context_command.dao.BaseContextCommand in project DIH4JDA by DynxstyGIT.
the class InteractionHandler method getGuildContextCommandData.
/**
* Gets all Guild Context commands registered in {@link InteractionHandler#registerContextCommands()} and
* returns their {@link CommandData} as a List.
*
* @param guild The context command's guild.
* @throws Exception If an error occurs.
*/
private Set<CommandData> getGuildContextCommandData(@NotNull Guild guild) throws Exception {
Set<CommandData> commands = new HashSet<>();
for (Class<? extends BaseContextCommand> contextCommandClass : this.guildContexts) {
BaseContextCommand instance = (BaseContextCommand) this.getClassInstance(guild, contextCommandClass);
commands.add(this.getContextCommandData(instance, contextCommandClass));
}
DIH4JDALogger.info(String.format("[%s] Queuing Guild Context Commands", guild.getName()), DIH4JDALogger.Type.CONTEXT_COMMANDS_QUEUED);
return commands;
}
Aggregations