本文整理汇总了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());
}
示例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 );
}
}
示例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());
}
示例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 + "]";
}
示例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);
}
}*/
}