• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JDABuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PointVectorValuePair类代码示例发布时间:2022-05-22
下一篇:
Java ProgressUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap