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


Java IUser.equals方法代码示例

本文整理汇总了Java中sx.blah.discord.handle.obj.IUser.equals方法的典型用法代码示例。如果您正苦于以下问题:Java IUser.equals方法的具体用法?Java IUser.equals怎么用?Java IUser.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sx.blah.discord.handle.obj.IUser的用法示例。


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

示例1: hasPermission

import sx.blah.discord.handle.obj.IUser; //导入方法依赖的package包/类
public boolean hasPermission(IUser user, IGuild server, String permission) {
    boolean check = false;
    if (permission.equalsIgnoreCase(Globals.BOT_OWNER)) {
        if (user.equals(INIT.BOT.getApplicationOwner())) {
            check = true;
        }
    } else {
        for (IRole role : user.getRolesForGuild(server)) {
            if (grouppermissions.get(role) != null && grouppermissions.get(role).contains(permission)) {
                check = true;
            }
        }
    }
    if (DRIVER.getPropertyOnly(DRIVER.CONFIG, "ownerbypass").equals(true) && user.equals(INIT.BOT.getApplicationOwner())) {
        check = true;
    }
    return check;
}
 
开发者ID:ModdyLP,项目名称:MoMuOSB,代码行数:19,代码来源:PermissionController.java

示例2: execute

import sx.blah.discord.handle.obj.IUser; //导入方法依赖的package包/类
@Override
public void execute(Context context) throws MissingArgumentException, IllegalCmdArgumentException {
	if(!context.hasArg()) {
		throw new MissingArgumentException();
	}

	List<String> splitArgs = StringUtils.split(context.getArg(), 2);
	if(splitArgs.size() != 2) {
		throw new MissingArgumentException();
	}

	Long userID = CastUtils.asPositiveLong(splitArgs.get(0));
	if(userID == null) {
		throw new IllegalCmdArgumentException(String.format("`%s` is not a valid user ID.", splitArgs.get(0)));
	}

	IUser user = Shadbot.getClient().getUserByID(userID);
	if(user == null) {
		BotUtils.sendMessage(Emoji.GREY_EXCLAMATION + " User not found.", context.getChannel());
		return;
	}

	if(user.equals(context.getOurUser())) {
		throw new IllegalCmdArgumentException("I can't send a private message to myself.");
	}

	if(user.isBot()) {
		throw new IllegalCmdArgumentException("I can't send private message to other bots.");
	}

	context.getClient().getOrCreatePMChannel(user).sendMessage(splitArgs.get(1));
	BotUtils.sendMessage(Emoji.CHECK_MARK + " Message sent.", context.getChannel());
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:34,代码来源:SendMessageCmd.java

示例3: execute

import sx.blah.discord.handle.obj.IUser; //导入方法依赖的package包/类
@Override
public void execute(Context context) throws MissingArgumentException, IllegalCmdArgumentException {
	if(!context.hasArg()) {
		throw new MissingArgumentException();
	}

	if(context.getMessage().getMentions().isEmpty()) {
		throw new MissingArgumentException();
	}

	List<String> splitCmd = StringUtils.split(context.getArg(), 2);
	if(splitCmd.size() != 2) {
		throw new MissingArgumentException();
	}

	IUser receiverUser = context.getMessage().getMentions().get(0);
	IUser senderUser = context.getAuthor();
	if(receiverUser.equals(senderUser)) {
		throw new IllegalCmdArgumentException("You cannot transfer coins to yourself.");
	}

	Integer coins = CastUtils.asPositiveInt(splitCmd.get(0));
	if(coins == null) {
		throw new IllegalCmdArgumentException(String.format("`%s` is not a valid amount for coins.", splitCmd.get(0)));
	}

	if(Database.getDBUser(context.getGuild(), senderUser).getCoins() < coins) {
		BotUtils.sendMessage(TextUtils.notEnoughCoins(context.getAuthor()), context.getChannel());
		return;
	}

	if(Database.getDBUser(context.getGuild(), receiverUser).getCoins() + coins >= Config.MAX_COINS) {
		BotUtils.sendMessage(String.format(Emoji.BANK + " This transfer cannot be done because %s would exceed the maximum coins cap.",
				receiverUser.getName()), context.getChannel());
		return;
	}

	Database.getDBUser(context.getGuild(), senderUser).addCoins(-coins);
	Database.getDBUser(context.getGuild(), receiverUser).addCoins(coins);

	BotUtils.sendMessage(String.format(Emoji.BANK + " %s has transfered **%s** to %s",
			senderUser.mention(), FormatUtils.formatCoins(coins), receiverUser.mention()), context.getChannel());
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:44,代码来源:TransferCoinsCmd.java

示例4: execute

import sx.blah.discord.handle.obj.IUser; //导入方法依赖的package包/类
@Override
public MessageBuilder execute(CommandData<Baristron> commandData) {
	ProfileObject profile = Userdata.getGson("profile_" + commandData.getUser().getID(), ProfileObject.class);
	if (profile == null)
		profile = new ProfileObject();

	if (commandData.getArgs().size() == 0) {
		MetadataMessageBuilder builder = Bot.getNewBuilder(commandData.getChannel())
				.withContent("You have **" + profile.rep + "** reputation points.");

		if (System.currentTimeMillis() < profile.repCooldown) {
			builder.appendContent("\nYour rep-giving cooldown ends in **" +
					Utils.formatTime((profile.repCooldown - System.currentTimeMillis()) / 1000f) + "**.");
		}

		Bot.sendMessage(builder);
	} else {
		final String content = commandData.getFullContent();
		IUser u = Utils.findFirstUser(commandData.getChannel(), content);

		if (u == null)
			return CommandResponse.withAutoDeleteMessage(Bot.getNewBuilder(commandData.getChannel())
					.withContent("Couldn't find that commandData.getUser()."), Bot.AUTO_DELETE_TIME);

		if (u.equals(commandData.getUser()))
			return CommandResponse.withAutoDeleteMessage(Bot.getNewBuilder(commandData.getChannel())
					.withContent("You cannot give rep-points to yourself!"), Bot.AUTO_DELETE_TIME);

		if (System.currentTimeMillis() < profile.repCooldown)
			return CommandResponse.withAutoDeleteMessage(Bot.getNewBuilder(commandData.getChannel()).withContent(
					"Your rep-giving cooldown ends in **" +
							Utils.formatTime((profile.repCooldown - System.currentTimeMillis()) / 1000f) + "**."),
					Bot.AUTO_DELETE_TIME);


		ProfileObject profile2 = Userdata.getGson("profile_" + u.getID(), ProfileObject.class);
		if (profile2 == null)
			profile2 = new ProfileObject();

		profile2.rep++;
		profile.repCooldown = System.currentTimeMillis() + (1000 * 60 * 60 * 12);

		Bot.sendMessage(Bot.getNewBuilder(commandData.getChannel()).withContent(
				u.mention() + ", **" + commandData.getUser().getDisplayName(commandData.getChannel().getGuild()) +
						"**#" + commandData.getUser().getDiscriminator() +
						" has given you a rep-point! You now have **" + profile2.rep + "**."));

		Userdata.setGson("profile_" + commandData.getUser().getID(), profile);
		Userdata.setGson("profile_" + u.getID(), profile2);
		Userdata.instance().save();
	}
	return null;
}
 
开发者ID:chrislo27,项目名称:Baristron,代码行数:54,代码来源:RepCommand.java

示例5: handle

import sx.blah.discord.handle.obj.IUser; //导入方法依赖的package包/类
@Override
public void handle(MessageReceivedEvent event) {
	if (finished || !ready)
		return;

	final IMessage messageObj = event.getMessage();
	final IChannel channel = messageObj.getChannel();
	String message = messageObj.getContent();
	final IUser author = messageObj.getAuthor();

	if (!channel.isPrivate())
		return;

	boolean matchAny = false;
	for (IPrivateChannel ch : privateChannels) {
		if (channel.equals(ch)) {
			matchAny = true;
			break;
		}
	}
	if (!matchAny)
		return;

	final int index = author.equals(battlers[0].owner) ? 0 : (author.equals(battlers[1].owner) ? 1 : -1);

	if (index == -1)
		return;

	if (message.length() == 1) {
		char c = Character.toLowerCase(message.charAt(0));

		if (c == 'r') {
			// resign

			finished = true;
			client.getDispatcher().unregisterListener(this);

			for (IPrivateChannel pc : privateChannels) {
				Bot.sendMessage(Bot.getNewBuilder(pc).withContent(
						"**" + author.getName() + "**#" + author.getDiscriminator() +
								" __resigned__ from the battle."));
			}

			Userdata.addLong("goatBattlesLost_" + author.getID(), 1, 0);
			Userdata.addLong("goatBattlesWon_" + battlers[index].opponent.owner.getID(), 1, 0);
			Userdata.instance().save();

			return;
		} else if (selection[index] == 0 && c >= '1' &&
				c <= Integer.toString(battlers[index].moves.length).charAt(0)) {
			selection[index] = c - '1' + 1;
			final int moveIndex = selection[index] - 1;

			final Move m = battlers[index].moves[moveIndex];

			boolean noPPRemaining = true;
			for (int pp : battlers[index].pp) {
				if (pp > 0) {
					noPPRemaining = false;
					break;
				}
			}

			if (!noPPRemaining && battlers[index].pp[moveIndex] == 0) {
				Bot.sendMessage(
						Bot.getNewBuilder(privateChannels[index]).withContent("That move is **out of PP**."));
				selection[index] = 0;
			}
		}
	}

	if (selection[0] != 0 && selection[1] != 0) {
		executeTurn(event);
	}
}
 
开发者ID:chrislo27,项目名称:Baristron,代码行数:76,代码来源:Battle.java


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