Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for user-installable apps #2633

Open
wants to merge 41 commits into
base: master
Choose a base branch
from

Conversation

freya022
Copy link
Contributor

@freya022 freya022 commented Mar 22, 2024

Pull Request Etiquette

Changes

  • Internal code
  • Library interface (affecting end-user code)
  • Documentation
  • Other: _____

Closes Issue: NaN

Description

This adds support for https://discord.com/developers/docs/change-log#userinstallable-apps-preview.

You are able to create application commands using the new properties, read the new data structures provided in ApplicationInfo, Interaction and Message, as well as responding to interactions in detached guilds (where your bot isn't it in) and group DMs.

@freya022 freya022 force-pushed the feature/user-installable-apps branch from a55eba3 to 5bc36cb Compare March 26, 2024 11:02
@freya022 freya022 force-pushed the feature/user-installable-apps branch 3 times, most recently from 8bb9df6 to 34bae66 Compare April 11, 2024 20:35
@freya022 freya022 changed the title Add partial support for user-installable apps Add support for user-installable apps Apr 11, 2024
@freya022 freya022 force-pushed the feature/user-installable-apps branch from 7d78c12 to f2d4e9d Compare April 12, 2024 20:42
@freya022 freya022 marked this pull request as ready for review April 12, 2024 21:05
@freya022 freya022 force-pushed the feature/user-installable-apps branch from d2d8463 to a1a3954 Compare April 23, 2024 21:16
Copy link
Contributor

@Xirado Xirado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking quite good

@Ran-Mewo
Copy link

There seems to be a caching issue
If two different people use the same command in the same dm then all subsequent event.getUser() will return whoever used the command first.

@freya022 freya022 force-pushed the feature/user-installable-apps branch from c495b94 to 5488620 Compare May 18, 2024 16:20
@freya022
Copy link
Contributor Author

There seems to be a caching issue If two different people use the same command in the same dm then all subsequent event.getUser() will return whoever used the command first.

Should be fixed

@Ran-Mewo
Copy link

I am not sure if this is an issue on my code or the library
but updating attachments with editOriginalAttachments doesn't actually cause it to update unless you restart your discord

it's not an issue on my client as it also occurs for other people

@freya022
Copy link
Contributor Author

I am not sure if this is an issue on my code or the library but updating attachments with editOriginalAttachments doesn't actually cause it to update unless you restart your discord

it's not an issue on my client as it also occurs for other people

As you mentioned, restarting the client fixes the issue, so it's not a JDA issue

@Ran-Mewo
Copy link

Ran-Mewo commented May 26, 2024

I really doubt it's not a JDA issue, it works in other discord frameworks
Replying to an interaction using reply and then editing the original hook's attachments just doesn't work on JDA (well it does but discord doesn't update it)

sigh at this point I just give up, I have to resort to putting my image in an embed (by using .setImage("attachment://" + fileName))
I really hate how images in embeds get scaled down but that's a discord problem

the thing that annoys me the most is that it used to work, I don't know what changed nor do I know if it's something to do with your new changes

@freya022
Copy link
Contributor Author

Can't repro with the code below, please share minimal reproduction code if you can

public void onSlashReplyEditAttachment(SlashCommandInteractionEvent event, Message.Attachment attachment, Message.Attachment attachment2) throws Exception {
    final byte[] bytes = getBytes(attachment);
    final byte[] bytes2 = getBytes(attachment2);

    event.replyFiles(FileUpload.fromData(bytes, attachment.getFileName()))
            .setEphemeral(true) // Tried without ephemeral too
            .queue();

    event.getHook()
            .editOriginalAttachments(FileUpload.fromData(bytes2, attachment.getFileName()))
            .queue();
}

private byte[] getBytes(Message.Attachment attachment) throws Exception {
    try (InputStream stream = attachment.getProxy().download().get()) {
        return stream.readAllBytes();
    }
}

@ErfinderLabyrinth
Copy link

Maybe a UserJoinEvent(like GuildJoinEvent for userapps) and a JDA.getInstalledAppUsers()(like JDA.getGuilds() for userapps)

@freya022
Copy link
Contributor Author

Maybe a UserJoinEvent(like GuildJoinEvent for userapps) and a JDA.getInstalledAppUsers()(like JDA.getGuilds() for userapps)

Discord doesn't have a way to get who installed the application on their accounts

As a reminder, JDA adds what Discord documents, if it isn't in the Discord docs, we can't add it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants