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


Java User.getId方法代碼示例

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


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

示例1: setNickForUser

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
private UserConfig setNickForUser(Config config, User user, UserConfig userConfig, String value) {
    if (value.length() > 10 || value.length() < 3) {
        throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.USER_NICK_INVALID,
                localeService.getLocaleForUser(user))
        );
    }
    if (userConfig == null) {
        final UserConfig entity = new UserConfig(user.getId(), null, null, null,
                config.getLocale());
        entity.setNick(value);
        userConfig = userConfigRepository.save(entity);
    } else {
        userConfig.setNick(value);
        userConfig = userConfigRepository.save(userConfig);
    }
    return userConfig;
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:18,代碼來源:UserConfigCommand.java

示例2: EmoticonSignUpMessageListener

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public EmoticonSignUpMessageListener(BotService botService, LocaleService localeService,
                                     ServerConfigRepository serverConfigRepository,
                                     RaidRepository raidRepository, PokemonRepository pokemonRepository,
                                     GymRepository gymRepository,
                                     String raidId, LocalDateTime startAt, User user) {
    this.botService = botService;
    this.localeService = localeService;
    this.serverConfigRepository = serverConfigRepository;
    this.raidRepository = raidRepository;
    this.pokemonRepository = pokemonRepository;
    this.gymRepository = gymRepository;
    this.raidId = raidId;
    this.startAt = startAt;
    this.userId = user.getId();
    botService.addEmoticonEventListener(this);
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:17,代碼來源:EmoticonSignUpMessageListener.java

示例3: addToDbAndCollection

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
private void addToDbAndCollection(PokemonTrackingTarget trackingTarget, User user, Config config) {
    UserConfig userConfig = userConfigRepository.findOne(user.getId());
    if (userConfig != null) {
        if (userConfig.hasFreeTrackingSpot()) {
            userConfig.setNextTrackingSpot(trackingTarget.getPokemon());
        } else {
            throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.TRACKING_NONE_FREE,
                    localeService.getLocaleForUser(user)));
        }
    } else {
        // Per default, let user have the same locale as the server
        userConfig = new UserConfig(user.getId(), trackingTarget.getPokemon(), null, null,
                config.getLocale());
    }
    userConfigRepository.save(userConfig);
    trackingTargets.add(trackingTarget);
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:18,代碼來源:TrackingService.java

示例4: getLocaleForUser

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public Locale getLocaleForUser(User user) {
    if (userConfigRepository == null || user == null || user.getId() == null) {
        return DEFAULT;
    }

    final UserConfig userConfig = userConfigRepository.findOne(user.getId());
    if (userConfig == null) {
        return DEFAULT;
    } else {
        final Locale userLocale = userConfig.getLocale();
        if (userLocale == null) {
            return DEFAULT;
        } else {
            return userLocale;
        }
    }
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:18,代碼來源:LocaleService.java

示例5: resolveUserId

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public static final long resolveUserId(User user, String user_id) {
    if (user != null && user_id != null && (user_id.equalsIgnoreCase("user") || user_id.equalsIgnoreCase("me"))) {
        user_id = user.getId();
    } else if (user_id != null && (user_id.equalsIgnoreCase("this") || user_id.equalsIgnoreCase("current"))) {
        return -1;
    } else if (user_id == null || user_id.equalsIgnoreCase("0")) {
        return 0;
    }
    return resolveUserId(user_id);
}
 
開發者ID:Panzer1119,項目名稱:Supreme-Bot,代碼行數:11,代碼來源:Standard.java

示例6: addPlayer

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public void addPlayer(User u) {
	FileProperties f = new FileProperties(u);
	Player p = new Player();
	p.user = u.getId();
	p.xp = f.getInt("xp");
	players.add(p);
}
 
開發者ID:Nonoland,項目名稱:TaverneBot,代碼行數:8,代碼來源:Scoreboard.java

示例7: FileProperties

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public FileProperties(User u) {
	this.nameFile = u.getId();
	this.extension = ".user";
	this.path = "users/";
	
	file = new File("files/users/"+nameFile+"."+extension);
}
 
開發者ID:Nonoland,項目名稱:TaverneBot,代碼行數:8,代碼來源:FileProperties.java

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

示例9: add

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public void add(Pokemon pokemon, User user, Config config) {
    Validate.notNull(pokemon, "Pokemon");
    Validate.notNull(user, "User");
    Validate.notNull(config, "Config");

    PokemonTrackingTarget trackingTarget = new PokemonTrackingTarget(user.getId(), pokemon);
    if (getTrackingTargets().contains(trackingTarget)) {
        throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.TRACKING_EXISTS,
                localeService.getLocaleForUser(user)));
    }
    addToDbAndCollection(trackingTarget, user, config);
}
 
開發者ID:magnusmickelsson,項目名稱:pokeraidbot,代碼行數:13,代碼來源:TrackingService.java

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

示例11: execute

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
@Override
protected void execute(CommandEvent event)
{
    Color color;
    Config config = null;
    
    if(event.isFromType(ChannelType.PRIVATE))
        color = Color.decode("#33ff00");
    else
        color = event.getGuild().getSelfMember().getColor();

    try
    {
        config = new Config();
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
    
   String title = ":information_source: Information about **"+event.getSelfUser().getName()+"**";
   EmbedBuilder builder = new EmbedBuilder();
   User owner = event.getJDA().getUserById(config.getOwnerId());
   String ownername = owner.getName()+"#"+owner.getDiscriminator();
   String ownerid = owner.getId();


          builder.setDescription("Hi, I'm Endless! A multipurpose bot designed to be smart.\n"
          		+ "If you found a bug please contact my dad\n"
          		+ "("+Const.DEV+")!\n");
          builder.addField(":bust_in_silhouette: Owner:", "**"+ownername+"** (**"+ownerid+"**)", false);
          builder.addField("<:jda:325395909347115008>  Library:", "Java Discord API (JDA) "+JDAInfo.VERSION+" and JDA Utilities "+JDAUtilitiesInfo.VERSION, false);
          builder.addField("<:github:326118305062584321> GitHub:", "Did you found a bug? Want improve something?\n"
          		+ "Please open an Issue or create a PR on GitHub\n"
          		+ "**https://github.com/ArtutoGamer/Endless**\n", false);
          builder.addField(":link: Support Guild:", "**[Support]("+Const.INVITE+")**\n", false);
          builder.setFooter("Version: "+Const.VERSION+" | Latest Start", null);
          builder.setColor(color);
          builder.setTimestamp(event.getClient().getStartTime());
          builder.setThumbnail(event.getSelfUser().getAvatarUrl());
          event.getChannel().sendMessage(new MessageBuilder().append(title).setEmbed(builder.build()).build()).queue();
}
 
開發者ID:EndlessBot,項目名稱:Endless,代碼行數:43,代碼來源:About.java

示例12: run

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public Result run(String[] argsOrig, MessageReceivedEvent e) {
	
	//Check for proper argument length
	if (argsOrig.length < 2) {
		return new Result(Outcome.WARNING, ":warning: Please specify a message.");
	}
	
	//Extract user
	String[] args = ArrayUtils.remove(MessageUtils.getContent(e.getMessage(), true), 0);
	User user = null;
	if (args[0].matches(MessageUtils.mentionRegex)) {
		user = e.getMessage().getMentionedUsers().get(0);
		if (user.getId() == e.getJDA().getSelfUser().getId()) {
			user = e.getMessage().getMentionedUsers().get(1);
		}
	} else if (args[0].matches(MessageUtils.idRegex)) {
		user = e.getJDA().getUserById(args[0]);
	} else {
		return new Result(Outcome.ERROR, ":x: Not a valid user!");
	}
	
	//Send the message
	String msg = null;
	try {
		PrivateChannel channel = user.openPrivateChannel().submit().get();
		msg = String.join(" ", ArrayUtils.remove(args, 0));
		channel.sendMessage(msg).queue();
	} catch (InterruptedException | ExecutionException ex) {
		ex.printStackTrace();
		return new Result(Outcome.ERROR, ":x: An exception occured.");
	}
	
	EmbedBuilder eb = new EmbedBuilder();
	eb.setAuthor(e.getAuthor().getName() + " (" + e.getAuthor().getId() + ")",
		null, e.getAuthor().getAvatarUrl());
	eb.setDescription("**Sent a DM to " + user.getName() + " (" + user.getId() + "):**\n" + msg);
	eb.setThumbnail(user.getAvatarUrl());
	MessageUtils.log(eb.build());
	
	return new Result(Outcome.SUCCESS);
}
 
開發者ID:Tisawesomeness,項目名稱:Minecord,代碼行數:42,代碼來源:MsgCommand.java

示例13: Stats

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public Stats(User user) {
    this.persona = user.getId();
    this.numOfMessages = 1;
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:5,代碼來源:Stats.java

示例14: MCBUser

import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public MCBUser(User user, Guild guild) {
    nickNames = new HashMap<>();
    name = user.getName();
    nickNames.put(guild, guild.getMember(user).getNickname());
    ID = user.getId();
}
 
開發者ID:CyR1en,項目名稱:Minecordbot,代碼行數:7,代碼來源:MCBUser.java


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