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


Java Guild类代码示例

本文整理汇总了Java中net.dv8tion.jda.entities.Guild的典型用法代码示例。如果您正苦于以下问题:Java Guild类的具体用法?Java Guild怎么用?Java Guild使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: execute

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    String list = "";
    int count = 0;
    Guild discordbots = event.getJDA().getGuildById("110373943822540800");
    Role botsrole = null;
    if(discordbots!=null)
        for(Role r: discordbots.getRoles())
            if(r.getId().equals("110374777914417152"))
                botsrole = r;
    String bot = SafeEmote.BOT.get(event.getJDA())+" ";
    for(User u: event.getGuild().getUsers())
        if(u.isBot() || (botsrole!=null && discordbots!=null && discordbots.isMember(u) && discordbots.getRolesForUser(u).contains(botsrole)))
        {
            list+="\n"+(u.isBot()?bot:"\uD83D\uDC68 ")+u.getUsername()+" #"+u.getDiscriminator();
            count ++;
        }
    String str = SpConst.SUCCESS+"**"+count+"** bots found on **"+event.getGuild().getName()+"**:"+list;
    if(str.length()>2000)
    {
        Sender.sendResponse(SpConst.WARNING+"**"+count+"** bots found, so the list is not shown.", event);
        return true;
    }
    Sender.sendResponse(str, event);
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:27,代码来源:BotScan.java

示例2: execute

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    String id = (String)args[0];
    //String reason = (String)args[1];
    Guild guild = event.getJDA().getGuildById(id);
    if(guild==null)
    {
        Sender.sendResponse(SpConst.ERROR+"Not a valid Guild ID", event);
        return false;
    }
    if(lists.getState(id)==GlobalLists.ListState.GOLDLIST)
    {
        Sender.sendResponse(SpConst.WARNING+"**"+guild.getName()+"** is already goldlisted!", event);
        return false;
    }
    String[] entry = new String[lists.getSize()];
    entry[GlobalLists.ID] = id;
    entry[GlobalLists.LISTTYPE] = "GOLDLIST";
    entry[GlobalLists.REASON] = guild.getName();
    entry[GlobalLists.IDTYPE] = "GUILD";
    lists.set(entry);
    Sender.sendResponse(SpConst.SUCCESS+entry[GlobalLists.IDTYPE]+" with ID `"+id+"` ("+guild.getName()+") added to goldlist", event);
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:25,代码来源:GoldList.java

示例3: execute

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    Guild guild = event.getGuild();
    long onlineCount = guild.getUsers().stream().filter((u) -> 
            (u.getOnlineStatus()==OnlineStatus.ONLINE || u.getOnlineStatus()==OnlineStatus.AWAY))
            .count();
    long botCount = guild.getUsers().stream().filter(User::isBot).count();
    String str = "\uD83D\uDDA5 Information about **"+guild.getName()+"**:\n"
            +SpConst.LINESTART+"ID: **"+guild.getId()+"**\n"
            +SpConst.LINESTART+"Owner: **"+guild.getOwner().getUsername()+"** #"+guild.getOwner().getDiscriminator()+"\n"
        
            +SpConst.LINESTART+"Location: **"+guild.getRegion().getName()+"**\n"
            +SpConst.LINESTART+"Creation: **"+MiscUtil.getCreationTime(guild.getId()).format(DateTimeFormatter.RFC_1123_DATE_TIME)+"**\n"
        
            +SpConst.LINESTART+"Users: **"+guild.getUsers().size()+"** ("+onlineCount+" online, "+botCount+" bots)\n"
            +SpConst.LINESTART+"Channels: **"+guild.getTextChannels().size()+"** Text, **"+guild.getVoiceChannels().size()+"** Voice\n"
            +SpConst.LINESTART+"Verification: **"+(guild.getVerificationLevel().equals(VerificationLevel.HIGH)?"(╯°□°)╯︵ ┻━┻":guild.getVerificationLevel())+"**";
    if(guild.getIconUrl()!=null)
        str+="\n"+SpConst.LINESTART+"Server Icon: "+guild.getIconUrl();
    
    Sender.sendResponse(str, event);
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:24,代码来源:Server.java

示例4: execute

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    String id = (String)args[0];
    String details = (String)args[1];
    Guild guild = event.getJDA().getGuildById(id);
    if(lists.getState(id)==GlobalLists.ListState.WHITELIST)
    {
        Sender.sendResponse(SpConst.WARNING+(guild==null?"[???]":"**"+guild.getName()+"**")+" is already whitelisted!", event);
        return false;
    }
    String[] entry = new String[lists.getSize()];
    entry[GlobalLists.ID] = id;
    entry[GlobalLists.LISTTYPE] = "WHITELIST";
    entry[GlobalLists.REASON] = guild==null ? details : guild.getName();
    entry[GlobalLists.IDTYPE] = "GUILD";
    lists.set(entry);
    Sender.sendResponse(SpConst.SUCCESS+entry[GlobalLists.IDTYPE]+" with ID `"+id+"` ("+(guild==null ? "???" : guild.getName())+") added to whitelist", event);
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:20,代码来源:WhiteList.java

示例5: execute

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event)
{
    String[] mirrorlist= Settings.tagMirrorsFromList(settings.getSettingsForGuild(event.getGuild().getId())[Settings.TAGMIRRORS]);
    if(mirrorlist.length==0)
    {
        Sender.sendResponse(SpConst.WARNING+"No tag mirrors have been set up on **"+event.getGuild().getName()+"**", event);
        return true;
    }
    StringBuilder builder = new StringBuilder(SpConst.SUCCESS+mirrorlist.length+" tag mirrors on **"+event.getGuild().getName()+"**:");
    for(String id: mirrorlist)
    {
        Guild g = event.getJDA().getGuildById(id);
        if(g==null)
            continue;
        builder.append("\n").append(g.getName());
    }
    Sender.sendResponse(builder.toString(), event);
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:21,代码来源:Tag.java

示例6: execute

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    Guild g = event.getJDA().getGuildById((String)args[0]);
    if(g==null)
    {
        Sender.sendResponse(SpConst.ERROR+"Guild with ID `"+args[0]+"` not found!", event);
        return false;
    }
    long botcount = g.getUsers().stream().filter(User::isBot).count();
    long usercount = g.getUsers().stream().filter(u -> {
            return !u.isBot() && u.getAvatarId()!=null && MiscUtil.getCreationTime(u.getId()).plusDays(7).isBefore(OffsetDateTime.now());
        }).count();
    int requirements = spectra.meetsRequirements(g);
    StringBuilder builder = new StringBuilder(SpConst.SUCCESS+"Found **"+g.getName()+"**:");
    builder.append("\nOwner: ").append(FormatUtil.fullUser(g.getOwner()))
           .append("\nCreated: ").append(MiscUtil.getCreationTime(g.getId()).format(DateTimeFormatter.RFC_1123_DATE_TIME))
           .append("\nTotal users: ").append(g.getUsers().size())
           .append("\nReal users: ").append(usercount)
           .append("\nBots: ").append(botcount)
           .append("\nRequirements? ").append(requirements > 0 ? "No" : "Yes").append(" (").append(requirements).append(")");
    Sender.sendResponse(builder.toString(), event);
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:24,代码来源:SystemCmd.java

示例7: findTag

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
public String[] findTag(String name, Guild guild, boolean local, boolean nsfw)
{
    synchronized(data)
    {
        String[] tag = data.get(name.toLowerCase());
        if(tag!=null)
        {
            if(!nsfw && TagUtil.isNSFWTag(tag))
                return new String[]{tag[OWNERID],tag[TAGNAME],"\uD83D\uDD1E This tag has been marked as **Not Safe For Work** and is not available in this channel."};
            if(local && guild!=null)
            {
                User u = guild.getJDA().getUserById(tag[OWNERID]);
                if(u!=null && guild.isMember(u))
                    return tag;
                return null;
                //return new String[]{tag[OWNERID],tag[TAGNAME],SpConst.WARNING+"This tag does not belong to a user on this server."};
            }
            return tag.clone();
        }
    }
    return null;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:23,代码来源:Tags.java

示例8: findTags

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
public ArrayList<String[]> findTags(String search, Guild guild, boolean local, boolean nsfw)
{
    if(search==null)
        search="";
    ArrayList<String[]> results = new ArrayList<>();
    search = search.toLowerCase();
    synchronized(data)
    {
        for(String[] tag: data.values())
        {
            if(tag[TAGNAME].toLowerCase().contains(search) && (nsfw || !TagUtil.isNSFWTag(tag)))
            {
                if(local && guild!=null)
                {
                    User owner = guild.getJDA().getUserById(tag[OWNERID]);
                    if(owner!=null && guild.isMember(owner))
                        results.add(tag.clone());
                }
                else results.add(tag.clone());
            }
        }
    }
                
    return results;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:26,代码来源:Tags.java

示例9: GuildManager

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
public GuildManager(String accessID, ServerManager manager, Guild guild)
{
    super(guild);

    this.accessID = accessID;
    this.manager = manager;

    String basePath = String.format("_DATA/servers/%s.json", accessID);
    fileManager = new FileManager(basePath);
    fileManager.createIfNotFound();

    String content = fileManager.readText();
    
    if (content.length() == 0) jsonObject = new NullableJSONObject();
    else jsonObject = new NullableJSONObject(content);
    
    saveFile();

    this.userManager = new UserManager(this);
    this.commandManager = new GuildCommandManager(this);
    
    defaultSetup();
}
 
开发者ID:Gnar-Team,项目名称:Legacy-GN4R,代码行数:24,代码来源:GuildManager.java

示例10: GuildEntry

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
public GuildEntry(FontRenderer fr, Guild guild)
{
    this.fr = fr;
    this.guild = guild;
    GuiListButton b;

    // Mute server
    guiButtons.add(b = new GuiListButton(0, getListWidth() - 45, 0, 45, 20
            , Preferences.i.mutedGuilds.contains(guild.getId())
                ? TextFormatting.RED + "Unmute"
                : "Mute"));

    guiButtons.add(new GuiListButton(1, getListWidth() - 90, 0, 45, 20, "Leave"));
    guiButtons.add(new GuiListButton(2, getListWidth() - 141, 0, 50, 20, "Channels"));

    // Disabling mute if this is user's current server
    if (Preferences.i.usingGuild.equals(guild.getId()))
        b.enabled = false;
}
 
开发者ID:duke605,项目名称:DiscordCE,代码行数:20,代码来源:GuiServerList.java

示例11: getBans

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
public static List<Ban> getBans(Guild guild) {
    List<Ban> bans = new LinkedList<>();
    if(!initialized)
        return bans;
    try {
        banLookup.setString(1, guild.getId());
        ResultSet resultSet = banLookup.executeQuery();
        while(!resultSet.next()) {
            bans.add(new Ban(resultSet.getString("reason"), resultSet.getString("bannedId"), resultSet.getString("bannedName")
                    , resultSet.getString("executorId"), resultSet.getString("executorName"), resultSet.getInt("created")));
        }
        resultSet.close();
    } catch(SQLTimeoutException ex) {
        onTimeout();
    } catch(SQLException e) {
        LOG.log(e);
    }
    return bans;
}
 
开发者ID:kantenkugel,项目名称:KanzeBot,代码行数:20,代码来源:DbEngine.java

示例12: addBan

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
public static void addBan(Guild guild, User banned, User executor, String reason) {
    if(!initialized)
        return;
    if(reason.length() > 250) {
        reason = reason.substring(0, 247) + "...";
    }
    try {
        updateUser(banned);
        banAdd.setString(1, guild.getId());
        banAdd.setString(2, banned.getId());
        banAdd.setString(3, executor.getId());
        banAdd.setString(4, reason);
        banAdd.setTimestamp(5, new Timestamp(OffsetDateTime.now().toEpochSecond() * 1000));
        banAdd.executeUpdate();
    } catch(SQLTimeoutException ex) {
        onTimeout();
    } catch(SQLException e) {
        LOG.log(e);
    }
}
 
开发者ID:kantenkugel,项目名称:KanzeBot,代码行数:21,代码来源:DbEngine.java

示例13: modelToDto

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
@Override
public GuildDTO modelToDto(GuildEntity model) {
    GuildDTO dto = null;
    if(model != null){
        dto = new GuildDTO();

        final Guild guild = jda.getGuildById(Long.toString(model.getServerId()));
        final DiscordGuildDTO guildDTO = this.discordGuildTransformer.modelToDto(guild);
        dto.setServer(guildDTO);

        final TextChannel channel = jda.getTextChannelById(Long.toString(model.getChannelId()));
        final DiscordChannelDTO channelDTO = this.discordChannelTransformer.modelToDto(channel);
        dto.setChannel(channelDTO);
        dto.setActive(model.isActive());
        dto.setCompact(model.isCompact());
        dto.setCleanup(model.getCleanup());

        final List<QueueItemDTO> queueItems = this.queueItemTransformer.modelToDto(new ArrayList<QueueitemEntity>(model.getQueue()));
        dto.setQueue(queueItems);

        final List<UserDTO> notifications = this.notificationTransformer.modelToDto(new ArrayList<NotificationEntity>(model.getNotifications()));
        dto.setNotifications(notifications);

        final List<PermissionDTO> permissions = this.permissionTransformer.modelToDto(new ArrayList<PermissionEntity>(model.getPermissions()));
        dto.setPermissions(permissions);
    }
    return dto;
}
 
开发者ID:Gyoo,项目名称:Discord-Streambot,代码行数:29,代码来源:GuildTransformer.java

示例14: modelToDto

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
@Override
public DiscordGuildDTO modelToDto(Guild model) {
    DiscordGuildDTO dto = null;
    if(model != null){
        dto = new DiscordGuildDTO();
        dto.setId(model.getId());
        dto.setName(model.getName());
        dto.setIconURL(model.getIconUrl());
    }
    return dto;
}
 
开发者ID:Gyoo,项目名称:Discord-Streambot,代码行数:12,代码来源:DiscordGuildTransformer.java

示例15: execute

import net.dv8tion.jda.entities.Guild; //导入依赖的package包/类
@Override
protected boolean execute(Object[] args, MessageReceivedEvent event) {
    String text = (String)args[0];
    List<Guild> list = new ArrayList<>();
    feeds.findGuildsForFeedType(Feeds.Type.ANNOUNCEMENTS).stream().filter((id) -> (event.getJDA().getGuildById(id)!=null)).forEach((id) -> {
        list.add(event.getJDA().getGuildById(id));
    });
    handler.submitText(Feeds.Type.ANNOUNCEMENTS, list, text);
    Sender.sendResponse(SpConst.SUCCESS+"Sent to **"+list.size()+"** guilds", event);
    return true;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:12,代码来源:AnnounceFeed.java


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