本文整理汇总了Java中net.dv8tion.jda.JDABuilder类的典型用法代码示例。如果您正苦于以下问题:Java JDABuilder类的具体用法?Java JDABuilder怎么用?Java JDABuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JDABuilder类属于net.dv8tion.jda包,在下文中一共展示了JDABuilder类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: GnarBot
import net.dv8tion.jda.JDABuilder; //导入依赖的package包/类
private GnarBot(String token)
{
try
{
final JDA jda = new JDABuilder().setBotToken(token).buildBlocking();
jda.getAccountManager().setUsername("GNAR");
jda.getAccountManager().setGame("_help | _invite");
jda.getAccountManager().update();
jda.setAutoReconnect(true);
DiscordBotsInfo.updateServerCount(jda);
serverManager = new ServerManager(jda);
}
catch (LoginException | InterruptedException e)
{
e.printStackTrace();
}
}
开发者ID:Gnar-Team,项目名称:Legacy-GN4R,代码行数:22,代码来源:GnarBot.java
示例2: main
import net.dv8tion.jda.JDABuilder; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
try {
SimpleLog.addFileLogs(null,new File("err" + System.currentTimeMillis() + ".txt"));
} catch (IOException e) {
Logger.writeToErr(e, "");
}
Dao dao = new Dao();
List<Platform> platforms;
String token = PropertiesReader.getInstance().getProp().getProperty("bot.token");
DiscordController discordController = new DiscordController(dao);
JDA jda = new JDABuilder()
.setBotToken(token)
.addListener(discordController)
.buildBlocking();
discordController.setJda(jda);
Thread messageConsumer = new MessageConsumer(MessageHandler.getQueue(), jda, dao);
messageConsumer.start();
Thread messageFinder = new MessageFinder(MessageHandler.getDeleteQueue(), jda);
messageFinder.start();
platforms = setPlatforms(dao, jda);
WebController webController = new WebController(jda, dao);
webController.serve();
platforms.forEach(Platform::checkStillOnline);
int ticks = 0;
while(true){
if(!((JDAImpl)jda).getClient().isConnected()){
while (!((JDAImpl)jda).getClient().isConnected()){
Thread.sleep(1000);
}
discordController.setJda(jda);
platforms = setPlatforms(dao, jda);
//webController.setJda(jda);
continue;
}
if(!messageConsumer.isAlive()){
messageConsumer = new MessageConsumer(MessageHandler.getQueue(), jda, dao);
messageConsumer.start();
}
if(!messageFinder.isAlive()){
messageFinder = new MessageFinder(MessageHandler.getDeleteQueue(), jda);
messageFinder.start();
}
if(ticks < 10){
Session session = HibernateUtil.getSession();
List<Long> guildIDs = session.createCriteria(GuildEntity.class)
.setProjection(Projections.property("id")).list();
List<Guild> connectedGuilds = jda.getGuilds();
for(Guild connectedGuild : connectedGuilds){
Long connectedGuildID = Long.parseLong(connectedGuild.getId());
if(guildIDs.contains(connectedGuildID)){
for(Platform platform : platforms){
platform.checkStreams(connectedGuildID);
}
}
}
ticks++;
}
else{
platforms.forEach(Platform::checkStillOnline);
ticks = 0;
}
Thread.sleep(60000);
}
}
开发者ID:Gyoo,项目名称:Discord-Streambot,代码行数:78,代码来源:Main.java
示例3: main
import net.dv8tion.jda.JDABuilder; //导入依赖的package包/类
public static void main(String[] args) {
// Set up logging
LogManager.getLogManager().reset();
Handler handler = new ConsoleHandler();
handler.setLevel(Level.ALL);
handler.setFormatter(new LogFormatter());
Logger.getLogger("").addHandler(handler);
// Redirect default System.out to the logger (because JDA does not use java logging...)
System.setOut(new PrintStream(System.out) {
@Override
public void print(String s) {
Logger.getLogger("System.out").info(s);
}
});
LOG.info("Starting...");
// Try to find VLC
boolean found = new NativeDiscovery().discover();
if (found) LOG.info("Found VLC: " + LibVlc.INSTANCE.libvlc_get_version());
else {
LOG.severe("Could not find VLC, exiting");
System.exit(-1);
}
// AudioService
AudioService audioService = new AudioService();
try {
// Load configuration
new ConfigurationBuilder(new File("config.properties")).build();
// Start JDA
JDA jda = new JDABuilder()
.setEmail(Configuration.EMAIL)
.setPassword(Configuration.PASSWORD)
.addListener(new JoinMessageListener(audioService))
.addListener(new CommandListener(audioService))
.buildAsync();
// Log to the specified log channel
if (!Configuration.LOG_CHANNEL.isEmpty()) {
ChannelLogHandler channelLogHandler = new ChannelLogHandler(jda, new LogFormatter());
Logger.getLogger("").addHandler(channelLogHandler);
}
} catch (Exception e) {
LOG.log(Level.SEVERE, "An unexpected error occurred", e);
}
}
开发者ID:flaiker,项目名称:bottimus,代码行数:51,代码来源:Main.java
注:本文中的net.dv8tion.jda.JDABuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论