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

Get invite code on member Join #804

Open
4 of 5 tasks
YukioKeno opened this issue Oct 14, 2018 · 12 comments
Open
4 of 5 tasks

Get invite code on member Join #804

YukioKeno opened this issue Oct 14, 2018 · 12 comments
Labels
type: discord issue seems to be an issue on discord's end type: feature

Comments

@YukioKeno
Copy link

YukioKeno commented Oct 14, 2018

General Troubleshooting

  • I have checked for similar issues.
  • I have updated to the latest JDA version.
  • I have checked the branches or the maintainers' PRs for upcoming features/bug fixes.

Issue

Issue Type

  • Bug Report
  • Feature Request

Description

Get info of the invite code when user join if they join via a invite link.

@schnapster
Copy link
Contributor

schnapster commented Oct 14, 2018

This information is not available from the Discord API...yet.

See discord/discord-api-docs#448

@MinnDevelopment MinnDevelopment added type: discord issue seems to be an issue on discord's end type: feature labels Oct 14, 2018
@reflexin
Copy link

I wrote a bot to do this with an algorithm, so it's still possible to create.

@YukioKeno
Copy link
Author

And how do you code that?

@BenjaminUrquhart
Copy link
Contributor

BenjaminUrquhart commented Oct 15, 2018

@YukioKeno

  1. Store how many times all invites have been used
  2. When a user joins, see which invite has a use incremented by 1
  3. That's probably the invite they used.

@YukioKeno
Copy link
Author

Okay thank you. I'll try that :)

@MinnDevelopment MinnDevelopment pinned this issue Dec 14, 2018
@zaanposni
Copy link

Note:
I think this was not relevant in 2018 but nowadays you also have to check for missing invites in your new list as they could be expired by MaxUses.
Furthermore, if there are two or more invites missing and only one of those had MaxUses, this is the invite that has been used. (The others expired by time)

If two or more invites are missing in your new list you cannot safely assign the used invite. This most likely happens if you forget to cache new invites on GuildInviteCreateEvent.

@MinnDevelopment MinnDevelopment unpinned this issue Dec 15, 2020
@KaiKikuchi
Copy link

Although I believe we still cannot get the invite code when a member joins, we can now get the invite code for a member with the new "member search" feature.

I hope we can at least get that, so that our bots can just search for the invite code when a new member joins the server. Thanks!

Related discussion comment:
discord/discord-api-docs#3210 (comment)

@MinnDevelopment
Copy link
Member

@KaiKikuchi bots cannot access this endpoint.

@kohlerpop1
Copy link

kohlerpop1 commented Feb 10, 2024

This is now possible to retrieve via the API.

image
image
image
Post body accepts json of how many users you want of 1000 maximum.
Only required header: Authorization: Bot {Bot-Token}
I believe this should be added to the member object as it is sent with every member now.
Here is a sample response!

{
    "guild_id": "{guild-id}",
    "members": [
        {
            "member": {
                "avatar": null,
                "communication_disabled_until": null,
                "flags": 0,
                "joined_at": "2024-02-09T15:41:13.354000+00:00",
                "nick": null,
                "pending": false,
                "premium_since": null,
                "roles": [],
                "unusual_dm_activity_until": null,
                "user": {
                    "id": "example-id",
                    "username": "example-username",
                    "avatar": "2699fbf2e65df3ee85ecd2a84ce45cac",
                    "discriminator": "0",
                    "public_flags": 0,
                    "premium_type": 0,
                    "flags": 0,
                    "banner": null,
                    "accent_color": null,
                    "global_name": "Example Name",
                    "avatar_decoration_data": null,
                    "banner_color": null
                },
                "mute": false,
                "deaf": false
            },
            "source_invite_code": "XHVBNhMuUw",
            "join_source_type": 5,
            "inviter_id": "203200098426028526"
        }, {...}
    ],
    "page_result_count": 126,
    "total_result_count": 126
}

Originally found here: discord/discord-api-docs#3210

@freya022
Copy link
Contributor

Good chances it won't be added until it's documented

@MinnDevelopment
Copy link
Member

This endpoint is still unfinished and not intended to be used in production. JDA does not support unfinished API features.

@kohlerpop1
Copy link

Yep. I am aware both of what you are saying is correct however I wanted to make it visible to those who want/need to use it even before it is added to the JDA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: discord issue seems to be an issue on discord's end type: feature
Projects
None yet
Development

No branches or pull requests

9 participants