Pycord-Development / pycord

Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python
https://docs.pycord.dev
MIT License
2.7k stars 459 forks source link

on_scheduled_event_delete event parameter is useless #1709

Open Sedpower opened 1 year ago

Sedpower commented 1 year ago

Summary

event parameter contains nothing relevant

Reproduction Steps

just implement the on_sceduled_event_delete then print for example event.interested it will print None

Minimal Reproducible Code

@commands.Cog.listener()
async def on_scheduled_event_delete(self, event):
    print("Event on_scheduled_event_delete")
    print(f"event.subscriber_count : {event.subscriber_count}")
    print(f"event.guild.id : {event.guild.id}")

    async for member in event.subscribers(as_member=True):
        print(member.display_name)

Expected Results

Event on_scheduled_event_delete
event.subscriber_count : 3
event.guild.id : 790988862448861234
Sedpower
SDPR
Powersed

Actual Results

Event on_scheduled_event_delete
event.subscriber_count : None
event.guild.id : 790988862448861234
Ignoring exception in on_scheduled_event_delete
Traceback (most recent call last):
  File "/home/erwan/.local/lib/python3.8/site-packages/discord/client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "/home/erwan/perso/code/python/discord/test/cogs/scheduledEvent.py", line 54, in on_scheduled_event_delete
    async for member in event.subscribers(as_member=True):
  File "/home/erwan/.local/lib/python3.8/site-packages/discord/iterators.py", line 124, in __anext__
    return await self.next()
  File "/home/erwan/.local/lib/python3.8/site-packages/discord/iterators.py", line 858, in next
    await self.fill_subs()
  File "/home/erwan/.local/lib/python3.8/site-packages/discord/iterators.py", line 896, in fill_subs
    data = await self.get_subscribers(
  File "/home/erwan/.local/lib/python3.8/site-packages/discord/http.py", line 355, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10070): Unknown Guild Scheduled Event

Intents

Intents.all()

System Information

- Python v3.8.10-final
- py-cord v2.2.0-final
- aiohttp v3.7.4.post0
- system info: Linux 5.15.0-50-generic #56~20.04.1-Ubuntu SMP Tue Sep 27 15:51:29 UTC 2022

Checklist

Additional Context

I want to remove a role which is added when a user click on intserested but when a scheduled event finish by itself, on_sceduled_event_delete os not even executed. And when I manually delete an event, I cant access to the list of members who were interested by the event before deletion because it is null. So why put the event as argument of on_sceduled_event_delete event listener if all data is None ...

NeloBlivion commented 1 year ago

It's not useless, the behaviour here is normal. ScheduledEvent.subscribers() is a method that fetches them from Discord; since it was deleted, this is impossible as it no longer exists. The only workaround to this would be to internally cache the subscribed members.

Sedpower commented 1 year ago

:/ this is counter intuitive And do you know why this event isnt called when an event finish by himself but only when someone delete cancel it ?

NeloBlivion commented 1 year ago

And do you know why this event isnt called when an event finish by himself but only when someone delete cancel it ?

Because that's what it is, the delete event. If an event has an end_time and that time has passed then it calls on_scheduled_event_update with after.status as discord.ScheduledEventStatus.completed

Sedpower commented 1 year ago

And do you know why this event isnt called when an event finish by himself but only when someone delete cancel it ?

Because that's what it is, the delete event. If an event has an end_time and that time has passed then it calls on_scheduled_event_update with after.status as discord.ScheduledEventStatus.completed

ok I thought the event was deleted when it ended

Middledot commented 1 year ago

The only workaround to this would be to internally cache the subscribed members.

User caching could be implemented, so this can stay open as a feature request

Sedpower commented 1 year ago

The only workaround to this would be to internally cache the subscribed members.

User caching could be implemented, so this can stay open as a feature request

Yeah it could be a very usefull feature