Java Code Examples for net.dv8tion.jda.api.entities.User

The following examples show how to use net.dv8tion.jda.api.entities.User. These examples are extracted from open source projects. 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 Project: MantaroBot   Source File: LeaderboardCmd.java    License: GNU General Public License v3.0 6 votes vote down vote up
private EmbedBuilder generateLeaderboardEmbed(Context ctx, String description, String leaderboardKey, List<Map<String, Object>> lb, Function<Map<?, ?>, Pair<User, String>> mapFunction, String format, boolean isSeasonal) {
    I18nContext languageContext = ctx.getLanguageContext();
    return new EmbedBuilder()
            .setAuthor(isSeasonal ?
                    String.format(languageContext.get("commands.leaderboard.header_seasonal"),
                    config.getCurrentSeason().getDisplay()) : languageContext.get("commands.leaderboard.header"), null, ctx.getSelfUser().getEffectiveAvatarUrl()
            ).setDescription(description)
            .addField(languageContext.get(leaderboardKey), lb.stream()
                    .map(mapFunction)
                    .filter(p -> Objects.nonNull(p.getKey()))
                    .map(p -> {
                        //This is... an interesting place to do it lol
                        if(p.getKey().getIdLong() == ctx.getAuthor().getIdLong()) {
                            var player = MantaroData.db().getPlayer(ctx.getAuthor());
                            if(player.getData().addBadgeIfAbsent(Badge.CHAMPION))
                                player.saveAsync();
                        }

                        return String.format(
                                format, EmoteReference.BLUE_SMALL_MARKER, p.getKey().getName(), p.getKey().getDiscriminator(),
                                StringUtils.isNumeric(p.getValue()) ? Long.parseLong(p.getValue()) : p.getValue()
                        );
                    }).collect(Collectors.joining("\n")), false)
            .setFooter(String.format(languageContext.get("general.requested_by"), ctx.getAuthor().getName()), null)
            .setThumbnail(ctx.getAuthor().getEffectiveAvatarUrl());
}
 
Example 2
Source Project: JDA   Source File: ReactionPaginationActionImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void handleSuccess(Response response, Request<List<User>> request)
{
    final EntityBuilder builder = api.getEntityBuilder();
    final DataArray array = response.getArray();
    final List<User> users = new LinkedList<>();
    for (int i = 0; i < array.length(); i++)
    {
        try
        {
            final User user = builder.createFakeUser(array.getObject(i));
            users.add(user);
            if (useCache)
                cached.add(user);
            last = user;
            lastKey = last.getIdLong();
        }
        catch (ParsingException | NullPointerException e)
        {
            LOG.warn("Encountered exception in ReactionPagination", e);
        }
    }

    request.onSuccess(users);
}
 
Example 3
Source Project: SkyBot   Source File: BotinfoCommand.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void execute(@Nonnull CommandContext ctx) {
    if ("support".equals(ctx.getInvoke())) {
        MessageUtils.sendMsg(ctx, "You can join my support server here: <https://dunctebot.link/server>");
        return;
    }

    final User u = ctx.getJDA().getSelfUser();
    final String duncte = " <@191231307290771456> (duncte123#1245)";

    final MessageEmbed eb = EmbedUtils.defaultEmbed()
        .setDescription("Here is some information about me \uD83D\uDE09")
        .setThumbnail(u.getEffectiveAvatarUrl())
        .addField("About me", "Hello there, my name is DuncteBot and I’m currently being developed by " +
            duncte + ".\n" +
            "If you want to add me to your server you can do that by [clicking here](https://bots.discord.pw/bots/210363111729790977).\n" +
            "\n**[Support server](https://dunctebot.link/server)** \u2022 **[Website](https://dunctebot.com/)** \u2022 " +
            "**[Invite me](https://dunctebot.link/invite)**" +
            " \u2022 **[Twitter](https://twitter.com/DuncteBot)**  \u2022 **[Cheap hosting](https://billing.oxide.host/aff.php?aff=6)**" +
            "\n\u200B", true)
        .addField("Lang & lib info", "**Coded in:** Java (version " + System.getProperty("java.version") +
            ") and Kotlin (version " + KotlinVersion.CURRENT + ")\n\n" +
            "**JDA version:** " + JDAInfo.VERSION + "" +
            "\n**LavaPlayer version:** " + this.lavaplayerVersion + "\n" +
            "**Weeb.java version:** " + WeebInfo.VERSION + "\n\u200B", false)
        .addField("Support", "If you want to help keep the bot up 24/7, please consider " +
            "[becoming a patron](https://www.patreon.com/DuncteBot).", false)
        .build();

    sendEmbed(ctx, eb);
}
 
Example 4
Source Project: JDA   Source File: GuildMessageReactionAddEvent.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
@SuppressWarnings("ConstantConditions")
public User getUser()
{
    return super.getUser();
}
 
Example 5
Source Project: SkyBot   Source File: UnwarnCommand.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void execute(@Nonnull CommandContext ctx) {
    final List<Member> mentioned = ctx.getMentionedArg(0);

    if (mentioned.isEmpty()) {
        sendMsg(ctx, "No users found for query");

        return;
    }

    final DunctebotGuild guild = ctx.getGuild();
    final User target = mentioned.get(0).getUser();

    ctx.getDatabaseAdapter().deleteLatestWarningForUser(
        target.getIdLong(),
        guild.getIdLong(),
        (latestWarning) -> {
            if (latestWarning == null) {
                sendMsg(ctx, "This user has no active warnings");

                return null;
            }

            sendMsgFormat(ctx, "Latest warning for _%s_ removed\nReason was: %s", target.getAsTag(), latestWarning.getReason());
            modLog(String.format(
                "**%s** removed the latest warning for **%s**\nReason was: %s",
                ctx.getAuthor().getAsTag(),
                target.getAsTag(),
                latestWarning.getReason()
            ), guild);

            return null;
        });
}
 
Example 6
Source Project: JDA   Source File: ApplicationInfoImpl.java    License: Apache License 2.0 5 votes vote down vote up
public ApplicationInfoImpl(JDA api, String description, boolean doesBotRequireCodeGrant, String iconId, long id,
        boolean isBotPublic, String name, User owner, ApplicationTeam team)
{
    this.api = api;
    this.description = description;
    this.doesBotRequireCodeGrant = doesBotRequireCodeGrant;
    this.iconId = iconId;
    this.id = id;
    this.isBotPublic = isBotPublic;
    this.name = name;
    this.owner = owner;
    this.team = team;
}
 
Example 7
Source Project: SkyBot   Source File: FlagCommand.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void execute(@Nonnull CommandContext ctx) {
    final GuildMessageReceivedEvent event = ctx.getEvent();

    if (!passes(event, false)) {
        return;
    }

    final List<String> args = ctx.getArgs();
    final String flag = args.get(0).toLowerCase();

    if (flag.equalsIgnoreCase("list")) {
        sendMsg(event, "A list of flags can be found at https://dunctebot.com/flags");

        return;
    }

    if (!flags.contains(flag)) {
        sendMsg(event, "I do not know what this flag is, visit <https://dunctebot.com/flags> for a list of available flags.");

        return;
    }

    User user = ctx.getAuthor();

    if (args.size() > 1) {
        final String search = String.join(" ", args.subList(1, args.size()));
        final List<User> foundUsers = FinderUtils.searchUsers(search, ctx);

        if (!foundUsers.isEmpty()) {
            user = foundUsers.get(0);
        }
    }

    final String imageUrl = UserKt.getStaticAvatarUrl(user) + "?size=512";
    final byte[] image = ctx.getApis().getFlag(flag, imageUrl);

    handleBasicImage(event, image);

}
 
Example 8
Source Project: MantaroBot   Source File: ProfileComponent.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Holder(User user, Player player, SeasonPlayer seasonalPlayer, DBUser dbUser, List<Badge> badges) {
    this.user = user;
    this.player = player;
    this.seasonalPlayer = seasonalPlayer;
    this.dbUser = dbUser;
    this.badges = badges;
}
 
Example 9
Source Project: SkyBot   Source File: CommandUtils.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
private static boolean isPatron(@Nonnull User u, @Nullable TextChannel tc) {
    // Developers have access to paton features
    if (isDev(u) || patrons.contains(u.getIdLong())) {
        return true;
    }

    //noinspection ConstantConditions
    final Guild supportGuild = u.getJDA().getShardManager().getGuildById(Settings.SUPPORT_GUILD_ID);

    // If the guild is not in cache (cuz discord) ignore the rest of the checks
    if (supportGuild == null) {
        return false;
    }

    final Member m = supportGuild.getMember(u);

    // If the member is not in our guild we tell them to join it
    if (m == null) {
        sendEmbed(tc, EmbedUtils.embedMessage("This command is a patron only command and is locked for you because you " +
            "are not one of our patrons.\n" +
            "For only $1 per month you can have access to this and many other commands [click here link to get started](https://www.patreon.com/DuncteBot).\n" +
            "You will also need to join our discord server [here](https://dunctebot.link/server)"));
        return false;
    }

    // If the member is not a patron tell them to become one
    if (!m.getRoles().contains(supportGuild.getRoleById(Settings.PATRONS_ROLE))) {
        sendEmbed(tc, EmbedUtils.embedMessage("This command is a patron only command and is locked for you because you " +
            "are not one of our patrons.\n" +
            "For only $1 per month you can have access to this and many other commands [click here link to get started](https://www.patreon.com/DuncteBot)."));
        return false;
    }

    patrons.add(u.getIdLong());

    return true;
}
 
Example 10
Source Project: MantaroBot   Source File: ImageCmd.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void call(Context ctx, String content) {
    String random;
    String id = "";
    if (images.size() == 1) {
        if (type != null) {
            Pair<String, String> result = weebapi.getRandomImageByType(type, false, null);
            images = Collections.singletonList(result.getKey());
            id = result.getValue();
        }

        random = images.get(0); //Guaranteed random selection :^).
    } else {
        random = images.get(rand.nextInt(images.size()));
    }

    String extension = random.substring(random.lastIndexOf("."));
    MessageBuilder builder = new MessageBuilder();
    builder.append(EmoteReference.TALKING);

    if (!noMentions) {
        List<User> users = ctx.getMentionedUsers();
        var names = users.stream().distinct().map(user -> {
            var member = ctx.getGuild().getMember(user);
            if (member == null) {
                return "unknown";
            }

            return member.getEffectiveName();
        }).collect(Collectors.joining(", "));
        if (!names.isEmpty())
            builder.append("**").append(names).append("**, ");
    }

    builder.append(ctx.getLanguageContext().get(toSend));
    ctx.getChannel().sendMessage(builder.build()).addFile(CACHE.getInput(random), imageName + "-" + id + "." + extension).queue();
}
 
Example 11
Source Project: JuniperBot   Source File: MafiaInstance.java    License: GNU General Public License v3.0 5 votes vote down vote up
public boolean done(User user) {
    if (scheduledStep != null) {
        if (scheduledStep.isDone() || scheduledStep.isCancelled()) {
            return false;
        } else {
            scheduledStep.cancel(false);
            scheduledStep = null;
        }
    }
    return handler == null || handler.onEnd(user, this);
}
 
Example 12
Source Project: MantaroBot   Source File: ModLog.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void log(Member author, User target, String reason, String channel, ModAction action, long caseNumber, int messagesDeleted) {
    DBGuild guildDB = db.getGuild(author.getGuild());
    Player player = db.getPlayer(author);
    PlayerData playerData = player.getData();
    EmbedBuilder embedBuilder = new EmbedBuilder();

    embedBuilder.addField("Responsible Moderator", author.getEffectiveName(), true);

    if (target != null) {
        embedBuilder.addField("Member", target.getName(), true);
        embedBuilder.setThumbnail(target.getEffectiveAvatarUrl());
    } else {
        embedBuilder.setThumbnail(author.getUser().getEffectiveAvatarUrl());
    }

    embedBuilder.addField("Reason", reason, false);
    embedBuilder.addField("Channel", channel, true);

    if (action == ModAction.PRUNE) {
        embedBuilder.addField("Messages Deleted", String.valueOf(messagesDeleted), true);
    }

    //Why was this a giant switch statement?
    embedBuilder.setAuthor(String.format("%s | Case #%s", Utils.capitalize(action.name()), caseNumber),
            null, author.getUser().getEffectiveAvatarUrl());

    if (!playerData.hasBadge(Badge.POWER_USER)) {
        playerData.addBadgeIfAbsent(Badge.POWER_USER);
        player.saveAsync();
    }

    if (guildDB.getData().getGuildLogChannel() != null) {
        TextChannel logChannel = MantaroBot.getInstance().getShardManager().getTextChannelById(guildDB.getData().getGuildLogChannel());
        if (logChannel != null) {
            logChannel.sendMessage(embedBuilder.build()).queue();
        }
    }
}
 
Example 13
Source Project: JuniperBot   Source File: DayHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onEnd(User user, MafiaInstance instance) {
    MafiaPlayer toExile = getChoiceResult(instance);
    if (toExile != null) {
        instance.getDailyActions().put(MafiaActionType.EXILE, toExile);
    }
    unpinMessage(instance);
    return goonHandler.onStart(user, instance);
}
 
Example 14
Source Project: JDA   Source File: GenericMessageReactionEvent.java    License: Apache License 2.0 5 votes vote down vote up
public GenericMessageReactionEvent(@Nonnull JDA api, long responseNumber, @Nonnull User user,
                                   @Nullable Member member, @Nonnull MessageReaction reaction, long userId)
{
    super(api, responseNumber, reaction.getMessageIdLong(), reaction.getChannel());
    this.userId = userId;
    this.issuer = user;
    this.member = member;
    this.reaction = reaction;
}
 
Example 15
Source Project: JuniperBot   Source File: ChoosingHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onStart(User user, MafiaInstance instance) {
    instance.tick();
    String delayText = getEndTimeText(instance, CHOOSING_DELAY);
    EmbedBuilder builder = getBaseEmbed("mafia.start.message");

    GuildConfig config = configService.get(instance.getGuild());
    String nextCommand = messageService.getMessageByLocale("discord.command.mafia.done.key", config.getCommandLocale());

    builder.setFooter(messageService.getMessage("mafia.start.message.footer", delayText, instance.getPrefix(), nextCommand), null);

    TextChannel channel = instance.getChannel();
    if (channel == null) {
        return true; // end for non existent channel instantly
    }

    channel.sendMessage(builder.build()).queue(message -> {
        message.addReaction(CHOOSE).queue();
        instance.getListenedMessages().add(message.getId());
        reactionsListener.onReaction(message.getId(), (event, add) -> {
            if (!instance.isInState(MafiaState.CHOOSING)) {
                return true;
            }
            String emote = event.getReaction().getReactionEmote().getName();
            if (!event.getUser().equals(event.getJDA().getSelfUser()) && !event.getUser().isBot() && CHOOSE.equals(emote)) {
                instance.tick();
                if (add && instance.getPlayers().size() < 10) {
                    instance.getPlayers().add(new MafiaPlayer(event.getMember()));
                }
                if (!add) {
                    instance.getPlayers().removeIf(e -> event.getMember().getUser().getIdLong() == e.getMemberId());
                }
            }
            return false;
        });
    });
    return scheduleEnd(instance, CHOOSING_DELAY);
}
 
Example 16
Source Project: JDA   Source File: AudioWebSocket.java    License: Apache License 2.0 5 votes vote down vote up
private User getUser(final long userId)
{
    JDAImpl api = getJDA();
    User user = api.getUserById(userId);
    if (user != null)
        return user;
    return api.getFakeUserMap().get(userId);
}
 
Example 17
Source Project: MantaroBot   Source File: InvestigateCmd.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static void investigateUser(GuildMessageReceivedEvent event, User user, boolean file) {
    if (user == null) {
        event.getChannel().sendMessage("Unknown user").queue();
        return;
    }
    EmbedBuilder eb = new EmbedBuilder()
            .setTitle("Please pick a guild")
            .setColor(Color.PINK);
    DiscordUtils.selectList(event, user.getMutualGuilds(), Guild::toString, s -> eb.setDescription(s).build(), g -> investigateGuild(event, g, file));
}
 
Example 18
Source Project: JDA   Source File: GenericPrivateMessageReactionEvent.java    License: Apache License 2.0 5 votes vote down vote up
public GenericPrivateMessageReactionEvent(@Nonnull JDA api, long responseNumber, @Nullable User user, @Nonnull MessageReaction reaction, long userId)
{
    super(api, responseNumber, reaction.getMessageIdLong(), (PrivateChannel) reaction.getChannel());
    this.userId = userId;
    this.issuer = user;
    this.reaction = reaction;
}
 
Example 19
Source Project: DiscordSRV   Source File: PrettyUtil.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static String beautify(User user) {
    if (user == null) return "<Unknown>";

    Member member = DiscordSRV.getPlugin().getMainGuild().getMember(user);

    return member != null
            ? member.getEffectiveName() + " (#" + user.getId() + ")"
            : user.getName() + " (#" + user.getId() + ")";
}
 
Example 20
private Object getAuthor(GenericEvent event) {
    if (event == null) {
        return null;
    }
    Class<? extends GenericEvent> clazz = event.getClass();
    Method method;
    if (!userAccessors.containsKey(clazz)) {
        method = ReflectionUtils.findMethod(clazz, "getUser");
        if (method == null) {
            method = ReflectionUtils.findMethod(clazz, "getAuthor");
        }
        userAccessors.put(clazz, method);
    } else {
        method = userAccessors.get(clazz);
    }
    if (method != null) {
        try {
            Object result = ReflectionUtils.invokeMethod(method, event);
            if (result instanceof User) {
                return result;
            }
        } catch (Exception e) {
            // we don't care
        }
    }
    return null;
}
 
Example 21
Source Project: MantaroBot   Source File: AudioUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static String getQueueList(ConcurrentLinkedDeque<AudioTrack> queue) {
    StringBuilder sb = new StringBuilder();
    int n = 1;
    for (AudioTrack audioTrack : queue) {
        long aDuration = audioTrack.getDuration();
        String duration = String.format("%02d:%02d",
                TimeUnit.MILLISECONDS.toMinutes(aDuration),
                TimeUnit.MILLISECONDS.toSeconds(aDuration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(aDuration))
        );

        User dj = audioTrack.getUserData() != null ? MantaroBot.getInstance().getShardManager()
                .getUserById(String.valueOf(audioTrack.getUserData())) : null;

        sb.append("**")
                .append(n)
                .append(". [")
                .append(StringUtils.limit(audioTrack.getInfo().title, 30))
                .append("](")
                .append(audioTrack.getInfo().uri)
                .append(")** (")
                .append(duration)
                .append(")")
                .append(dj != null ? " **[" + dj.getName() + "]**" : "")
                .append("\n");
        n++;
    }
    return sb.toString();
}
 
Example 22
Source Project: SkyBot   Source File: UnbanCommand.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void execute(@Nonnull CommandContext ctx) {
    final GuildMessageReceivedEvent event = ctx.getEvent();
    final var flags = ctx.getParsedFlags(this);
    final String argsJoined = String.join(" ", flags.get("undefined"));
    final User mod = ctx.getAuthor();

    try {
        event.getGuild().retrieveBanList().queue((list) -> {

            for (final Guild.Ban ban : list) {
                final User bannedUser = ban.getUser();
                final String userFormatted = bannedUser.getAsTag();


                if (bannedUser.getName().equalsIgnoreCase(argsJoined) || bannedUser.getId().equals(argsJoined) ||
                    userFormatted.equalsIgnoreCase(argsJoined)) {

                    String reason = "Unbanned by " + mod.getAsTag();

                    if (flags.containsKey("r")) {
                        reason = reason + ": " + String.join(" ", flags.get("r"));
                    }

                    event.getGuild().unban(bannedUser)
                        .reason(reason)
                        .queue();

                    sendMsg(event, "User " + userFormatted + " unbanned.");
                    modLog(mod, ban.getUser(), "unbanned", ctx.getGuild());
                    return;
                }
            }
            sendMsg(event, "This user is not banned");
        });

    }
    catch (Exception e) {
        e.printStackTrace();
        sendMsg(event, "ERROR: " + e.getMessage());
    }
}
 
Example 23
Source Project: MantaroBot   Source File: ManagedDatabase.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Nonnull
@CheckReturnValue
public SeasonPlayer getPlayerForSeason(@Nonnull User user, Season season) {
    return getPlayerForSeason(user.getId(), season);
}
 
Example 24
Source Project: MantaroBot   Source File: DBUser.java    License: GNU General Public License v3.0 4 votes vote down vote up
@JsonIgnore
public User getUser() {
    return MantaroBot.getInstance().getShardManager().getUserById(getId());
}
 
Example 25
Source Project: MantaroBot   Source File: UnifiedPlayer.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static UnifiedPlayer of(User user, Season season) {
    return UnifiedPlayer.of(user.getId(), season);
}
 
Example 26
public AccountLinkedEvent(User user, UUID playerUuid) {
    this.player = Bukkit.getOfflinePlayer(playerUuid);
    this.user = user;
}
 
Example 27
Source Project: MantaroBot   Source File: SeasonPlayer.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static SeasonPlayer of(User user, Season season) {
    return of(user.getId(), season);
}
 
Example 28
Source Project: JDA   Source File: UserUpdateDiscriminatorEvent.java    License: Apache License 2.0 4 votes vote down vote up
public UserUpdateDiscriminatorEvent(@Nonnull JDA api, long responseNumber, @Nonnull User user, @Nonnull String oldDiscriminator)
{
    super(api, responseNumber, user, oldDiscriminator, user.getDiscriminator(), IDENTIFIER);
}
 
Example 29
Source Project: JDA   Source File: UserAudio.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * The {@link net.dv8tion.jda.api.entities.User User} that provided the audio data.
 *
 * @return Never-null {@link net.dv8tion.jda.api.entities.User User} object.
 */
@Nonnull
public User getUser()
{
    return user;
}
 
Example 30
Source Project: JDA   Source File: InviteCreateHandler.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected Long handleInternally(DataObject content)
{
    long guildId = content.getUnsignedLong("guild_id");
    if (getJDA().getGuildSetupController().isLocked(guildId))
        return guildId;
    Guild realGuild = getJDA().getGuildById(guildId);
    if (realGuild == null)
    {
        EventCache.LOG.debug("Caching INVITE_CREATE for unknown guild with id {}", guildId);
        getJDA().getEventCache().cache(EventCache.Type.GUILD, guildId, responseNumber, allContent, this::handle);
        return null;
    }

    long channelId = content.getUnsignedLong("channel_id");
    GuildChannel realChannel = realGuild.getGuildChannelById(channelId);
    if (realChannel == null)
    {
        EventCache.LOG.debug("Caching INVITE_CREATE for unknown channel with id {} in guild with id {}", channelId, guildId);
        getJDA().getEventCache().cache(EventCache.Type.CHANNEL, channelId, responseNumber, allContent, this::handle);
        return null;
    }

    String code = content.getString("code");
    boolean temporary = content.getBoolean("temporary");
    int maxAge = content.getInt("max_age", -1);
    int maxUses = content.getInt("max_uses", -1);
    OffsetDateTime creationTime = content.opt("created_at")
            .map(String::valueOf)
            .map(OffsetDateTime::parse)
            .orElse(null);

    Optional<DataObject> inviterJson = content.optObject("inviter");
    boolean expanded = maxUses != -1;

    User inviter = inviterJson.map(json -> getJDA().getEntityBuilder().createFakeUser(json)).orElse(null);
    InviteImpl.ChannelImpl channel = new InviteImpl.ChannelImpl(realChannel);
    InviteImpl.GuildImpl guild = new InviteImpl.GuildImpl(realGuild);

    Invite invite = new InviteImpl(getJDA(), code, expanded, inviter, maxAge, maxUses, temporary, creationTime, 0, channel, guild, null, Invite.InviteType.GUILD);
    getJDA().handleEvent(
        new GuildInviteCreateEvent(
            getJDA(), responseNumber,
            invite, realChannel));
    return null;
}