本文整理匯總了Java中net.dv8tion.jda.core.entities.User.isBot方法的典型用法代碼示例。如果您正苦於以下問題:Java User.isBot方法的具體用法?Java User.isBot怎麽用?Java User.isBot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.dv8tion.jda.core.entities.User
的用法示例。
在下文中一共展示了User.isBot方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendPrivateMsg
import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
/**
* sends a message to a private message channel, opening the channel before use
*, asynchronous (non-blocking)
* @param content the message to send as a string
* @param user the user to send the private message to
* @param action a non null Consumer will do operations on the results returned
*/
public static void sendPrivateMsg(String content, User user, Consumer<Message> action )
{
if (content.isEmpty()) return;
if (user.isBot()) return;
try
{
user.openPrivateChannel().queue(privateChannel -> sendMsg(content, privateChannel, action), null);
}
catch (PermissionException ignored) { }
catch (Exception e)
{
Logging.exception( MessageUtilities.class, e );
}
}
示例2: execute
import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
@Override
public void execute(String[] args, Event event, TaverneBot bot) {
MessageReceivedEvent mre = (MessageReceivedEvent) event;
EmbedBuilder builder = new EmbedBuilder();
builder.setColor(new Color(192, 57, 43));
builder.setFooter("TaverneBot", null);
if(args.length>=2) {
User u = mre.getMessage().getMentionedUsers().get(0);
if(u.isBot()) return;
builder.setAuthor(u.getName(), null, u.getAvatarUrl()+"?size=256");
builder.addField("Classement", String.valueOf(bot.getScoreboard().getRank(u)), true);
builder.addField("Niveaux", String.valueOf(bot.getLevelManager().getLevel(u)), true);
builder.addField("Exp�riences", String.valueOf(bot.getLevelManager().getXP(u)), true);
} else {
builder.setAuthor(mre.getAuthor().getName(), null, mre.getAuthor().getAvatarUrl()+"?size=256");
builder.addField("Classement", String.valueOf(bot.getScoreboard().getRank(mre.getAuthor())), true);
builder.addField("Niveaux", String.valueOf(bot.getLevelManager().getLevel(mre.getAuthor())), true);
builder.addField("Exp�riences", String.valueOf(bot.getLevelManager().getXP(mre.getAuthor())), true);
}
((MessageReceivedEvent) event).getTextChannel().sendMessage(builder.build()).queue();
}
示例3: 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();
}
示例4: onCommand
import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
@Override
public boolean onCommand(Message message, String[] args) {
GuildTransformer guildTransformer = GuildController.fetchGuild(avaire, message);
if (guildTransformer == null || !guildTransformer.isLevels()) {
return sendErrorMessage(message, "This command requires the `Levels & Experience` feature to be enabled for the server, you can ask a server admin if they want to enable it with `.level`");
}
User user = message.getAuthor();
if (!message.getMentionedUsers().isEmpty() && !args[0].equals("---skip-mentions")) {
user = message.getMentionedUsers().get(0);
}
final User author = user;
if (author.isBot()) {
MessageFactory.makeWarning(message, "Bots cannot receive xp and therefore can\'t be ranked, try and tag a user instead.").queue();
return false;
}
loadProperties(message, author).thenAccept(properties -> {
String score = properties.getScore().equals("Unranked") ?
"Unranked" : properties.getScore() + " / " + message.getGuild().getMembers().size();
long experience = properties.getPlayer().getExperience();
long level = LevelUtil.getLevelFromExperience(experience);
long current = LevelUtil.getExperienceFromLevel(level);
long diff = LevelUtil.getExperienceFromLevel(level + 1) - current;
double percentage = ((double) (experience - current) / diff) * 100;
String levelBar = "";
for (int i = 1; i <= 40; i++) {
levelBar += ((i * 2.5) < percentage) ? "\u2592" : "\u2591";
}
MessageFactory.makeEmbeddedMessage(message.getChannel(), Color.decode("#E91E63"))
.setAuthor(author.getName(), "https://avairebot.com/leaderboard/" + message.getGuild().getId(), author.getAvatarUrl())
.setFooter("https://avairebot.com/leaderboard/" + message.getGuild().getId())
.addField("Rank", score, true)
.addField("Level", "" + level, true)
.addField("Experience", (experience - 100 < 0 ? "0" : String.format("%s (Total: %s)",
experience - 100, properties.getTotal()
)), true)
.addField("Experience needed to next Level", String.format("[%s] %s%s",
levelBar, new DecimalFormat("#.##").format(percentage), '%'
), false)
.queue();
});
return true;
}
示例5: botIsBlocked
import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
protected boolean botIsBlocked(String id) {
List<String> blockedB = (List<String>) configsManager.getChatConfig().getList("Blocked_Bots");
if (mcb.getBot().getJda().getUserById(id) != null) {
User user = mcb.getBot().getJda().getUserById(id);
if (user.isBot()) {
for (Object s : blockedB) {
if (user.getId().equals(s.toString().trim()))
return true;
}
}
}
return false;
}
示例6: canHandle
import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
@Override
public boolean canHandle(Config config, User user, Raid raid, Guild guild) {
if (config == null || user == null || raid == null || guild == null) {
LOGGER.debug("Returning tracker can't handle this, because some input is null. Config: " +
config + ", User: " + (user == null ? "null" : user.getName()) + ", Raid: " + raid +
", Guild: " + guild);
return false;
}
if (!config.useBotIntegration() && user.isBot()) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Skipping, since server has no bot integration and message is from a bot.");
}
return false; // Skip bot messages
}
if (user.getId().equals(userId)) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Skipping, since this is user's own raid.");
}
return false; // Skip raids user created
}
if (guild.getMemberById(this.userId) == null) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Skipping, since user with this tracking is not a member of server " + guild.getName());
}
return false; // Skip raids for guilds where user is not a member
}
boolean raidIsForPokemon =
StringUtils.containsIgnoreCase(raid.getPokemon().getName(),
pokemon.getName());
return raidIsForPokemon;
}
示例7: run
import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public Result run(String[] args, MessageReceivedEvent e) {
Config.update();
//If the author used the admin keyword and is an elevated user
boolean elevated = false;
if (args.length > 0 && args[0].equals("admin") && Config.getElevatedUsers().contains(e.getAuthor().getId())) {
elevated = true;
}
//Calculate memory (taken from stackoverflow)
long value = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
final long[] dividers = new long[] {T, G, M, K, 1};
final String[] units = new String[] {"TB", "GB", "MB", "KB", "B"};
if (value < 1) {
throw new IllegalArgumentException("Invalid file size: " + value);
}
String memory = null;
for (int i = 0; i < dividers.length; i++) {
final long divider = dividers[i];
if (value >= divider) {
memory = format(value, divider, units[i]);
break;
}
}
//Build message
EmbedBuilder eb = new EmbedBuilder();
eb.setColor(Color.GREEN);
eb.addField("Author", "@Tis_awesomeness#8617", true);
eb.addField("Version", Bot.getVersion(), true);
String guilds = DiscordUtils.getGuilds().size() + "";
String channels = DiscordUtils.getTextChannels().size() + "";
String users = DiscordUtils.getUsers().size() + "";
if (Config.getShardCount() > 1) {
String shards = e.getJDA().getShardInfo().getShardId() + 1 + "/" + Config.getShardCount();
eb.addField("Shard", shards, true);
guilds += " {" + e.getJDA().getGuilds().size() + "}";
channels += " {" + e.getJDA().getTextChannels().size() + "}";
users += " {" + e.getJDA().getUsers().size() + "}";
}
eb.addField("Guilds", guilds + "", true);
eb.addField("Channels", channels, true);
eb.addField("Users", users, true);
ArrayList<User> userArray = new ArrayList<User>(DiscordUtils.getUsers());
for (User u : new ArrayList<User>(userArray)) {
if (u.isBot() || u.isFake()) {
userArray.remove(u);
}
}
eb.addField("Humans", userArray.size() + "", true);
eb.addField("Uptime", DateUtils.getUptime(), true);
if (Config.getShowMemory() || elevated) {
eb.addField("Memory", memory, true);
}
eb.addField("Invite", Config.getInvite(), true);
eb.addField("Help Server", Bot.helpServer, true);
eb.addField("Website", Bot.website, true);
eb.addField("Credits", "Mojang API, Crafatar, and MCAPI", true);
eb.addField("Library", "Java `1.8.0_101`, JDA `3.3.1_301`", true);
eb = MessageUtils.addFooter(eb);
return new Result(Outcome.SUCCESS, eb.build());
}
示例8: isApplicable
import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
@Override
public boolean isApplicable(User user) {
return user != null && !user.isBot();
}
示例9: isUserPokeAlarmBot
import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public static boolean isUserPokeAlarmBot(User user) {
return user.isBot() && (user.getName().equalsIgnoreCase("raid") ||
user.getName().equalsIgnoreCase("egg"));
}
示例10: isUserGymhuntrBot
import net.dv8tion.jda.core.entities.User; //導入方法依賴的package包/類
public static boolean isUserGymhuntrBot(User user) {
return user.isBot() && StringUtils.containsIgnoreCase(
user.getName(), "gymhuntrbot");
}