Java Code Examples for net.dv8tion.jda.api.entities.User#getIdLong()

The following examples show how to use net.dv8tion.jda.api.entities.User#getIdLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PronounsCheckCommand.java    From SkyBot with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void execute(@Nonnull CommandContext ctx) {
    final GuildMessageReceivedEvent event = ctx.getEvent();
    final User target = getMentionedUser(ctx);
    final long userId = target.getIdLong();
    final JsonNode json = ctx.getApis().getPronouns(userId);
    final boolean isSelf = userId == ctx.getAuthor().getIdLong();

    if (json == null) {
        sendMsg(event, (isSelf ? "You do" : target.getName() + " does") + " not have any pronouns set");
        return;
    }

    final String pronouns = json.get("pronouns").asText();
    final String singular = json.get("singular").asBoolean() ? "Singular" : "Plural";
    final String userName = isSelf ? "Your" : target.getName() + "'s";

    final String format = "%s current pronouns are:%n**%s** (%s)";

    sendMsg(event, String.format(format, userName, pronouns, singular));
}
 
Example 2
Source File: PunishmentListener.java    From Arraybot with Apache License 2.0 5 votes vote down vote up
/**
 * Handles the punishment or punishment revocation.
 * @param event The event.
 * @param userObject The user object.
 * @param type The type of punishment.
 * @param roles The roles involved in the event, should be null unless it is a mute or unmute.
 * @param revoke True: revocation, false: punishment creation.
 */
private void handlePunishment(GenericGuildEvent event, User userObject, PunishmentType type, Role[] roles, boolean revoke) {
    Guild guild = event.getGuild();
    if(!event.getGuild().getSelfMember().hasPermission(Permission.VIEW_AUDIT_LOGS)) {
        return;
    }
    long user = userObject.getIdLong();
    guild.retrieveAuditLogs().queue(entries -> {
        if(entries.isEmpty()) {
            return;
        }
        AuditLogEntry entry = entries.get(0);
        if(!isPunishment(entry, user, type, roles)
                || entry.getUser() == null
                || entry.getUser().getIdLong() == guild.getSelfMember().getUser().getIdLong()) {
            return;
        }
        long staff = entry.getUser().getIdLong();
        if(!revoke) {
            punishmentManager.punish(guild, user, type, staff, -1, true, entry.getReason());
        } else {
            PunishmentObject punishmentObject = ULambda.INSTANCE.getSpecificGeneralizedPunishment(guild, user, type);
            if(punishmentObject == null) {
                return;
            }
            if(!punishmentManager.revoke(guild, punishmentObject, staff)) {
                Arraybot.INSTANCE.getLogger().error("Failed the revocation of the punishment number {} in the guild {}.", punishmentObject.getId(), guild.getIdLong());
            }
        }
    });
}
 
Example 3
Source File: ReactionPaginationActionImpl.java    From JDA with Apache License 2.0 4 votes vote down vote up
@Override
protected long getKey(User it)
{
    return it.getIdLong();
}