use of sx.blah.discord.api.IDiscordClient in project Discord4J by Discord4J.
the class EmptyBot method main.
public static void main(String[] args) {
((Discord4J.Discord4JLogger) Discord4J.LOGGER).setLevel(Discord4J.Discord4JLogger.Level.DEBUG);
// Log.setLog(new Logger() {
// @Override
// public String getName() {
// return "sdfsdsdfsf";
// }
//
// @Override
// public void warn(String s, Object... objects) {
// Discord4J.LOGGER.warn(s, objects);
// }
//
// @Override
// public void warn(Throwable throwable) {
// Discord4J.LOGGER.warn("", throwable);
// }
//
// @Override
// public void warn(String s, Throwable throwable) {
// Discord4J.LOGGER.warn(s, throwable);
// }
//
// @Override
// public void info(String s, Object... objects) {
// Discord4J.LOGGER.info(s, objects);
// }
//
// @Override
// public void info(Throwable throwable) {
// Discord4J.LOGGER.info("", throwable);
// }
//
// @Override
// public void info(String s, Throwable throwable) {
// Discord4J.LOGGER.info(s, throwable);
// }
//
// @Override
// public boolean isDebugEnabled() {
// return true;
// }
//
// @Override
// public void setDebugEnabled(boolean b) {
//
// }
//
// @Override
// public void debug(String s, Object... objects) {
// Discord4J.LOGGER.debug(s, objects);
// }
//
// @Override
// public void debug(String s, long l) {
// Discord4J.LOGGER.debug(s, l);
// }
//
// @Override
// public void debug(Throwable throwable) {
// Discord4J.LOGGER.debug("", throwable);
// }
//
// @Override
// public void debug(String s, Throwable throwable) {
// Discord4J.LOGGER.debug(s, throwable);
// }
//
// @Override
// public Logger getLogger(String s) {
// return this;
// }
//
// @Override
// public void ignore(Throwable throwable) {
//
// }
// });
IDiscordClient client = new ClientBuilder().withToken(args[0]).registerListener(new IListener<ReadyEvent>() {
@Override
public void handle(ReadyEvent event) {
System.out.println("Ohai");
}
}).login();
}
use of sx.blah.discord.api.IDiscordClient in project Discord4J by Discord4J.
the class Discord4J method main.
/**
* Runs Discord4J using modules only.
*
* @param args The args should only include the bot token.
*/
public static void main(String[] args) {
// This functionality is dependent on these options being true
if (!Configuration.AUTOMATICALLY_ENABLE_MODULES || !Configuration.LOAD_EXTERNAL_MODULES)
throw new RuntimeException("Invalid configuration! Must have auto-enabling of modules + loading of external modules enabled.");
if (args.length == 0)
throw new RuntimeException("Invalid configuration! No arguments passed in.");
try {
ClientBuilder builder = new ClientBuilder();
IDiscordClient client = builder.withToken(args[0]).login();
client.getDispatcher().registerListener((IListener<ReadyEvent>) (ReadyEvent e) -> {
LOGGER.info(LogMarkers.MAIN, "Logged in as {}", e.getClient().getOurUser().getName());
});
// The modules should handle the rest
} catch (DiscordException e) {
LOGGER.error(LogMarkers.MAIN, "There was an error initializing the client", e);
}
}
Aggregations