add Discord4J Wrapper #14

Merged
tueem merged 13 commits from wrapper/d4j into dev 2025-02-19 12:43:38 +00:00
3 changed files with 5 additions and 5 deletions
Showing only changes of commit b4af922ac2 - Show all commits

View File

@ -66,7 +66,7 @@ public class InteractionRegistry {
} }
public void handle(Object context) { public void handle(Object context) {
InteractionType type = marinara.getWrapper().getInteractionType(context.getClass()); InteractionType type = marinara.getWrapper().getInteractionType(context);
logger.debug("Received {} interaction ", context); logger.debug("Received {} interaction ", context);
interactionMethods.forEach((m) -> { interactionMethods.forEach((m) -> {
if (m.getType().equals(type) && m.canRun(context)) { if (m.getType().equals(type) && m.canRun(context)) {

View File

@ -29,7 +29,7 @@ public abstract class LibraryWrapper {
interactionSubscriber.remove(consumer); interactionSubscriber.remove(consumer);
} }
public abstract InteractionType getInteractionType(Class<?> clazz); public abstract InteractionType getInteractionType(Object context);
public abstract void registerSlashCommands(SlashCommandDefinition[] defs); public abstract void registerSlashCommands(SlashCommandDefinition[] defs);
public abstract Object convertCommandOption(Object context, SlashCommandOptionType type, String optionName); public abstract Object convertCommandOption(Object context, SlashCommandOptionType type, String optionName);

View File

@ -42,10 +42,10 @@ public class JavacordWrapper extends LibraryWrapper {
} }
@Override @Override
public InteractionType getInteractionType(Class<?> clazz) { public InteractionType getInteractionType(Object context) {
if (ApplicationCommandInteraction.class.isAssignableFrom(clazz)) if (ApplicationCommandInteraction.class.isAssignableFrom(context.getClass()))
return InteractionType.COMMAND; return InteractionType.COMMAND;
if (ButtonInteraction.class.isAssignableFrom(clazz)) if (ButtonInteraction.class.isAssignableFrom(context.getClass()))
return InteractionType.BUTTON; return InteractionType.BUTTON;
return null; return null;