Skip to content

New invite and reaction events, and a new endpoint! #1309

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

Merged
merged 10 commits into from
Mar 3, 2020

Conversation

msciotti
Copy link
Contributor

@msciotti msciotti commented Jan 18, 2020

We built this: #838

There's a new endpoint and event that goes with it!

There's also some new events for when invites are created and deleted.

The features flags on the reactions endpoint should be abled now; if you have issues accessing it, please let us know here.

Copy link
Contributor

@kyranet kyranet left a comment

Choose a reason for hiding this comment

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

Is there any reason why the MESSAGE_REACTION_REMOVE_EMOJI packet doesn't include a guild_id field? Feels inconsistent with MESSAGE_REACTION_REMOVE_ALL.

@msciotti
Copy link
Contributor Author

msciotti commented Jan 18, 2020

@RogueException could speak better to that one, if ya don't mind just kidding, turns out I'm blind

@night
Copy link
Member

night commented Jan 18, 2020

probably a documentation bug? all events sent from guilds have a guild_id injected into them.

@MBR-0001
Copy link
Contributor

Looks like the invite events are sent to a bot only if it has the MANAGE_CHANNELS permission, this may be worth documenting (unless there's a plan to remove this requirement?)

@Dramex
Copy link

Dramex commented Jan 19, 2020

#448 when

@spergmoment
Copy link
Contributor

I noticed MESSAGE_REACTION_ADD is also quite... odd. Its hard to get any asynchronous events from it, is this known or is it normal.

cakedan added a commit to detritusjs/client-rest that referenced this pull request Jan 24, 2020
from discord/discord-api-docs#1309

the bug came from null being counted as objects which I forgot about
@ghost
Copy link

ghost commented Jan 24, 2020

I feel like in the same way you provide us full info on a message that is deleted, with all the metadata, you should consider providing this information on the delete endpoint for invites like you do for create.

The main issue I am finding is that without having to keep a full history client side of every reaction made, users will still struggle to find out who created the invite that just got deleted, etc, which would be overly useful for auditing as well as for providing a consistent interface to the end user.

For example, in the framework I am implementing currently, I can provide the full invite object to the user on the invite_create event, but on the invite delete event, I can only provide the guild, channel, and the invite code, which is inconsistent and doesn't provide any real benefit to the user other than a string of a few characters representing the URL that no longer works.

@Skillz4Killz
Copy link
Contributor

If memory serves MESSAGE_DELETE only provides a id, channel id and guild id. Isn't it just the same way to handle invites? Cache the invites so you can provide it the lib user when its deleted

@ghost
Copy link

ghost commented Jan 24, 2020

@Skillz4Killz maybe i was mistaken then; the problem is that without having to physically request invites for each guild on startup, there is no way to determine what the invite was that just got removed, which is not helpful for moderation bots, for example, that may go offline during a partial outage; it is one more place that you have to rely on a bot having 100% uptime to provide the ability to track invites correctly.

While this might be fine for things like messages, I would assume the main usecase for tracking invite creation and deletion in the first place is for moderation purposes. Presumably this information is still available to Discord before they delete the entity in their backend.

I guess my point is this: for the sake of a slightly larger payload, you would be able to provide much greater detail to bots about what invite was actually removed, even if the invite was added before the bot came online. It would also then reduce the number of bots that are spamming the get invites endpoint on startup/resume/guild creation to fill in this missing information.

For the argument of performance, this sort of operation should be seen much less frequently than with other endpoints such as message deletion.

The other solution would be to include invite data in the Guild entity that is sent on guild creation if the bot has permission to view them

@ghost
Copy link

ghost commented Jan 24, 2020

true, the other fields that you mentioned would be useful though; I'll admit I didn't really think this through before opening my mouth lol

| code | string | the unique invite [code](#DOCS_RESOURCES_INVITE/invite-object) |
| created_at | timestamp | the time at which the invite was created |
| guild_id | snowflake | the guild of the invite |
| inviter | [partial user object](#DOCS_TOPICS_GATEWAY/invite-create-partial-user-object) | the user that created the invite |
Copy link
Member

Choose a reason for hiding this comment

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

we should just clone https://discordapp.com/developers/docs/resources/invite#invite-metadata-object behavior and link to the user object as this event is just serializing the invite the same way. then we avoid redocumenting user

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I notice here that we actually serialize this different than our normal invite object. Our invite object from our REST API returns guild and channel objects in which are id fields, but this event flattens them out. From our API:

"code": "123456",
    "guild": {
        "id": "290926798626999999",
        "name": "Mason's Test Server",
        "splash": "75610b05a0dd09ec2c3c7df9f6975ea0",
        "banner": "5c3cb8d1bc159937fffe7e641ec96ca7",
        "description": null,
        "icon": "389030ec9db118cb5b85a732333b7c98",
        "features": [
            "BANNER",
            "NEWS",
            "INVITE_SPLASH",
            "VANITY_URL",
            "COMMERCE",
            "VERIFIED",
            "VIP_REGIONS"
        ],
        "verification_level": 0,
        "vanity_url_code": "absh12385f"
    },
    "channel": {
        "id": "651144899865089999",
        "name": "news",
        "type": 0
    },
    "inviter": {
        "id": "53908232506183680",
        "username": "Mason",
        "avatar": "a_d5efa99b3eeaa7dd43acca82f5692432",
        "discriminator": "1337"
    }
}

Should we normalize these?

@Erk-
Copy link
Contributor

Erk- commented Feb 5, 2020

It seems that the INVITE_CREATE event is currently sometimes sent without the inviter field. Is this a bug or an issue with the documentation?

@night
Copy link
Member

night commented Feb 5, 2020

Invites do not always have an inviter. For example, an invite created by a widget has no inviter.

msciotti and others added 6 commits February 28, 2020 11:01
- INVITE_CREATE event
- INVITE_DELETE event
- MESSAGE_REACITON_REMOVE_EMOJI event
- Delete all reactions for an emoji endpoint
Co-Authored-By: Pedro Arenas <[email protected]>
@msciotti msciotti force-pushed the feature/invite-and-reaction-events branch from 6e3659b to cb3a411 Compare February 28, 2020 19:14
Copy link
Member

@night night left a comment

Choose a reason for hiding this comment

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

lgtm otherwise

@msciotti msciotti merged commit 33ecdc9 into master Mar 3, 2020
@msciotti msciotti deleted the feature/invite-and-reaction-events branch March 3, 2020 21:04
l7ssha added a commit to nyxx-discord/nyxx that referenced this pull request Apr 9, 2020
l7ssha added a commit to nyxx-discord/nyxx that referenced this pull request Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.