當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。