discord / discord-api-docs

Official Discord API Documentation
https://discord.com/developers/docs/intro
Other
5.95k stars 1.26k forks source link

API returns scheduled events with no creator_id #6481

Open honzajavorek opened 1 year ago

honzajavorek commented 1 year ago

Description

The API returns scheduled events from my guild with no creator_id, although those are recently created events and although this has worked a few days before. I made no changes to my code and it started crashing, because it assumed creator_id is always populated (I know it's optional, but only for very old events).

Steps to Reproduce

I made my bot so that it only enriches my own guild, hence I cannot confirm if this is guild-specific or not. I use pycord:

guild = client.get_guild(769966886598737931)
for scheduled_event in guild.scheduled_events:
    print(repr(scheduled_event))
    print(scheduled_event.creator_id)

I'm sure it's bug of the API, because I locally modified pycord's files so that the ScheduledEvent object logs whatever data it is initialized to my terminal and I could see the raw data. There is no creator_id at all for any of the current 14 events scheduled in my guild.

Expected Behavior

The scheduled events should have creator ID unless they're very old, per documentation.

Current Behavior

There is no key creator_id in the raw data received from the API for any of the scheduled events in my guild.

Screenshots/Videos

No response

Client and System Information

I have the following in my pyproject.toml:

py-cord = {version = "2.4.1", extras = ["speed"]}

The whole repo is here, but it's a huge heap of code. I'll happily navigate you through it if desired though.

Possibly Related Issues

I found https://github.com/discord/discord-api-docs/issues/5352 and https://github.com/discord/discord-api-docs/issues/5940, but those look like old issues. This seems to be something introduced to the API just a few days ago.

Auralytical commented 1 year ago

Heyhey, I wasn't able to repro this on my end (I see creator_id provided for both API request and gateway events for a newly created event). Is this still an issue?

honzajavorek commented 1 year ago

@Auralytical I will check and confirm if it's still true. Also might try a different server if it's server-specific.

DV8FromTheWorld commented 1 year ago

Following up @honzajavorek were you able to double check this? Closing the issue soon due to non-reproability

honzajavorek commented 1 year ago

I have minimal reproducible example working: example.zip

Installation

What happens

honzajavorek commented 1 year ago

I created completely new server (1166673072393289848, for the record) and authorized my bot (application 797097976571887687, for the record) to be an admin there. I created a sample event and tried to run the same code with the guild ID set to 1166673072393289848. The initial payload printed to my console looks like this:

...
'guild_scheduled_events': [{'test': None, 'status': 1, 'sku_ids': [], 'scheduled_start_time': '2023-12-24T12:00:00+00:00', 'scheduled_end_time': '2023-12-24T13:00:00+00:00', 'recurrence_rule': None, 'privacy_level': 2, 'name': 'Pokus', 'image': None, 'id': '1166675763718782997', 'guild_scheduled_event_exceptions': [], 'guild_id': '1166673072393289848', 'entity_type': 3, 'entity_metadata': {'location': 'Praha'}, 'entity_id': None, 'description': 'Tralala', 'channel_id': None, 'auto_start': False}]
...

The result is, again, no creator_id set:

INFO:creator_id:Logged in as kuře#7420
INFO:creator_id:Accessing guild 1166673072393289848 (change this by setting DISCORD_GUILD_ID env var)
INFO:creator_id:Guild name: Kurník
INFO:creator_id:Accessing scheduled events
INFO:creator_id:Scheduled event 1166675763718782997: Pokus
INFO:creator_id:Creator ID: None
honzajavorek commented 1 year ago

FWIW, if you're not up to running the code, the initial logs go like below. When I mention initial payload in my previous comments, what I mean is the content of the WebSocket Event: {'t': 'GUILD_CREATE' lines.

DEBUG:asyncio:Using selector: KqueueSelector
WARNING:discord.client:PyNaCl is not installed, voice will NOT be supported
DEBUG:discord.client:on_ready has successfully been registered as an event
INFO:discord.client:logging in using static token
DEBUG:discord.http:GET https://discord.com/api/v10/users/@me with None has returned 200
DEBUG:discord.http:GET https://discord.com/api/v10/users/@me has received {'id': '797097976571887687', 'username': 'kuře', 'avatar': '47ed1251b517a153e95fc4345d22883c', 'discriminator': '7420', 'public_flags': 0, 'premium_type': 0, 'flags': 0, 'bot': True, 'banner': None, 'accent_color': None, 'global_name': None, 'avatar_decoration_data': None, 'banner_color': None, 'mfa_enabled': True, 'locale': 'en-US', 'email': None, 'verified': True, 'bio': ''}
DEBUG:discord.http:GET https://discord.com/api/v10/gateway with None has returned 200
DEBUG:discord.http:GET https://discord.com/api/v10/gateway has received {'url': 'wss://gateway.discord.gg'}
DEBUG:discord.gateway:Created websocket connected to wss://gateway.discord.gg?encoding=json&v=10&compress=zlib-stream
DEBUG:discord.gateway:For Shard ID None: WebSocket Event: {'t': None, 's': None, 'op': 10, 'd': {'heartbeat_interval': 41250, '_trace': ['["gateway-prd-us-east1-b-tsk4",{"micros":0.0}]']}}
INFO:discord.gateway:Shard ID None has sent the IDENTIFY payload.
DEBUG:discord.gateway:For Shard ID None: WebSocket Event: {'t': None, 's': None, 'op': 11, 'd': None}
DEBUG:discord.gateway:For Shard ID None: WebSocket Event: {'t': 'READY', 's': 1, 'op': 0, 'd': {'v': 10, 'user_settings': {}, 'user': {'verified': True, 'username': 'kuře', 'mfa_enabled': True, 'id': '797097976571887687', 'global_name': None, 'flags': 0, 'email': None, 'discriminator': '7420', 'bot': True, 'avatar': '47ed1251b517a153e95fc4345d22883c'}, 'session_type': 'normal', 'session_id': '=== REDACTED ===', 'resume_gateway_url': 'wss://gateway-us-east1-b.discord.gg', 'relationships': [], 'private_channels': [], 'presences': [], 'guilds': [{'unavailable': True, 'id': '769966886598737931'}, {'unavailable': True, 'id': '1166673072393289848'}], 'guild_join_requests': [], 'geo_ordered_rtc_regions': ['frankfurt', 'milan', 'rotterdam', 'stockholm', 'bucharest'], 'auth': {}, 'application': {'id': '797097976571887687', 'flags': 557056}, '_trace': ['=== REDACTED ===']}}
DEBUG:discord.client:Dispatching event socket_event_type
INFO:discord.gateway:Shard ID None has connected to Gateway: === REDACTED ===
DEBUG:discord.client:Dispatching event connect
DEBUG:discord.gateway:For Shard ID None: WebSocket Event: {'t': 'GUILD_CREATE', 's': 2, 'op': 0, 'd': {'lazy': True, 'embedded_activities': [], 'members': [... === REDACTED ===}
DEBUG:discord.client:Dispatching event socket_event_type
DEBUG:discord.client:Dispatching event guild_available
DEBUG:discord.gateway:For Shard ID None: WebSocket Event: {'t': 'GUILD_CREATE', 's': 3, 'op': 0, 'd': {'lazy': True, 'embedded_activities': [], 'members': [... === REDACTED ===}
DV8FromTheWorld commented 1 year ago

I can confirm that this is a problem for initial connections and certain other events. For now, until we get a fix out, you should be able to get the creator id of the event using the GET endpoint

honzajavorek commented 1 year ago

Thanks!

On Thu 26. 10. 2023 at 21:08, Austin Keener @.***> wrote:

I can confirm that this is a problem for initial connections and certain other events.

— Reply to this email directly, view it on GitHub https://github.com/discord/discord-api-docs/issues/6481#issuecomment-1781745485, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACFGMK3KJI43KBGK5LZDFTYBKYKRAVCNFSM6AAAAAA54OW5ZCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBRG42DKNBYGU . You are receiving this because you were mentioned.Message ID: @.***>