Repository: Pycord-Development/pycord

Issue:
"store_user user_id = int(data['id']) KeyError: 'id'" on event.subscribers
### Summary

Trying to get event.subscribers fails everytime

### Reproduction Steps

I use part of the [event.subscribers](https://docs.pycord.dev/en/master/api.html?highlight=event%20subscriber_count#discord.ScheduledEvent.subscriber_count) documentation:
```py
event = ctx.guild.get_scheduled_event(int(eventid))

if event is not None:
    async for member in event.subscribers(as_member=True, limit=100, before=datetime.datetime.utcnow(), after=event.created_at):
        print(member.display_name)
```

### Minimal Reproducible Code

_No response_

### Expected Results

A list of all subscribers to an event as discord.Member objects.

### Actual Results

Nothing...

### Intents

guilds=True, members=True, reactions=True

### System Information

- Python v3.10.0-final
- py-cord v2.0.0-alpha
    - py-cord pkg_resources: v2.0.0a4771+gef9b5983
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.22000

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

_No response_


Discussion:

Resolving patch:
diff --git a/discord/http.py b/discord/http.py
--- a/discord/http.py
+++ b/discord/http.py
@@ -1666,9 +1666,13 @@ def get_scheduled_event_users(
         params = {
             'limit': int(limit),
             'with_member': int(with_member),
-            'before': int(before),
-            'after': int(after),
         }
+
+        if before is not None:
+            params["before"] = int(before)
+
+        if after is not None:
+            params["after"] = int(after)
         
         return self.request(Route('GET', '/guilds/{guild_id}/scheduled-events/{event_id}/users', guild_id=guild_id, event_id=event_id), params=params)
 
diff --git a/discord/iterators.py b/discord/iterators.py
--- a/discord/iterators.py
+++ b/discord/iterators.py
@@ -68,6 +68,7 @@
     from .guild import Guild
     from .threads import Thread
     from .abc import Snowflake
+    from .scheduled_events import ScheduledEvent
 
 T = TypeVar('T')
 OT = TypeVar('OT')
@@ -754,7 +755,14 @@ def create_thread(self, data: ThreadPayload) -> Thread:
 
 
 class ScheduledEventSubscribersIterator(_AsyncIterator[Union["User", "Member"]]):
-    def __init__(self, event, limit, with_member=False, before=None, after=None):
+    def __init__(
+        self,
+        event: ScheduledEvent,
+        limit: int,
+        with_member: bool = False,
+        before: Union[datetime.datetime, int] = None,
+        after: Union[datetime.datetime, int] = None,
+    ):
         if isinstance(before, datetime.datetime):
             before = Object(id=time_snowflake(before, high=False))
         if isinstance(after, datetime.datetime):
@@ -790,24 +798,30 @@ def _get_retrieve(self):
     def member_from_payload(self, data):
         from .member import Member
 
-        member = data.pop('member', None)
-        member['user'] = data
+        user = data.pop('user')
+
+        member = data.pop('member')
+        member['user'] = user
 
         return Member(data=member, guild=self.event.guild, state=self.event._state)
 
     def user_from_payload(self, data):
         from .user import User
 
-        return User(state=self.event._state, data=data)
+        user = data.pop('user')
+
+        return User(state=self.event._state, data=user)
 
     async def fill_subs(self):
         if self._get_retrieve():
             before = self.before.id if self.before else None
             after = self.after.id if self.after else None
             data = await self.get_subscribers(guild_id=self.event.guild.id, event_id=self.event.id, limit=self.retrieve, with_member=self.with_member, before=before, after=after)
+            if data:
+                self.limit -= self.retrieve
 
             for element in reversed(data):
                 if 'member' in element:
-                    self.subscribers.put(self.member_from_payload(element))
+                    await self.subscribers.put(self.member_from_payload(element))
                 else:
-                    self.subscribers.put(self.user_from_payload(element))
+                    await self.subscribers.put(self.user_from_payload(element))
diff --git a/discord/scheduled_events.py b/discord/scheduled_events.py
--- a/discord/scheduled_events.py
+++ b/discord/scheduled_events.py
@@ -428,7 +428,7 @@ async def cancel(self, *, reason: Optional[str] = None) -> None:
     def subscribers(
         self,
         *,
-        limit: Optional[int] = None,
+        limit: int = 100,
         as_member: bool = False,
         before: Optional[Union[Snowflake, datetime.datetime]] = None,
         after: Optional[Union[Snowflake, datetime.datetime]] = None,


Test patch: