當前位置: 首頁>>代碼示例>>Java>>正文


Java User.getName方法代碼示例

本文整理匯總了Java中net.dv8tion.jda.core.entities.User.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java User.getName方法的具體用法?Java User.getName怎麽用?Java User.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.dv8tion.jda.core.entities.User的用法示例。


在下文中一共展示了User.getName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sub

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
/**
 * Substitutes a player in-game with another player out-of-game.
 * 
 * @param target the player that will be substituted
 * @param substitute the player that will replace the target
 */
public void sub(User target, User substitute) {
	if (!isQueueListEmpty()) {
		if (isPlayerIngame(substitute)) {
			throw new InvalidUseException(substitute.getName() + " is already in-game");
		}
		for (Queue q : queueList) {
			for (Game g : q.getGames()) {
				if (g.getPlayers().contains(target)) {
					g.sub(target, substitute);
					purgeQueue(substitute);
					return;
				}
			}
		}
		throw new InvalidUseException(target.getName() + " is not in-game");
	} else {
		throw new DoesNotExistException("Queue");
	}
}
 
開發者ID:Implosions,項目名稱:BullyBot,代碼行數:26,代碼來源:QueueManager.java

示例2: executeWithConfig

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
    final User user = commandEvent.getAuthor();
    final String userName = user.getName();
    final Locale localeForUser = localeService.getLocaleForUser(user);
    String gymName = commandEvent.getArgs();
    final Gym gym = gymRepository.search(user, gymName, config.getRegion());
    final Raid raid = raidRepository.getActiveRaidOrFallbackToExRaid(gym, config.getRegion(), user);
    final SignUp removed = raid.remove(user, raidRepository);
    if (removed != null) {
        commandEvent.reactSuccess();
        removeOriginMessageIfConfigSaysSo(config, commandEvent);
    } else {
        final String message =
                localeService.getMessageFor(LocaleService.NO_SIGNUP_AT_GYM, localeForUser, userName, gym.getName());
        replyErrorBasedOnConfig(config, commandEvent, new UserMessedUpException(user, message));
    }
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:19,代碼來源:RemoveSignUpCommand.java

示例3: saveRaid

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
private RaidEntity saveRaid(User raidCreator, Raid raid) {
    final RaidEntity toBeSaved = new RaidEntity(UUID.randomUUID().toString(),
            raid.getPokemon().getName(),
            raid.getEndOfRaid(),
            raid.getGym().getName(),
            raidCreator.getName(),
            raid.getRegion());
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Creating raid: " + toBeSaved);
    }
    return raidEntityRepository.save(toBeSaved);

}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:14,代碼來源:RaidRepository.java

示例4: set

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
@Nonnull
//set general user values
public Self set(@Nullable final User user) {
    if (user == null) {
        return getThis();//gracefully ignore null users
    }
    this.name = user.getName();
    this.discriminator = Short.parseShort(user.getDiscriminator()); //unbox it
    this.avatarId = user.getAvatarId();
    this.bot = user.isBot();
    return getThis();
}
 
開發者ID:napstr,項目名稱:SqlSauce,代碼行數:13,代碼來源:DiscordUser.java

示例5: getEffectiveName

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
@Nonnull
public String getEffectiveName(@Nullable final Guild guild, @Nullable Function<Long, User> globalUserLookup) {
    if (guild != null) {
        final Member member = guild.getMemberById(this.userId);
        if (member != null) {
            //1
            return member.getEffectiveName();
        }
        final String cachedNick = getNick(guild.getIdLong());
        if (cachedNick != null && !cachedNick.isEmpty()) {
            //2
            return cachedNick;
        }

        User user = guild.getJDA().getUserById(this.userId);
        if (user != null) {
            //3
            return user.getName();
        }
        if (globalUserLookup != null) {
            user = globalUserLookup.apply(this.userId);
            if (user != null) {
                //3a
                return user.getName();
            }
        }
    }
    //4 & 5
    return getName();
}
 
開發者ID:napstr,項目名稱:SqlSauce,代碼行數:31,代碼來源:DiscordUser.java

示例6: DiscordEvent

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public DiscordEvent(User user) {
	this.user = user;
	this.channel = null;
	this.channelName = null;
	this.username = user.getName();
	this.discrim = user.getDiscriminator();
	this.senderId = user.getId();
	this.sender = (username + "#" + discrim);
	this.mention = "<@" + senderId + ">";
}
 
開發者ID:GloriousEggroll,項目名稱:quorrabot,代碼行數:11,代碼來源:DiscordEvent.java

示例7: toString

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public String toString(){
	String names = "";
	if(members.size() > 0){
		for(User m : members){
			names += m.getName() + ", ";
		}
		names = names.substring(0, names.length() - 2);
	}
	return String.format("%s: %s", captain.getName(), names);
}
 
開發者ID:Implosions,項目名稱:BullyBot,代碼行數:11,代碼來源:TeamPickerMenu.java

示例8: popQueue

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
/**
 * Creates a new game.
 * Removes players in-game from other queues.
 * Sends notification to the pug channel and to each player in queue.
 */
private void popQueue() {
	String names = "";
	List<User> players = new ArrayList<User>(playersInQueue);
	TextChannel pugChannel = ServerManager.getServer(guildId).getPugChannel();
	
	// Send alert to players and compile their names
	for(User u : players){
		names += u.getName() + ", ";
		PrivateChannel c = u.openPrivateChannel().complete();
		c.sendMessage(String.format("`Your game: %s has started!`", name)).queue();
	}
	names = names.substring(0, names.lastIndexOf(","));
	
	// Create Game and add to the list of active games
	Game newGame = new Game(guildId, name, players);
	games.add(newGame);
	
	// Remove players from all other queues
	ServerManager.getServer(guildId).getQueueManager().purgeQueue(players);
	
	// Generate captain string
	String captainString = "";
	if(ServerManager.getServer(guildId).getSettings().randomizeCaptains()){
		captainString = String.format("**Captains:** <@%s> & <@%s>", newGame.getCaptains()[0].getId(), newGame.getCaptains()[1].getId());
	}
	
	// Send game start message to pug channel
	pugChannel.sendMessage(Utils.createMessage(String.format("Game: %s starting%n", name), String.format("%s%n%s", names, captainString), Color.YELLOW)).queueAfter(2, TimeUnit.SECONDS);
	
	/*String servers = new CmdPugServers().getServers(guildId, null);
	if(!servers.equals("N/A")){
		pugChannel.sendMessage(Utils.createMessage("`Pug servers:`", servers, true)).queueAfter(2, TimeUnit.SECONDS);
	}*/
}
 
開發者ID:Implosions,項目名稱:BullyBot,代碼行數:40,代碼來源:Queue.java

示例9: executeWithConfig

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
    final User user = commandEvent.getAuthor();
    final String userName = user.getName();
    final String[] args = commandEvent.getArgs().split(" ");
    String whatToChange = args[0].trim().toLowerCase();

    switch (whatToChange) {
        case "when":
            changeWhen(commandEvent, config, user, args);
            break;
        case "pokemon":
            if (args.length < 2) {
                throw new UserMessedUpException(userName,
                        localeService.getMessageFor(LocaleService.BAD_SYNTAX, localeService.getLocaleForUser(user),
                                "!raid change {when/pokemon/remove/group} {params}"));
            }
            changePokemon(this, gymRepository, localeService, pokemonRepository, raidRepository,
                    commandEvent, config, user, userName, args[1].trim().toLowerCase(),
                    ArrayUtils.removeAll(args, 0, 1));
            break;
        case "remove":
            deleteRaid(commandEvent, config, user, userName, args);
            break;
        case "group":
            changeOrDeleteGroup(commandEvent, config, user, userName, args);
            break;
        default:
            throw new UserMessedUpException(userName,
                    localeService.getMessageFor(LocaleService.BAD_SYNTAX, localeService.getLocaleForUser(user),
                            "!raid change {when/pokemon/remove/group} {params}"));
    }
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:34,代碼來源:AlterRaidCommand.java

示例10: executeWithConfig

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
    final User user = commandEvent.getAuthor();
    final String userName = user.getName();
    final String[] args = commandEvent.getArgs().split(" ");
    if (args.length < 2) {
        throw new UserMessedUpException(userName,
                localeService.getMessageFor(LocaleService.BAD_SYNTAX, localeService.getLocaleForUser(user),
                        "!raid hatch Ho-Oh solna platform"));
    }
    String pokemonName = args[0].trim().toLowerCase();
    final String[] gymArguments = ArrayUtils.removeAll(args, 0);
    String gymName = StringUtils.join(gymArguments, " ");
    final String region = config.getRegion();
    final Gym gym = gymRepository.search(user, gymName, region);
    final Raid raid = raidRepository.getActiveRaidOrFallbackToExRaid(gym, region, user);

    final Pokemon pokemon = pokemonRepository.search(pokemonName, user);
    final PokemonRaidInfo existingRaidInfo = raidStrategyService.getRaidInfo(raid.getPokemon());
    final int newBossTier = raidStrategyService.getRaidInfo(pokemon).getBossTier();
    if (!raid.getPokemon().isEgg()) {
        throw new UserMessedUpException(user,
                localeService.getMessageFor(LocaleService.EGG_ALREADY_HATCHED,
                        localeService.getLocaleForUser(user), raid.getPokemon().toString()));
    }
    if (pokemon.isEgg() || newBossTier != existingRaidInfo.getBossTier()) {
        throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.EGG_WRONG_TIER,
                localeService.getLocaleForUser(user)));
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Trying to hatch raid " + raid + " into " + pokemonName);
    }
    AlterRaidCommand.changePokemon(this, gymRepository, localeService, pokemonRepository, raidRepository,
            commandEvent, config, user, userName, pokemonName,
            gymArguments);
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:37,代碼來源:EggHatchedCommand.java

示例11: executeUnsignCommand

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public String executeUnsignCommand(Config config,
                                   User user,
                                   Locale localeForUser,
                                   String[] args,
                                   String help) {
    String people = args[0];
    String userName = user.getName();
    if (args.length < 2 || args.length > 10) {
        throw new WrongNumberOfArgumentsException(user, localeService, 2, args.length, help);
    }
    Integer numberOfPeople = Utils.assertNotTooManyOrNoNumber(user, localeService, people);

    StringBuilder gymNameBuilder = new StringBuilder();
    for (int i = 1; i < args.length; i++) {
        gymNameBuilder.append(args[i]).append(" ");
    }
    String gymName = gymNameBuilder.toString().trim();
    final Gym gym = gymRepository.search(user, gymName, config.getRegion());
    Raid raid = getActiveRaidOrFallbackToExRaid(gym, config.getRegion(), user);
    final RaidEntitySignUp signUp = findEntityByRaidId(raid.getId()).getSignUp(user.getName());
    if (signUp == null) {
        throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.NO_SIGNUP_AT_GYM,
                localeForUser, user.getName(), gym.getName()));
    }

    raid = removeFromSignUp(raid.getId(), user, 0, 0, 0, numberOfPeople,
            LocalDateTime.of(raid.getEndOfRaid().toLocalDate(),
                    signUp.getArrivalTime()));
    final String currentSignupText = localeService.getMessageFor(LocaleService.CURRENT_SIGNUPS, localeForUser);
    final Set<SignUp> signUps = raid.getSignUps();
    Set<String> signUpNames = Utils.getNamesOfThoseWithSignUps(signUps, true);
    final String allSignUpNames = StringUtils.join(signUpNames, ", ");
    final String signUpText = raid.getSignUps().size() > 1 ? currentSignupText + "\n" + allSignUpNames : "";
    return localeService.getMessageFor(LocaleService.UNSIGN, localeForUser, userName,
            gym.getName(), signUpText);
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:37,代碼來源:RaidRepository.java

示例12: executeSignUpCommand

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public String executeSignUpCommand(Config config,
                                   User user,
                                   Locale localeForUser,
                                   String[] args,
                                   String help) {
    String people = args[0];
    String userName = user.getName();
    if (args.length < 3 || args.length > 10) {
        throw new WrongNumberOfArgumentsException(user, localeService, 3, args.length, help);
    }
    Integer numberOfPeople = Utils.assertNotTooManyOrNoNumber(user, localeService, people);

    String timeString = args[1];

    StringBuilder gymNameBuilder = new StringBuilder();
    for (int i = 2; i < args.length; i++) {
        gymNameBuilder.append(args[i]).append(" ");
    }
    String gymName = gymNameBuilder.toString().trim();
    final Gym gym = gymRepository.search(user, gymName, config.getRegion());
    final Raid raid = getActiveRaidOrFallbackToExRaid(gym, config.getRegion(), user);

    LocalTime eta = Utils.parseTime(user, timeString, localeService);
    LocalDateTime realEta = LocalDateTime.of(raid.getEndOfRaid().toLocalDate(), eta);

    assertEtaNotAfterRaidEnd(user, raid, realEta, localeService);
    assertSignupTimeNotBeforeRaidStartAndNow(user, realEta, raid.getEndOfRaid(), localeService, raid.isExRaid());

    raid.signUp(user, numberOfPeople, eta, this);
    final String currentSignupText = localeService.getMessageFor(LocaleService.CURRENT_SIGNUPS, localeForUser);
    final Set<SignUp> signUps = raid.getSignUps();
    Set<String> signUpNames = Utils.getNamesOfThoseWithSignUps(signUps, true);
    final String allSignUpNames = StringUtils.join(signUpNames, ", ");
    final String signUpText = raid.getSignUps().size() > 1 ? currentSignupText + "\n" + allSignUpNames : "";
    return localeService.getMessageFor(LocaleService.SIGNUPS, localeForUser, userName,
            gym.getName(), signUpText);
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:38,代碼來源:RaidRepository.java

示例13: isBotAdminOwner

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
private boolean isBotAdminOwner(User author) {
    String userwithDiscriminator = author.getName() + "#" + author.getDiscriminator(); //the libarey don't include a readily used readable username with descriminator
    return (userwithDiscriminator.equals(botAdmin) && botAdmin != null) || (botOwner.getIdLong() == author.getIdLong());
}
 
開發者ID:IANetworks,項目名稱:Ducky-Mc-Duckerson,代碼行數:5,代碼來源:CommandStructure.java

示例14: getCompleteName

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public static final String getCompleteName(User user, boolean withId) {
    if (user == null) {
        return null;
    }
    return "<" + user.getName() + "#" + user.getDiscriminator() + (withId ? ":" + user.getId() : "") + ">";
}
 
開發者ID:Panzer1119,項目名稱:Supreme-Bot,代碼行數:7,代碼來源:Standard.java

示例15: getFullUser

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public static String getFullUser(User user)
{
    return user.getName() + "#" + user.getDiscriminator();
}
 
開發者ID:thebrightspark,項目名稱:MDC-Discord-Bot,代碼行數:5,代碼來源:Util.java


注:本文中的net.dv8tion.jda.core.entities.User.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。