当前位置: 首页>>代码示例>>Java>>正文


Java JDA.ShardInfo方法代码示例

本文整理汇总了Java中net.dv8tion.jda.core.JDA.ShardInfo方法的典型用法代码示例。如果您正苦于以下问题:Java JDA.ShardInfo方法的具体用法?Java JDA.ShardInfo怎么用?Java JDA.ShardInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.dv8tion.jda.core.JDA的用法示例。


在下文中一共展示了JDA.ShardInfo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onGuildLeave

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
@Override
public void onGuildLeave( GuildLeaveEvent event )
{
    /* Disabled reactive database pruning as the Discord API seems to like to send GuildLeave notifications
       during discord outages

    // purge the leaving guild's entry list
    Main.getDBDriver().getEventCollection().deleteMany(eq("guildId", event.getGuild().getId()));
    // remove the guild's schedules
    Main.getDBDriver().getScheduleCollection().deleteMany(eq("guildId", event.getGuild().getId()));
    // remove the guild's settings
    Main.getDBDriver().getGuildCollection().deleteOne(eq("_id", event.getGuild().getId()));
    */

    JDA.ShardInfo info = event.getJDA().getShardInfo();
    HttpUtilities.updateStats(info==null ? null : info.getShardId());
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:18,代码来源:EventListener.java

示例2: action

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
@Override
public void action(String prefix, String[] args, MessageReceivedEvent event)
{
    JDA.ShardInfo info = event.getJDA().getShardInfo();
    Runtime rt = Runtime.getRuntime();
    RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();

    String msg = "```python\n" +
            "\"Database\"\n" +
            "      Entries: " + Main.getDBDriver().getEventCollection().count() + "\n" +
            "    Schedules: " + Main.getDBDriver().getScheduleCollection().count() + "\n" +
            "       Guilds: " + Main.getDBDriver().getGuildCollection().count() + "\n" +
            "\n\"Shard\"\n" +
            "      ShardId: " + info.getShardId() + "/" + info.getShardTotal() + "\n" +
            "       Guilds: " + event.getJDA().getGuilds().size() + "\n" +
            "        Users: " + event.getJDA().getUsers().size() + "\n" +
            "ResponseTotal: " + event.getJDA().getResponseTotal() + "\n" +
            "\n\"Application\"\n" +
            " Memory-total: " +rt.totalMemory()/1024/1024 + " MB\n" +
            "       -free : " + rt.freeMemory()/1024/1024 + " MB\n" +
            "       -max  : " + rt.maxMemory()/1024/1024 + " MB\n" +
            "      Threads: " + Thread.activeCount() + "\n" +
            "       Uptime: " + rb.getUptime()/1000/60 + " minute(s)" +
            "```";

    if(event.isFromType(ChannelType.PRIVATE))
    {
        MessageUtilities.sendPrivateMsg( msg, event.getAuthor(), null );
    }
    else
    {
        MessageUtilities.sendMsg( msg, event.getTextChannel(), null );
    }
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:35,代码来源:StatsCommand.java

示例3: onGuildJoin

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
@Override
public void onGuildJoin( GuildJoinEvent event )
{
    // leave guild if guild is blacklisted
    if(Main.getBotSettingsManager().getBlackList().contains(event.getGuild().getId()))
    {
        event.getGuild().leave().queue();
        return;
    }

    // identify which shard is responsible for the guild
    String guildId = event.getGuild().getId();
    JDA jda = Main.getShardManager().isSharding() ? Main.getShardManager().getShard(guildId) : Main.getShardManager().getJDA();

    // send welcome message to the server owner
    String welcomeMessage = "```diff\n- Joined```\n" +
            "**" + jda.getSelfUser().getName() + "**, a calendar bot, has been added to the guild you own, '"
            + event.getGuild().getName() + "'." +
            "\n\n" +
            "If this is your first time using the bot, you will need to create a new channel in your guild named" +
            " **" + Main.getBotSettingsManager().getControlChan() + "** to control the bot.\n" +
            "The bot will not listen to commands in any other channel!" +
            "\n\n" +
            "If you have not yet reviewed the **Quickstart** guide (as seen on the bots.discord.pw listing), " +
            "it may be found here: https://bots.discord.pw/bots/250801603630596100";
    MessageUtilities.sendPrivateMsg(
            welcomeMessage,
            event.getGuild().getOwner().getUser(),
            null
    );

    // update web stats
    JDA.ShardInfo info = event.getJDA().getShardInfo();
    HttpUtilities.updateStats(info==null ? null : info.getShardId());
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:36,代码来源:EventListener.java

示例4: getShardString

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
public static String getShardString(JDA.ShardInfo shardInfo) {
    int shardId = shardInfo.getShardId();
    int shardCount = shardInfo.getShardTotal();

    return "[" + (shardId + 1) + " / " + shardCount + "]";
}
 
开发者ID:Samoxive,项目名称:SafetyJim,代码行数:7,代码来源:DiscordUtils.java

示例5: postStats

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
public void postStats() {
    if(GabrielBot.DEBUG) return;

    int guildCount = (int)jda.getGuildCache().size();
    JSONObject payload = new JSONObject().put("server_count", guildCount);
    JDA.ShardInfo info = jda.getShardInfo();
    int shardId, totalShards;
    if(info != null) {
        payload.put("shard_id", shardId = info.getShardId()).put("shard_count", totalShards = info.getShardTotal());
    } else {
        shardId = 0;
        totalShards = 1;
    }

    GabrielBot.getInstance().discordBotsAPI.postStats(jda.getSelfUser().getIdLong(), shardId, totalShards, guildCount);

    botspw: {
        String token = GabrielData.config().botsPwToken;
        if(token == null || token.isEmpty()) break botspw;
        try {
            REQUESTER.newRequest("https://bots.discord.pw/api/bots/" + jda.getSelfUser().getId() + "/stats")
                    .header("Authorization", token)
                    .header("Content-Type", "application/json")
                    .body(payload)
                    .post();
        } catch(Exception e) {
            logger.error("Error posting stats to bots.discord.pw", e.getCause());
        }
    }

    /*carbon: {
        String token = GabrielData.config().carbonToken;
        if(token == null || token.isEmpty()) break carbon;
        try {
            REQUESTER.execute(new Request.Builder()
                    .url("https://www.carbonitex.net/discord/data/botdata.php")
                    .post(new FormBody.Builder()
                            .add("key", token)
                            .add("servercount", String.valueOf(guildCount))
                            .add("shardid", String.valueOf(shardId))
                            .add("shardcount", String.valueOf(totalShards)).build())
                    .build());
        } catch(Exception e) {
            logger.error("Error posting stats to carbonitex.net", e);
        }
    }*/
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:48,代码来源:Shard.java


注:本文中的net.dv8tion.jda.core.JDA.ShardInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。