mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-22 00:13:01 +00:00
Add application command permissions to audit log
This commit is contained in:
@@ -78,7 +78,7 @@ from .invite import Invite
|
||||
from .widget import Widget
|
||||
from .asset import Asset
|
||||
from .flags import SystemChannelFlags
|
||||
from .integrations import Integration, _integration_factory
|
||||
from .integrations import Integration, PartialIntegration, _integration_factory
|
||||
from .scheduled_event import ScheduledEvent
|
||||
from .stage_instance import StageInstance
|
||||
from .threads import Thread, ThreadMember
|
||||
@@ -3346,11 +3346,11 @@ class Guild(Hashable):
|
||||
|
||||
if data and entries:
|
||||
if limit is not None:
|
||||
limit -= len(data)
|
||||
limit -= len(entries)
|
||||
|
||||
before = Object(id=int(entries[-1]['id']))
|
||||
|
||||
return data.get('users', []), entries, before, limit
|
||||
return data, entries, after, limit
|
||||
|
||||
async def _after_strategy(retrieve, after, limit):
|
||||
after_id = after.id if after else None
|
||||
@@ -3362,11 +3362,11 @@ class Guild(Hashable):
|
||||
|
||||
if data and entries:
|
||||
if limit is not None:
|
||||
limit -= len(data)
|
||||
limit -= len(entries)
|
||||
|
||||
after = Object(id=int(entries[0]['id']))
|
||||
|
||||
return data.get('users', []), entries, after, limit
|
||||
return data, entries, after, limit
|
||||
|
||||
if user is not MISSING:
|
||||
user_id = user.id
|
||||
@@ -3397,31 +3397,46 @@ class Guild(Hashable):
|
||||
if after and after != OLDEST_OBJECT:
|
||||
predicate = lambda m: int(m['id']) > after.id
|
||||
|
||||
# avoid circular import
|
||||
from .app_commands import AppCommand
|
||||
|
||||
while True:
|
||||
retrieve = min(100 if limit is None else limit, 100)
|
||||
if retrieve < 1:
|
||||
return
|
||||
|
||||
raw_users, data, state, limit = await strategy(retrieve, state, limit)
|
||||
data, raw_entries, state, limit = await strategy(retrieve, state, limit)
|
||||
|
||||
# Terminate loop on next iteration; there's no data left after this
|
||||
if len(data) < 100:
|
||||
if len(raw_entries) < 100:
|
||||
limit = 0
|
||||
|
||||
if reverse:
|
||||
data = reversed(data)
|
||||
raw_entries = reversed(raw_entries)
|
||||
if predicate:
|
||||
data = filter(predicate, data)
|
||||
raw_entries = filter(predicate, raw_entries)
|
||||
|
||||
users = (User(data=raw_user, state=self._state) for raw_user in raw_users)
|
||||
users = (User(data=raw_user, state=self._state) for raw_user in data.get('users', []))
|
||||
user_map = {user.id: user for user in users}
|
||||
|
||||
for raw_entry in data:
|
||||
integrations = (PartialIntegration(data=raw_i, guild=self) for raw_i in data.get('integrations', []))
|
||||
integration_map = {integration.id: integration for integration in integrations}
|
||||
|
||||
app_commands = (AppCommand(data=raw_cmd, state=self._state) for raw_cmd in data.get('application_commands', []))
|
||||
app_command_map = {app_command.id: app_command for app_command in app_commands}
|
||||
|
||||
for raw_entry in raw_entries:
|
||||
# Weird Discord quirk
|
||||
if raw_entry['action_type'] is None:
|
||||
continue
|
||||
|
||||
yield AuditLogEntry(data=raw_entry, users=user_map, guild=self)
|
||||
yield AuditLogEntry(
|
||||
data=raw_entry,
|
||||
users=user_map,
|
||||
integrations=integration_map,
|
||||
app_commands=app_command_map,
|
||||
guild=self,
|
||||
)
|
||||
|
||||
async def widget(self) -> Widget:
|
||||
"""|coro|
|
||||
|
Reference in New Issue
Block a user