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


Java Guild.isAvailable方法代码示例

本文整理汇总了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);
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:39,代码来源:Mutes.java

示例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();
    }
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:36,代码来源:SpecialCase.java

示例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);
            }
        }
    }
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:68,代码来源:FeedHandler.java


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