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


Java IUser类代码示例

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


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

示例1: dispatchReminders

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
/**
 * Dispatches all reminders once the target time is hit
 */
public final synchronized void dispatchReminders() {
    Iterator<Reminder> iterator = reminders.iterator();

    while (iterator.hasNext()) {
        Reminder reminder = iterator.next();

        Date targetDate = reminder.getTargetDate();

        if (targetDate.getTime() >= System.currentTimeMillis()) {
            continue;
        } else {
            IUser recipient = reminder.getRecipient();
            String message = reminder.getMessage();

            String content = String.format("Here is your reminder: \"%s\"",
                                            message);
            rexCord.sendMessageToUser(recipient, content);
            iterator.remove();
        }
    }
}
 
开发者ID:Pedro12909,项目名称:RexCord,代码行数:25,代码来源:RemindHandler.java

示例2: moduleDmAnnouncements

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
private void moduleDmAnnouncements(MessageReceivedEvent event, GuildSettings settings) {
if (settings.isDevGuild()) {
          IUser user = event.getAuthor();

          if (settings.getDmAnnouncements().contains(user.getStringID())) {
              settings.getDmAnnouncements().remove(user.getStringID());
              DatabaseManager.getManager().updateSettings(settings);
              Message.sendMessage(MessageManager.getMessage("DisCal.DmAnnouncements.Off", settings), event);
          } else {
              settings.getDmAnnouncements().add(user.getStringID());
              DatabaseManager.getManager().updateSettings(settings);
              Message.sendMessage(MessageManager.getMessage("DisCal.DmAnnouncements.On", settings), event);
          }
      } else {
          Message.sendMessage(MessageManager.getMessage("Notification.Disabled", settings), event);
      }
  }
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:18,代码来源:DisCalCommand.java

示例3: 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

示例4: addUsertoRole

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
@Command(
        command = "addUserRole",
        description = "Add a User to a specific role",
        arguments = {"User Mention", "Role []"},
        prefix = Globals.ADMIN_PREFIX,
        permission = Globals.BOT_MANAGE,
        alias = "aur"
)
public void addUsertoRole(MessageReceivedEvent event, String[] args) {
    try {
        List<IRole> roles = event.getGuild().getRolesByName(Utils.makeArgsToString(args, new String[]{args[0]}));
        for (IUser user : event.getMessage().getMentions()) {
            for (IRole role : roles) {
                user.addRole(role);
                BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(String.format(LANG.getTranslation("role_add"), role.getName(), user.getName())), true);
            }
        }
    } catch (Exception ex) {
        BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(String.format(LANG.getTranslation("commonmessage_error"), Arrays.toString(ex.getStackTrace()))), true);
        Console.error(ex);
    }
}
 
开发者ID:ModdyLP,项目名称:MoMuOSB,代码行数:23,代码来源:RoleManagement.java

示例5: removeUsertoRole

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
@Command(
        command = "removeUserRole",
        description = "Add a User to a specific role",
        arguments = {"User Mention", "Role []"},
        prefix = Globals.ADMIN_PREFIX,
        permission = Globals.BOT_MANAGE,
        alias = "rmur"
)
public void removeUsertoRole(MessageReceivedEvent event, String[] args) {
    try {
        List<IRole> roles = event.getGuild().getRolesByName(Utils.makeArgsToString(args, new String[]{args[0]}));
        for (IUser user : event.getMessage().getMentions()) {
            for (IRole role : roles) {
                user.removeRole(role);
                BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(String.format(LANG.getTranslation("role_remove"), role.getName(), user.getName())), true);
            }
        }
    } catch (Exception ex) {
        BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(String.format(LANG.getTranslation("commonmessage_error"), Arrays.toString(ex.getStackTrace()))), true);
        Console.error(ex);
    }
}
 
开发者ID:ModdyLP,项目名称:MoMuOSB,代码行数:23,代码来源:RoleManagement.java

示例6: sanitize

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
public static String sanitize(@Nullable IGuild guild, String message) {
    if (message == null) return null;
    if (guild == null) return message;
    
	Matcher matcher = REGEX_MENTION.matcher(message);
	while (matcher.find()) {
	    long id = Long.parseLong(matcher.group(1));
	    String name;
	    if (matcher.group().contains("&")) {
	        name = "the " + MCBot.instance.getRoleByID(id).getName();
	    } else {
	        IUser user = guild.getUserByID(id);
	        if (matcher.group().contains("!")) {
	            name = user.getDisplayName(guild).replaceAll("@", "@\u200B");
	        } else {
	            name = user.getName();
	        }
	    }

		message = message.replace(matcher.group(), name);
    }
    return message.replace("@here", "everyone").replace("@everyone", "everyone").replace("@", "@\u200B");
}
 
开发者ID:tterrag1098,项目名称:MCBot,代码行数:24,代码来源:CommandContext.java

示例7: checkAndGetBet

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
public static Integer checkAndGetBet(IChannel channel, IUser user, String betStr, int maxValue) throws IllegalCmdArgumentException {
	Integer bet = CastUtils.asPositiveInt(betStr);
	if(bet == null) {
		throw new IllegalCmdArgumentException(String.format("`%s` is not a valid amount for coins.", betStr));
	}

	if(Database.getDBUser(channel.getGuild(), user).getCoins() < bet) {
		BotUtils.sendMessage(TextUtils.notEnoughCoins(user), channel);
		return null;
	}

	if(bet > maxValue) {
		BotUtils.sendMessage(String.format(Emoji.BANK + " Sorry, you can't bet more than **%s**.",
				FormatUtils.formatCoins(maxValue)), channel);
		return null;
	}

	return bet;
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:20,代码来源:Utils.java

示例8: execute

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
@Override
public void execute(Context context) throws MissingArgumentException {
	List<IUser> mentions = context.getMessage().getMentions();
	IUser user = mentions.isEmpty() ? context.getAuthor() : mentions.get(0);

	String creationDate = String.format("%s%n(%s)",
			TimeUtils.toLocalDate(user.getCreationDate()).format(dateFormatter),
			FormatUtils.formatLongDuration(user.getCreationDate()));

	String joinDate = String.format("%s%n(%s)",
			TimeUtils.toLocalDate(context.getGuild().getJoinTimeForUser(user)).format(dateFormatter),
			FormatUtils.formatLongDuration(context.getGuild().getJoinTimeForUser(user)));

	EmbedBuilder embed = EmbedUtils.getDefaultEmbed()
			.setLenient(true)
			.withAuthorName(String.format("Info about user \"%s\"%s", user.getName(), user.isBot() ? " (Bot)" : ""))
			.withThumbnail(user.getAvatarURL())
			.appendField("Display name", user.getDisplayName(context.getGuild()), true)
			.appendField("User ID", Long.toString(user.getLongID()), true)
			.appendField("Creation date", creationDate, true)
			.appendField("Join date", joinDate, true)
			.appendField("Roles", FormatUtils.format(user.getRolesForGuild(context.getGuild()), IRole::getName, "\n"), true)
			.appendField("Status", StringUtils.capitalize(user.getPresence().getStatus().toString()), true)
			.appendField("Playing text", user.getPresence().getText().orElse(null), true);
	BotUtils.sendMessage(embed.build(), context.getChannel());
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:27,代码来源:UserInfoCmd.java

示例9: draw

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
public static void draw() {
	LogUtils.infof("Lottery draw started...");
	int winningNum = ThreadLocalRandom.current().nextInt(MIN_NUM, MAX_NUM + 1);

	List<LottoPlayer> winners = LottoManager.getPlayers().stream()
			.filter(player -> player.getNum() == winningNum
					&& Shadbot.getClient().getGuildByID(player.getGuildID()) != null
					&& Shadbot.getClient().getUserByID(player.getUserID()) != null)
			.collect(Collectors.toList());

	for(LottoPlayer winner : winners) {
		IGuild guild = Shadbot.getClient().getGuildByID(winner.getGuildID());
		IUser user = Shadbot.getClient().getUserByID(winner.getUserID());
		int coins = (int) Math.ceil((double) LottoManager.getPool() / winners.size());
		Database.getDBUser(guild, user).addCoins(coins);
	}

	LogUtils.infof("Lottery draw done (Winning number: %d | %d winner(s) | Prize pool: %d)",
			winningNum, winners.size(), LottoManager.getPool());

	LottoManager.setHistoric(winners.size(), LottoManager.getPool(), winningNum);
	LottoManager.reset();
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:24,代码来源:LottoCmd.java

示例10: isLimited

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
public boolean isLimited(IChannel channel, IUser user) {
	guildsLimitedMap.putIfAbsent(channel.getGuild().getLongID(), new LimitedGuild());

	LimitedGuild limitedGuild = guildsLimitedMap.get(channel.getGuild().getLongID());
	limitedGuild.addUserIfAbsent(user);

	LimitedUser limitedUser = limitedGuild.getUser(user);
	limitedUser.increment();

	// The user has not exceeded the limit yet, he is not limited
	if(limitedUser.getCount() <= max) {
		limitedGuild.scheduledDeletion(scheduledExecutor, user, cooldown);
		return false;
	}

	// The user has exceeded the limit, he's warned and limited
	if(limitedUser.getCount() == max + 1) {
		limitedGuild.scheduledDeletion(scheduledExecutor, user, cooldown);
		this.warn(channel, user);
		return true;
	}

	// The user has already exceeded the limit, he will be unlimited when the deletion task will be done
	return true;
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:26,代码来源:RateLimiter.java

示例11: subscribeUser

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
private String subscribeUser(IUser user, String publisherName) {
    StringBuilder response = new StringBuilder();
    Optional<Publisher> publisher = getPublisher(publisherName);
    if (!publisher.isPresent()) {
        log.warn("Publisher does not exist: {}", publisherName);
        String available = publisherRepository.findAll().stream()
            .map(Publisher::getId).collect(Collectors.joining(", "));
        return "Invalid support channel. Available IDs: " + available + "\n";
    }
    DiscordUser discordUser = cacheService.getOrCreateUser(user);
    UserSubscription subscription = new UserSubscription();
    subscription.setUser(discordUser);
    subscription.setEnabled(true);
    publisher.get().getUserSubscriptions().removeIf(s -> s.getUser().getId().equals(user.getID()));
    publisher.get().getUserSubscriptions().add(subscription);
    publisherRepository.save(publisher.get());
    log.info("[SupportPing] User subscribed to {}: {}", publisherName, DiscordService.userString(user));
    response.append("*Preferences updated:* Receiving **").append(publisherName).append("** support PMs\n");
    appendFooter(response);
    return response.toString();
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:22,代码来源:SupportPresenter.java

示例12: execute

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
@Override
public MessageBuilder execute(CommandData<Baristron> commandData) {
	if (commandData.getArgs().size() < 1) {
		Bot.sendMessage(Bot.getNewBuilder(commandData.getChannel()).appendContent(
				commandData.getUser().mention() + " Your permission tier is " + commandData.getPermLevel())
				.appendContent(", you have been " + "tempbanned " +
						Userdata.getData("tempbanCount_" + commandData.getUser().getID(), "0") + " times."));
	} else {
		String content = commandData.getFullContent();
		IUser u = Utils.findFirstUser(commandData.getBot().client, content, commandData.getChannel().getGuild());

		Bot.sendMessage(Bot.getNewBuilder(commandData.getChannel()).appendContent(
				"The permission level of " + content + (u == null
						? " (real user not found!)"
						: " (" + u.getDisplayName(commandData.getChannel().getGuild()) + "#" +
								u.getDiscriminator()) + ")" + " " + "is " +
						Userdata.getPermissions(u == null ? content : u.getID()) + "."));
	}
	return null;
}
 
开发者ID:chrislo27,项目名称:Baristron,代码行数:21,代码来源:PermissionsCommand.java

示例13: unsubscribeAnnouncer

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
private String unsubscribeAnnouncer(IUser author, String announcer, IChannel channel) {
    if (!announcer.isEmpty()) {
        Publisher publisher = findOrCreatePublisher(announcer);
        List<ChannelSubscription> matching = publisher.getChannelSubscriptions().stream()
            .filter(s -> s.getChannel().getId().equals(channel.getID())).collect(Collectors.toList());
        if (matching.isEmpty()) {
            return "That channel is not receiving announcements about **" + announcer + "**";
        } else {
            for (ChannelSubscription subscription : matching) {
                subscription.setEnabled(false);
            }
            publisherRepository.save(publisher);
            return String.format("Cancelled subscription of %s to **%s**", channel.mention(), announcer);
        }
    } else {
        log.debug("Attempted to subscribe announcer: {}", author);
    }
    return null;
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:20,代码来源:AnnouncePresenter.java

示例14: resolveMentions

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
private String resolveMentions(String content) {
    // "escapes" a mention and translates ID to username if possible
    Matcher matcher = USER_MENTION_PATTERN.matcher(content);
    StringBuffer buffer = new StringBuffer();
    while (matcher.find()) {
        String id = matcher.group(1);
        IUser user = discordService.getClient().getUserByID(id);
        if (user == null) {
            matcher.appendReplacement(buffer, "@" + id);
        } else {
            matcher.appendReplacement(buffer, "@" + user.getName());
        }
    }
    matcher.appendTail(buffer);
    return buffer.toString();
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:17,代码来源:UserPresenter.java

示例15: onCommand

import sx.blah.discord.handle.obj.IUser; //导入依赖的package包/类
@Override
public void onCommand(IUser sender, IChannel channel, IMessage message, String[] args) {
    if (args.length == 0) {
        MessageUtils.sendMessage(sender.mention() + " Usage: " + FlareBot.getPrefixes().get(channel.getGuild().getID()) + "search <term>", channel);
    } else if (args.length >= 1) {
        if (args[0].startsWith("http") || args[0].startsWith("www.")) {
            VideoThread.getThread(args[0], channel, sender).start();
        } else {
            String term = "";
            for (String s : args) {
                term += s + " ";
            }
            term = term.trim();
            VideoThread.getSearchThread(term, channel, sender).start();
        }
    }
}
 
开发者ID:ArsenArsen,项目名称:FlareBot,代码行数:18,代码来源:SearchCommand.java


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