本文整理汇总了Java中sx.blah.discord.api.ClientBuilder.withToken方法的典型用法代码示例。如果您正苦于以下问题:Java ClientBuilder.withToken方法的具体用法?Java ClientBuilder.withToken怎么用?Java ClientBuilder.withToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sx.blah.discord.api.ClientBuilder
的用法示例。
在下文中一共展示了ClientBuilder.withToken方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import sx.blah.discord.api.ClientBuilder; //导入方法依赖的package包/类
@Override
public void run(String... arg0) throws Exception
{
IDiscordClient client;
ClientBuilder clientBuilder = new ClientBuilder();
clientBuilder.withToken(token);
try
{
client = clientBuilder.login();
EventDispatcher dispatcher = client.getDispatcher();
dispatcher.registerListener(new LeaderboardDiscordActions(client, prefix, leaderboardDao, leaderboardColumnDao));
}
catch (DiscordException e)
{
e.printStackTrace();
System.exit(0);
}
}
示例2: createClient
import sx.blah.discord.api.ClientBuilder; //导入方法依赖的package包/类
public static IDiscordClient createClient(String token, boolean login) { // Returns a new instance of the Discord client
ClientBuilder clientBuilder = new ClientBuilder(); // Creates the ClientBuilder instance
clientBuilder.withToken(token); // Adds the login info to the builder
try {
if (login) {
return clientBuilder.login(); // Creates the client instance and logs the client in
} else {
return clientBuilder.build(); // Creates the client instance but it doesn't log the client in yet, you would have to call client.login() yourself
}
} catch (DiscordException e) { // This is thrown if there was a problem building the client
e.printStackTrace();
return null;
}
}
示例3: createClient
import sx.blah.discord.api.ClientBuilder; //导入方法依赖的package包/类
private 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;
}
}
示例4: newClientBuilder
import sx.blah.discord.api.ClientBuilder; //导入方法依赖的package包/类
private ClientBuilder newClientBuilder() {
LeagueProperties.Discord discord = properties.getDiscord();
ClientBuilder builder = new ClientBuilder()
.withPingTimeout(discord.getMaxMissedPings())
.setMaxReconnectAttempts(discord.getMaxReconnects());
if (discord.getToken() != null) {
return builder.withToken(discord.getToken());
} else {
throw new IllegalArgumentException("Must configure a bot token");
}
}
示例5: getClientBuilder
import sx.blah.discord.api.ClientBuilder; //导入方法依赖的package包/类
public static ClientBuilder getClientBuilder(String token) throws DiscordException {
ClientBuilder clientBuilder = new ClientBuilder();
clientBuilder.withToken(token);
clientBuilder.setMaxReconnectAttempts(64);
clientBuilder.setDaemon(false);
return clientBuilder;
}
示例6: discordClient
import sx.blah.discord.api.ClientBuilder; //导入方法依赖的package包/类
@Bean
public static IDiscordClient discordClient(@Value("${bot.discord.token}") String token) throws DiscordException {
ClientBuilder builder = new ClientBuilder();
builder.withToken(token);
return builder.build();
}