#How do I register all buttons with DIH4JDA without Spring?

40 messages · Page 1 of 1 (latest)

edgy cobalt
#

How do I register components like buttons in this case, similarly to JavaBot? but without the use of Spring? or any other libraries like Spring? I did try to copy JavaBots code on this, but it required Spring to work so, yeah. (DIH4JDA + JDA)

package com.hedreon.hedreobot;

import ..;

public class Bot {
    private static DIH4JDA dih4jda;

    private void registerButtons() {
        // code
    }

    @SuppressWarnings("unused")
    public static void main(String[] args) throws DIH4JDAException {
        Dotenv env = Dotenv.configure().load();
        String loginVar = env.get("TOKEN");

        JDA jda = JDABuilder.createDefault(loginVar).setActivity(Activity.watching("you")).build();
        dih4jda = DIH4JDABuilder.setJDA(jda).setCommandPackages("com.hedreon.hedreobot.commands").build();
        //dih4jda.addButtonMappings(IdMapping.of(new RulesCommand(), "rules-button"));

        dih4jda.addEventListener(new PermissionListener());
    }
}
whole meteorBOT
#

This post has been reserved for your question.

Hey @edgy cobalt! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

edgy cobalt
#

Man I haven't worked on my bot in months due to this problem (registering all buttons help)

edgy cobalt
#

How do I register all buttons with DIH4JDA without Spring?

whole meteorBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.

edgy cobalt
#

re-opened; not answered yet.

#

(I haven't really used this server nor coded the bot in months, so, I forgot what else to include)

tender laurel
#

register?

edgy cobalt
#

yeah like, adding button mappings

tender laurel
#

message components don't need to be registered, just application commands

#

oh

#

yeah that makes sense

edgy cobalt
#

so I don't have to add that spam of button mappings

#

since it would be quite annoying

tender laurel
#

not sure what exactly is convention with jda, but from experience with djs there's 2 main approaches
making temporary listeners each time you need to, or making a permanent listener that checks for the custom-id to do whatever it needs to do

edgy cobalt
#

but within JavaBot's code, they register component handlers, and they register buttons, button mappings to be exact, within one line! (if you exclude what requires it to work, which requires the Spring framework), like, they put button mappings to an array list, from what I could understand and they also add component handlers, so, tl;dr, my message is basically the same as yours, but instead of listeners, it's component handling I think

tender laurel
#

you need listeners to handle components

edgy cobalt
tender laurel
#

isn't it just addEventListener?

#

interactions are given to you by discord via gateway events

#

you need a listener to receive the event, then you can pass execution off to an appropriate handler (which may just be itself)

edgy cobalt
#

just uh, thats registering classes

#

not button mappings

#

which needs to have an ID mapping or something

tender laurel
#

oh i think you're misunderstanding what i said, i meant you need listeners as part of handling components

#

not that listeners can handle components on their own

#

sorry

tender laurel
#

i don't have experience with jda at all, just dapi and djs, so i can't really help much, sorry

edgy cobalt
#

dan could help

#

just saying

whole meteorBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.

edgy cobalt
#

@gilded mural any suggestions?

gilded mural
#

DIH4JDA also does classpath scanning without Spring AFAIK

edgy cobalt
#

Off-topic; I'm nearly done my history project, just have to finish up and then I'll come back to bot coding.

edgy cobalt
whole meteorBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.

edgy cobalt
#

Closing post... I will make a new post about this in the future if I want to "re-open" it.