82 lines
3.3 KiB
Java
82 lines
3.3 KiB
Java
package net.nevet5.buzzbot;
|
|
|
|
import net.dv8tion.jda.api.JDA;
|
|
import net.dv8tion.jda.api.JDABuilder;
|
|
import net.dv8tion.jda.api.entities.Activity;
|
|
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
|
|
|
import javax.security.auth.login.LoginException;
|
|
import java.util.EnumSet;
|
|
|
|
public class Bot {
|
|
public static JDA jda;
|
|
|
|
public static void main(String[] args) {
|
|
Config.loadConfig();
|
|
|
|
try {
|
|
jda = JDABuilder.createDefault(Config.getConfig().getString("bot.token"))
|
|
.disableCache(EnumSet.of(
|
|
CacheFlag.CLIENT_STATUS,
|
|
CacheFlag.ACTIVITY,
|
|
CacheFlag.EMOTE
|
|
))
|
|
.enableCache(CacheFlag.VOICE_STATE)
|
|
.addEventListeners(new Listener())
|
|
.build();
|
|
getActivity();
|
|
} catch (LoginException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public static void getActivity() {
|
|
if (Config.getConfig().getString("bot.activity").equalsIgnoreCase("playing")) {
|
|
jda.getPresence().setActivity(Activity.playing(Config.getConfig().getString("bot.action")));
|
|
} else if (Config.getConfig().getString("bot.activity").equalsIgnoreCase("watching")) {
|
|
jda.getPresence().setActivity(Activity.watching(Config.getConfig().getString("bot.action")));
|
|
} else if (Config.getConfig().getString("bot.activity").equalsIgnoreCase("competing")) {
|
|
jda.getPresence().setActivity(Activity.competing(Config.getConfig().getString("bot.action")));
|
|
} else if (Config.getConfig().getString("bot.activity").equalsIgnoreCase("listening")) {
|
|
jda.getPresence().setActivity(Activity.listening(Config.getConfig().getString("bot.action")));
|
|
} else if (Config.getConfig().getString("bot.activity").equalsIgnoreCase("debug")) {
|
|
jda.getPresence().setActivity(Activity.listening("my prefix " + Config.getConfig().getString("bot.prefix")));
|
|
} else {
|
|
jda.getPresence().setActivity(Activity.playing("with myself!"));
|
|
}
|
|
}
|
|
|
|
// public static void main(String[] args) {
|
|
// Config.loadConfig();
|
|
//
|
|
// JDABuilder jdaBotBuilder = JDABuilder.createDefault(Config.getConfig().getString("bot.token"));
|
|
// // A token must be provided
|
|
//
|
|
// /* Start the JDA bot builder, letting you provide the token externally rather
|
|
// * than writing it in your program's code. args[0] is the token. */
|
|
//
|
|
// // Disable parts of the cache
|
|
// jdaBotBuilder.disableCache(CacheFlag.MEMBER_OVERRIDES, CacheFlag.VOICE_STATE);
|
|
//
|
|
// // Enable the bulk delete event - this means you'll have to handle it yourself!
|
|
// jdaBotBuilder.setBulkDeleteSplittingEnabled(false);
|
|
//
|
|
// // Set activity (like "playing Something")
|
|
//
|
|
// // Set event listeners
|
|
// jdaBotBuilder.addEventListeners(/*new MessageListener(), new ReadyListener()*/);
|
|
//
|
|
// try {
|
|
// // create the instance of JDA
|
|
// JDA discordBot = jdaBotBuilder.build();
|
|
//
|
|
// // optionally block until JDA is ready
|
|
// discordBot.awaitReady();
|
|
// } catch (LoginException | InterruptedException e) {
|
|
// System.err.println("Couldn't login.");
|
|
// e.printStackTrace();
|
|
// }
|
|
// }
|
|
}
|
|
|