本文整理汇总了Java中sx.blah.discord.api.ClientBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java ClientBuilder.build方法的具体用法?Java ClientBuilder.build怎么用?Java ClientBuilder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sx.blah.discord.api.ClientBuilder
的用法示例。
在下文中一共展示了ClientBuilder.build方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例2: 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;
}
}
示例3: 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();
}