use of sx.blah.discord.api.ClientBuilder in project DiscordSailv2 by Vaerys-Dawn.
the class Client method main.
public static void main(String[] args) {
IDiscordClient client = new ClientBuilder().withToken(args[0]).build();
client.getDispatcher().registerListener((IListener<ReadyEvent>) readyEvent -> System.out.println("login successful"));
client.login();
}
use of sx.blah.discord.api.ClientBuilder in project de-DiscordBot by DACH-Discord.
the class Authorization method createClient.
public static IDiscordClient createClient(final String token, final boolean login) {
// Creates the ClientBuilder instance
ClientBuilder clientBuilder = new ClientBuilder();
// Adds the login info to the builder
clientBuilder.withToken(token);
try {
if (login) {
// Creates the client instance and logs the client in
return clientBuilder.login();
} else {
// Creates the client instance but it doesn't log the client in yet, you would have to call client.login() yourself
return clientBuilder.build();
}
} catch (DiscordException e) {
// This is thrown if there was a problem building the client
Util.error(e);
return null;
}
}
use of sx.blah.discord.api.ClientBuilder in project solinia3-core by mixxit.
the class Solinia3CorePlugin method createClient.
public static IDiscordClient createClient(String token, boolean login) {
ClientBuilder clientBuilder = new ClientBuilder();
clientBuilder.withToken(token);
try {
if (login) {
return clientBuilder.login();
} else {
return clientBuilder.build();
}
} catch (DiscordException e) {
e.printStackTrace();
return null;
}
}
use of sx.blah.discord.api.ClientBuilder in project DisCal-Discord-Bot by NovaFox161.
the class Main method createClient.
/**
* Creates the DisCal bot client.
*
* @param token The Bot Token.
* @return The client if successful, otherwise <code>null</code>.
*/
private static IDiscordClient createClient(String token) {
// Creates the ClientBuilder instance
ClientBuilder clientBuilder = new ClientBuilder();
// Adds the login info to the builder
clientBuilder.withToken(token).withRecommendedShardCount();
try {
return clientBuilder.login();
} catch (DiscordException e) {
e.printStackTrace();
}
return null;
}
use of sx.blah.discord.api.ClientBuilder in project Discord4J by Discord4J.
the class BaseBot method login.
/**
* A custom login() method to handle all of the possible exceptions and set the bot instance.
*/
public static BaseBot login(String token) {
// Initializing the bot variable
BaseBot bot = null;
// Creates a new client builder instance
ClientBuilder builder = new ClientBuilder();
// Sets the bot token for the client
builder.withToken(token);
try {
// Builds the IDiscordClient instance and logs it in
IDiscordClient client = builder.login();
// Creating the bot instance
bot = new BaseBot(client);
} catch (DiscordException e) {
// Error occurred logging in
System.err.println("Error occurred while logging in!");
e.printStackTrace();
}
return bot;
}
Aggregations