Java 类net.dv8tion.jda.core.entities.SelfUser 实例源码

项目:Supreme-Bot    文件:Standard.java   
public static final Member getSelfMemberByGuild(long guild_id) {
    if (guild_id == 0) {
        return null;
    }
    final Guild guild = getGuildById(guild_id);
    if (guild != null) {
        try {
            final SelfUser user = getJDA().getSelfUser();
            if (user != null) {
                return guild.getMemberById(user.getId());
            } else {
                System.err.println("Failed to get SelfMember by Guild: SelfUser is null!");
                return null;
            }
        } catch (Exception ex) {
            System.err.print("Failed to get SelfMember by Guild: ");
            ex.printStackTrace();
            return null;
        }
    } else {
        System.err.println("Failed to get SelfMember by Guild: Guild is null!");
        return null;
    }
}
项目:DiscordIntegrationCore    文件:DiscordClient.java   
public SelfUser getSelf() {
    if (this.jda == null) {
        return null;
    }

    return this.jda.getSelfUser();
}
项目:Supreme-Bot    文件:Standard.java   
public static final boolean setNickname(String nickname) {
    if (nickname == null || nickname.isEmpty()) {
        return false;
    }
    Config.CONFIG.setBotNickname(nickname);
    try {
        final JDA jda = getJDA();
        if (jda != null) {
            final SelfUser user = jda.getSelfUser();
            if (user != null) {
                if (!nickname.equals(user.getName())) {
                    final AccountManager manager = user.getManager();
                    if (manager != null) {
                        manager.setName(nickname).queue();
                        System.out.println("Changed nickname to \"" + nickname + "\".");
                        return true;
                    } else {
                        System.err.println("Failed to change nickname to \"" + nickname + "\": AccountManager is null!");
                    }
                } else {
                    //System.err.println("Failed to change nickname to \"" + nickname + "\": Nickname is already set!");
                }
            } else {
                System.err.println("Failed to change nickname to \"" + nickname + "\": SelfUser is null!");
            }
        } else {
            System.err.println("Failed to change nickname to \"" + nickname + "\": JDA is null!");
        }
        return false;
    } catch (Exception ex) {
        System.err.println("Failed to change nickname to \"" + nickname + "\"");
        //ex.printStackTrace();
        return false;
    }
}
项目:GameResourceBot    文件:CommandUtils.java   
public static boolean botMentioned(Message message) {
    SelfUser selfUser = message.getJDA().getSelfUser();
    String prefix = BotConfig.getConfig().PREFIX;
    String messageStartWord = message.getContent().split(" ")[0];
    boolean prefixCheck = prefix.equalsIgnoreCase(messageStartWord);
    boolean mentionCheck = message.isMentioned(selfUser) && !message.mentionsEveryone();
    return prefixCheck || mentionCheck;
}
项目:GabrielBot    文件:GabrielBot.java   
public void log(String s) {
    if(DEBUG) return;
    Shard shard0 = shards[0];
    if(shard0 != null) {
        SelfUser self = shard0.getJDA().getSelfUser();
        log.send(new WebhookMessageBuilder()
                .setContent(s.replace("@everyone", "@evryone"))
                .setUsername(self.getName())
                .setAvatarUrl(self.getAvatarUrl())
                .build()
        );
    } else {
        log.send(s);
    }
}
项目:MantaroRPG    文件:UnifiedJDA.java   
@Override
default SelfUser getSelfUser() {
    throw new UnsupportedOperationException();
}
项目:GameResourceBot    文件:MessageListener.java   
private boolean isFromMyself(PrivateMessageReceivedEvent event) {
    SelfUser selfUser = event.getJDA().getSelfUser();
    return event.getAuthor().getId().equals(selfUser.getId());
}
项目:GameResourceBot    文件:MessageListener.java   
private boolean isFromMyself(GuildMessageReceivedEvent event) {
    SelfUser selfUser = event.getJDA().getSelfUser();
    return event.getAuthor().getId().equals(selfUser.getId());
}
项目:SafetyJim    文件:Info.java   
@Override
public boolean run(DiscordBot bot, GuildMessageReceivedEvent event, String args) {
    DSLContext database = bot.getDatabase();
    Config config = bot.getConfig();
    JDA currentShard = event.getJDA();
    List<JDA> shards = bot.getShards().stream().map((shard) -> shard.getShard()).collect(Collectors.toList());
    Guild guild = event.getGuild();
    SelfUser selfUser = currentShard.getSelfUser();
    Message message = event.getMessage();
    TextChannel channel = event.getChannel();

    int shardCount = shards.size();
    int shardId = DiscordUtils.getShardIdFromGuildId(guild.getIdLong(), shardCount);
    String shardString = DiscordUtils.getShardString(shardId, shardCount);

    String uptimeString = prettyTime.format(bot.getStartTime());

    long guildCount = bot.getGuildCount();
    int channelCount = shards.stream()
                          .mapToInt((shard) -> shard.getTextChannels().size())
                          .sum();
    int userCount = shards.stream()
                          .mapToInt((shard) -> shard.getUsers().size())
                          .sum();
    long pingShard = currentShard.getPing();
    long pingAverage = shards.stream()
                             .mapToLong((shard) -> shard.getPing())
                             .sum() / shardCount;

    Runtime runtime = Runtime.getRuntime();
    long ramTotal = runtime.totalMemory() / (1024 * 1024);
    long ramUsed = ramTotal - (runtime.freeMemory() / (1024 * 1024));

    BanlistRecord lastBanRecord = database.selectFrom(Tables.BANLIST)
                                          .where(Tables.BANLIST.GUILDID.eq(guild.getId()))
                                          .orderBy(Tables.BANLIST.BANTIME.desc())
                                          .fetchAny();

    String daysSince = "\u221E"; // Infinity symbol

    if (lastBanRecord != null) {
        Date now = new Date();
        long dayCount = ((now.getTime() / 1000) - lastBanRecord.getBantime()) / (60 * 60 * 24);
        daysSince = Long.toString(dayCount);
    }

    EmbedBuilder embed = new EmbedBuilder();
    embed.setAuthor(String.format("Safety Jim - v%s - Shard %s", config.version, shardString), null, selfUser.getAvatarUrl());
    embed.setDescription("Lifting the :hammer: since " + uptimeString);
    embed.addField("Server Count", Long.toString(guildCount), true);
    embed.addField("User Count", Integer.toString(userCount), true);
    embed.addField("Channel Count", Integer.toString(channelCount), true);
    embed.addField("Websocket Ping", String.format("Shard %s: %dms\nAverage: %dms", shardString, pingShard, pingAverage), true);
    embed.addField("RAM usage", String.format("%dMB / %dMB", ramUsed, ramTotal), true);
    embed.addField("Links", String.format("[Support](%s) | [Github](%s) | [Invite](%s)", supportServer, githubLink, botInviteLink), true);
    embed.setFooter("Made by Safety Jim team. | Days since last incident: " + daysSince, null);
    embed.setColor(new Color(0x4286F4));

    DiscordUtils.successReact(bot, message);
    DiscordUtils.sendMessage(channel, embed.build());

    return false;
}
项目:avaire    文件:AvaIre.java   
public SelfUser getSelfUser() {
    return getShards().get(0).getJDA().getSelfUser();
}
项目:wolfia    文件:Wolfia.java   
public static SelfUser getSelfUser() {
    return getFirstJda().getSelfUser();
}
项目:JDA    文件:GenericSelfUpdateEvent.java   
public SelfUser getSelfUser()
{
    return api.getSelfUser();
}
项目:JDA    文件:AccountManagerUpdatable.java   
/**
 * Creates a new AccountManagerUpdatable instance
 *
 * @param selfUser
 *        A {@link net.dv8tion.jda.core.entities.SelfUser SelfUser} instance
 *        that represents the currently logged in account
 */
public AccountManagerUpdatable(SelfUser selfUser)
{
    this.selfUser = selfUser;
    setupFields();
}
项目:JDA    文件:AccountManagerUpdatable.java   
/**
 * The {@link net.dv8tion.jda.core.entities.SelfUser SelfUser} that will be
 * modified by this AccountManagerUpdatable instance.
 * <br>This represents the currently logged in account.
 *
 * @return The corresponding SelfUser
 */
public SelfUser getSelfUser()
{
    return selfUser;
}
项目:JDA    文件:AccountManager.java   
/**
 * Creates a new AccountManager instance
 *
 * @param selfUser
 *        The {@link net.dv8tion.jda.core.entities.SelfUser SelfUser} to manage
 */
public AccountManager(SelfUser selfUser)
{
    this.updatable = new AccountManagerUpdatable(selfUser);
}
项目:JDA    文件:AccountManager.java   
/**
 * The {@link net.dv8tion.jda.core.entities.SelfUser SelfUser} that will be
 * modified by this AccountManager.
 * <br>This represents the currently logged in account.
 *
 * @return The corresponding SelfUser
 */
public SelfUser getSelfUser()
{
    return updatable.getSelfUser();
}