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


Java Guild类代码示例

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


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

示例1: onGuildJoin

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
@Override
public void onGuildJoin(GuildJoinEvent event) {
    Guild guild = event.getGuild();
    MessageEmbed embed = createWelcomeMessage(guild);
    guild.getOwner().getUser().openPrivateChannel().submit().whenComplete((e, t) -> {
        if (e != null) {
            e.sendMessage(embed).submit();
            return;
        }
        TextChannel channel = guild.getDefaultChannel();
        if (channel != null && PermissionUtil.checkPermission(channel, guild.getSelfMember(), Permission.MESSAGE_WRITE)) {
            channel.sendMessage(embed).submit();
        } else {
            for (TextChannel textChannel : guild.getTextChannels()) {
                if (PermissionUtil.checkPermission(textChannel, guild.getSelfMember(), Permission.MESSAGE_WRITE)) {
                    textChannel.sendMessage(embed).submit();
                    break;
                }
            }
        }
    });
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:23,代码来源:WelcomeGuildListener.java

示例2: execute

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
	if(!AudioPlayerThread.isPlaying()) {
		channel.sendMessage(author.getAsMention() + " ``Currently I'm not playing.``").queue();
		return;
	}

	int seconds;
	if(arg == null) {
		seconds = 10;
	} else {
		try {
			seconds = Integer.parseInt(arg);
			if(seconds == 0) {
				throw new NumberFormatException();
			}
		} catch(NumberFormatException e) {
			channel.sendMessage(author.getAsMention() +  " ``Invalid number``").queue();
			return;
		}
	}

	AudioTrack track = AudioPlayerThread.getMusicManager().player.getPlayingTrack();
	track.setPosition(track.getPosition() + (1000*seconds)); // Lavaplayer handles values < 0 or > track length
}
 
开发者ID:Bleuzen,项目名称:Blizcord,代码行数:26,代码来源:Jump.java

示例3: run

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
@Override
public boolean run(DiscordBot bot, GuildMessageReceivedEvent event, String args) {
    if (embed == null) {
        JDA shard = event.getJDA();
        DSLContext database = bot.getDatabase();
        Guild guild = event.getGuild();
        EmbedBuilder builder = new EmbedBuilder();
        builder.setAuthor("Safety Jim - Commands", null, shard.getSelfUser().getAvatarUrl());
        builder.setDescription(getUsageTexts(bot, DatabaseUtils.getGuildSettings(database, guild).getPrefix()));
        builder.setColor(new Color(0x4286F4));

        embed = builder.build();
    }

    DiscordUtils.successReact(bot, event.getMessage());
    DiscordUtils.sendMessage(event.getChannel(), embed);
    return false;
}
 
开发者ID:Samoxive,项目名称:SafetyJim,代码行数:19,代码来源:Help.java

示例4: assignRole

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
public static void assignRole(UserData data) {
    User user = ZLevels.jda.getUserById(data.getUserId());
    Guild guild = ZLevels.jda.getGuildById(Config.SERVER);
    int level = data.getLevel();

    for (int requiredLevel : roles.keySet()) {
        if (level < requiredLevel) return;

        Member member = guild.getMember(user);
        Role role = guild.getRolesByName(roles.get(requiredLevel).getString("name"), false).get(0);

        if (member == null || role == null) return;
        if (member.getRoles().contains(role)) return;

        try {
            guild.getController().addRolesToMember(member, role).queue();
        } catch (Exception e) {
            ZLogger.warn("Could not assign role to " + user.getName() + "!");
        }
    }
}
 
开发者ID:ZP4RKER,项目名称:zlevels,代码行数:22,代码来源:AutoRole.java

示例5: hasSettings

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
public boolean hasSettings(Guild guild)
{
    try
    {
        Statement statement = connection.createStatement();
        statement.closeOnCompletion();

        try(ResultSet results = statement.executeQuery(String.format("SELECT * FROM GUILD_SETTINGS WHERE GUILD_ID = %s", guild.getId())))
        {
            return results.next();
        }
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return false;
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:19,代码来源:DatabaseManager.java

示例6: getMusicManager

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
private GuildMusicManager getMusicManager(Guild guild)
{
    String guildId = guild.getId();
    GuildMusicManager mng = musicManagers.get(guildId);
    if (mng == null)
    {
        synchronized (musicManagers)
        {
            mng = musicManagers.get(guildId);
            if (mng == null)
            {
                mng = new GuildMusicManager(playerManager);
                mng.player.setVolume(DEFAULT_VOLUME);
                musicManagers.put(guildId, mng);
            }
        }
    }
    return mng;
}
 
开发者ID:ExidCuter,项目名称:JDodoBot,代码行数:20,代码来源:PlayerControl.java

示例7: run

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
@Override
public void run() {
    if (!avaire.areWeReadyYet() || !hasLoadedGuilds()) {
        return;
    }

    Metrics.guilds.set(avaire.getShardEntityCounter().getGuilds());

    for (Region region : Region.values()) {
        Metrics.geoTracker.labels(region.getName()).set(0);
    }

    for (AvaireShard shard : avaire.getShards()) {
        for (Guild guild : shard.getJDA().getGuilds()) {
            Metrics.geoTracker.labels(guild.getRegion().getName()).inc();
        }
    }
}
 
开发者ID:avaire,项目名称:avaire,代码行数:19,代码来源:SyncGuildMetricsCounterJob.java

示例8: getLeaveMessage

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
public String getLeaveMessage(Guild guild)
{
    try
    {
        Statement statement = connection.createStatement();
        statement.closeOnCompletion();
        String message;
        try (ResultSet results = statement.executeQuery(String.format("SELECT leave_msg FROM GUILD_SETTINGS WHERE GUILD_ID = %s", guild.getId())))
        {
            if(results.next())
                message = results.getString("leave_msg");
            else message="";
        }
        return message;
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return null;
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:22,代码来源:GuildSettingsDataManager.java

示例9: YEAR

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
@Scheduled(cron = "0 0 0 1 1 ?") // NEW YEAR (0 0 0 1 1 ?) | EVERY MIN (0 * * ? * *)
public void execute() {
    if (!discordService.isConnected()) {
        return;
    }
    NewYearNotification notification = repository.findOneByGuildId(null);
    JDA jda = discordService.getJda();
    for (Guild guild : jda.getGuilds()) {
        if (!discordService.isConnected()) {
            return;
        }
        try {
            notifyNewYear(notification, guild);
        } catch (Exception e) {
            LOGGER.error("Cannot send happy new year to guild {} (ID={})", guild.getName(), guild.getId(), e);
        }
    }
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:19,代码来源:HolidayService.java

示例10: getRewards

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
private List<RewardDetails> getRewards(long serverId, RankingConfig config) {
    if (discordService.isConnected() && CollectionUtils.isNotEmpty(config.getRewards())) {
        Guild guild = discordService.getJda().getGuildById(serverId);
        if (guild != null) {
            List<RewardDetails> details = new ArrayList<>();
            for (Reward reward : config.getRewards()) {
                Role role = guild.getRoleById(reward.getRoleId());
                if (role != null) {
                    details.add(new RewardDetails(role, reward));
                }
            }
            details.sort(Comparator.comparing(RewardDetails::getLevel));
            return details;
        }

    }
    return null;
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:19,代码来源:RankingController.java

示例11: add

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
public static boolean add(Tier tier, String id, Guild guild) {
    Level level = tierMap.get(tier.getName());

    if (level.getTIER().equals(Tier.BOT_DEVELOPER)) {
        ArrayList<String> IDS = (ArrayList<String>) level.getOBJECT();
        IDS.add(id);
        level.setOBJECT(IDS);
        return true;
    }

    if (level.getTIER().equals(Tier.GUILD_WHITELIST)) {
        HashMap<Guild, ArrayList<String>> GUILD_MAP = (HashMap<Guild, ArrayList<String>>) level.getOBJECT();
        GUILD_MAP.get(guild).add(id);
        level.setOBJECT(GUILD_MAP);
        return true;
    }

    try {
        throw new Exception("You entered an invalid tier!");
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:Sanduhr32,项目名称:Uselessbot,代码行数:25,代码来源:Tierutils.java

示例12: killAudioHandlers

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
public static void killAudioHandlers(Guild guild) {
    final AudioReceiveListener audioReceiveListener = (AudioReceiveListener) guild.getAudioManager().getReceiveHandler();
    if (audioReceiveListener != null) {
        audioReceiveListener.canReceive = false;
        audioReceiveListener.compiledVoiceData = null;
        guild.getAudioManager().setReceivingHandler(null);
    }
    final AudioSendListener audioSendListener = (AudioSendListener) guild.getAudioManager().getSendingHandler();
    if (audioSendListener != null) {
        audioSendListener.canProvide = false;
        audioSendListener.voiceData = null;
        guild.getAudioManager().setSendingHandler(null);
    }
    System.out.println(String.format("Destroyed AudioHandlers for \"%s\"", guild.getName()));
    System.gc(); //FIXME Fraglich!
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:17,代码来源:AudioRecorderCommand.java

示例13: action

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
@Override
public void action(String[] args, GuildMessageReceivedEvent event) throws ParseException, IOException {
        Guild g = event.getGuild();
        if (core.permissionHandler.check(2, event))
        if (args.length < 2) event.getChannel().sendMessage(help());
        String reason = String.join(" ", args).split(args[0])[1];
        User kick =  event.getMessage().getMentionedUsers().get(0);
    String channel = SQL.getValue(g, "logchannel");
        event.getGuild().getTextChannelById(channel).sendMessage(":mans_shoe: " + kick.getAsMention() + " got kicked by " + event.getAuthor().getAsMention() + " (" + event.getMember().getRoles().get(0).getName() + ").\n\n" +
                "Reason: " + reason
        ).queue();
    event.getChannel().sendMessage(":white_check_mark: Sucessfully kicked" + kick.getName()).queue();
    PrivateChannel pc = event.getMessage().getMentionedUsers().get(0).openPrivateChannel().complete();
    pc.sendMessage(
            "Sorry, you got kicked from Server " + event.getGuild().getName() + " by " + event.getAuthor().getAsMention() + " (" + event.getMember().getRoles().get(0).getName() + ").\n\n" +
                    "Reason: " + reason
    ).queue();

    event.getGuild().getController().kick(event.getGuild().getMember(event.getMessage().getMentionedUsers().get(0))
    , reason).queue();

}
 
开发者ID:LeeDJD,项目名称:Amme,代码行数:23,代码来源:kick.java

示例14: stop

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
@Command(
        name = "stop",
        description = "Stops the player",
        usage = "`>>stop`",
        permission = CommandPermission.USER,
        category = CommandCategory.MUSIC
)
public static void stop(@Argument("event")GuildMessageReceivedEvent event, @Argument("channel") TextChannel channel, @Argument("guild") Guild guild) {
    if(checkVC(event)) return;
    GuildMusicPlayer gmp = GabrielBot.getInstance().getPlayer(guild.getIdLong());
    if(gmp == null) {
        channel.sendMessage("I'm not playing any song").queue();
        return;
    }
    boolean dj = isDJ(event.getMember(), gmp.scheduler.currentTrack());
    if(dj) {
        gmp.textChannel.sendMessage("The DJ decided to stop").queue();
        GabrielBot.getInstance().interruptPlayer(gmp.guildId);
    } else {
        channel.sendMessage("You are not a DJ").queue();
    }
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:23,代码来源:MusicCommands.java

示例15: execute

import net.dv8tion.jda.core.entities.Guild; //导入依赖的package包/类
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
	if(!AudioPlayerThread.isPlaying()) {
		channel.sendMessage(author.getAsMention() + " ``Currently I'm not playing.``").queue();
		return;
	}

	int skips;
	if (arg == null) {
		skips = 1;
	} else {
		try {
			skips = Integer.parseInt(arg);
			if (skips < 1) {
				throw new NumberFormatException();
			}
		} catch (NumberFormatException e) {
			channel.sendMessage(author.getAsMention() + " ``Invalid number``").queue();
			return;
		}
	}

	AudioPlayerThread.getMusicManager().scheduler.nextTrack(skips);
}
 
开发者ID:Bleuzen,项目名称:Blizcord,代码行数:25,代码来源:Next.java


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