Register commands after jda starts
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.alttd.proxydiscordlink;
|
||||
|
||||
import com.alttd.proxydiscordlink.bot.commandManager.CommandManager;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.events.session.ReadyEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JDAListener extends ListenerAdapter {
|
||||
|
||||
private final JDA jda;
|
||||
|
||||
public JDAListener(JDA jda) {
|
||||
this.jda = jda;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReady(@NotNull ReadyEvent event) {
|
||||
CommandManager commandManager = new CommandManager(jda);
|
||||
jda.addEventListener(commandManager);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.alttd.proxydiscordlink.bot;
|
||||
|
||||
import com.alttd.proxydiscordlink.JDAListener;
|
||||
import com.alttd.proxydiscordlink.bot.commandManager.CommandManager;
|
||||
import com.alttd.proxydiscordlink.bot.listeners.DiscordRoleListener;
|
||||
import com.alttd.proxydiscordlink.config.BotConfig;
|
||||
@@ -34,12 +35,11 @@ public class Bot {
|
||||
.build();
|
||||
jda.setAutoReconnect(true);
|
||||
jda.addEventListener(
|
||||
new DiscordRoleListener());
|
||||
DiscordCommand.loadCommands();
|
||||
new DiscordRoleListener(),
|
||||
new JDAListener(jda)); //This executes code after jda is done loading
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
new CommandManager(jda);
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
|
||||
Reference in New Issue
Block a user