本文整理汇总了Java中net.dv8tion.jda.entities.Guild.isAvailable方法的典型用法代码示例。如果您正苦于以下问题:Java Guild.isAvailable方法的具体用法?Java Guild.isAvailable怎么用?Java Guild.isAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.dv8tion.jda.entities.Guild
的用法示例。
在下文中一共展示了Guild.isAvailable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkUnmutes
import net.dv8tion.jda.entities.Guild; //导入方法依赖的package包/类
public void checkUnmutes(JDA jda, FeedHandler handler, Feeds feeds)
{
if(jda.getStatus()!=JDA.Status.CONNECTED)
return;
List<String[]> expiredMutes = getExpiredMutes();
List<String[]> finished = new ArrayList<>();
for(String[] mute : expiredMutes)
{
Guild guild = jda.getGuildById(mute[Mutes.SERVERID]);
if(guild==null)
finished.add(mute);
else if(guild.isAvailable())
{
finished.add(mute);
User u = jda.getUserById(mute[Mutes.USERID]);
if(guild.isMember(u))
{
for(Role r : guild.getRolesForUser(u))
if(r.getName().equalsIgnoreCase("Muted"))
{
try{
guild.getManager().removeRoleFromUser(u, r).update();
String[] feed = feeds.feedForGuild(guild, Feeds.Type.MODLOG);
if(feed!=null && !feed[Feeds.DETAILS].contains("-mute"))
handler.submitText(Feeds.Type.MODLOG, guild, "\uD83D\uDD09 **"+u.getUsername()+"** (ID:"+u.getId()+") was unmuted.");
}catch(Exception e){System.out.println("Unable to remove a muted role on "+guild.getName()+" ("+guild.getId()+")");}
break;
}
}
else
{
handler.submitText(Feeds.Type.MODLOG, guild, "\uD83D\uDD09 "+(u==null ? "[???]" :"**"+u.getUsername()+"**")+" (ID:"+mute[Mutes.USERID]+") was unmuted.");
}
}
}
if(!finished.isEmpty())
removeAll(finished);
}
示例2: giveMonsterHunterRole
import net.dv8tion.jda.entities.Guild; //导入方法依赖的package包/类
public static void giveMonsterHunterRole(PrivateMessageReceivedEvent event)
{
if(!event.getAuthor().getId().equals(NEKO_ID) && !event.getAuthor().getId().equals(FUNKY_ID))
return;
String[] parts = event.getMessage().getRawContent().split(":");
User user = event.getJDA().getUserById(parts[0]);
Guild mhgh = event.getJDA().getGuildById(MHGH_ID);
if(user==null || mhgh==null || !mhgh.isAvailable() || !mhgh.isMember(user))
return;
int hr = Integer.parseInt(parts[1]);
if(hr==0)
return;
Role member = mhgh.getRoleById(MEMBER);
synchronized(mhgh.getManager()){
if(!mhgh.getRolesForUser(user).contains(member))
mhgh.getManager().addRoleToUser(user, member);
boolean gotten=false;
for(int i=MH_LEVELS.length-1; i>=0; i--)
{
Role role = mhgh.getRoleById(HR_ROLES[i]);
if(hr>=MH_LEVELS[i] && !gotten)
{
if(!mhgh.getRolesForUser(user).contains(role))
mhgh.getManager().addRoleToUser(user, role);
gotten=true;
}
else
{
if(mhgh.getRolesForUser(user).contains(role))
mhgh.getManager().removeRoleFromUser(user, role);
}
}
mhgh.getManager().update();
}
}
示例3: submitText
import net.dv8tion.jda.entities.Guild; //导入方法依赖的package包/类
public void submitText(Feeds.Type type, List<Guild> guilds, String text)
{
if(type==Feeds.Type.MODLOG || type== Feeds.Type.SERVERLOG || type==Feeds.Type.TAGLOG)
text = logFormat(text);
else if (type==Feeds.Type.BOTLOG)
text = botlogFormat(text);
for(Guild guild : guilds)
{
if(lists.getState(guild.getId())==GlobalLists.ListState.BLACKLIST)
continue;
String[] matching = feeds.feedForGuild(guild, type);
if(matching==null)
continue;
TextChannel target = guild.getJDA().getTextChannelById(matching[Feeds.CHANNELID]);
if(target==null)
{
if(guild.isAvailable())//channel was deleted
{
feeds.removeFeed(matching);
}
continue;
}
if(!target.checkPermission(target.getJDA().getSelfInfo(), Permission.MESSAGE_READ, Permission.MESSAGE_WRITE))
{
feeds.removeFeed(matching);
Sender.sendPrivate(SpConst.WARNING+"Feed `"+matching[Feeds.FEEDTYPE]+"` has been removed from <#"
+target.getId()+"> because I cannot send messages there.", guild.getOwner().getPrivateChannel());
continue;
}
synchronized(buffers){
Buffer buffer = buffers.get(guild.getId());
if(buffer==null)
{
Long ratelimit = ((JDAImpl)guild.getJDA()).getMessageLimit(guild.getId());
if(ratelimit!=null)
{
buffer = new Buffer(text);
buffers.put(guild.getId(), buffer);
bufferTimers.schedule(() -> {
synchronized(buffers)
{
buffers.remove(guild.getId());
Buffer thisbuffer = buffers.get(guild.getId());
String txt = thisbuffer.getBuffer();
if(txt!=null)
Sender.sendMsg(thisbuffer.getBuffer(), target);
if(thisbuffer.getFile()!=null)
{
Sender.sendMsgFile(thisbuffer.getFileText(), thisbuffer.getFile(), thisbuffer.getFileAltText(), target);
}
statistics.sentFeed(guild.getId());
}
}, Math.min(ratelimit-System.currentTimeMillis()+10, 10000), TimeUnit.MILLISECONDS);
}
else
{
Sender.sendMsg(text, target);
statistics.sentFeed(guild.getId());
}
}
else
{
buffer.append(text);
}
}
}
}