mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-12 16:59:50 +00:00
Add Client.persistent_views to get all persistent views
This commit is contained in:
parent
7c40e83d10
commit
78275023cc
@ -29,7 +29,7 @@ import logging
|
|||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Any, Generator, List, Optional, TYPE_CHECKING, TypeVar, Union
|
from typing import Any, Generator, List, Optional, Sequence, TYPE_CHECKING, TypeVar, Union
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
@ -1463,3 +1463,8 @@ class Client:
|
|||||||
raise ValueError('View is not persistent. Items need to have a custom_id set and View must have no timeout')
|
raise ValueError('View is not persistent. Items need to have a custom_id set and View must have no timeout')
|
||||||
|
|
||||||
self._connection.store_view(view, message_id)
|
self._connection.store_view(view, message_id)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def persistent_views(self) -> Sequence[View]:
|
||||||
|
"""Sequence[:class:`View`]: A sequence of persistent views added to the client."""
|
||||||
|
return self._connection.persistent_views
|
||||||
|
@ -287,6 +287,10 @@ class ConnectionState:
|
|||||||
def prevent_view_updates_for(self, message_id):
|
def prevent_view_updates_for(self, message_id):
|
||||||
return self._view_store.remove_message_tracking(message_id)
|
return self._view_store.remove_message_tracking(message_id)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def persistent_views(self):
|
||||||
|
return self._view_store.persistent_views
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def guilds(self):
|
def guilds(self):
|
||||||
return list(self._guilds.values())
|
return list(self._guilds.values())
|
||||||
|
@ -23,7 +23,7 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from typing import Any, Callable, ClassVar, Dict, Iterator, List, Optional, TYPE_CHECKING, Tuple
|
from typing import Any, Callable, ClassVar, Dict, Iterator, List, Optional, Sequence, TYPE_CHECKING, Tuple
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
|
|
||||||
@ -370,6 +370,15 @@ class ViewStore:
|
|||||||
self._synced_message_views: Dict[int, View] = {}
|
self._synced_message_views: Dict[int, View] = {}
|
||||||
self._state: ConnectionState = state
|
self._state: ConnectionState = state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def persistent_views(self) -> Sequence[View]:
|
||||||
|
views = {
|
||||||
|
view.id: view
|
||||||
|
for (_, (view, _, _)) in self._views.items()
|
||||||
|
if view.is_persistent()
|
||||||
|
}
|
||||||
|
return list(views.values())
|
||||||
|
|
||||||
def __verify_integrity(self):
|
def __verify_integrity(self):
|
||||||
to_remove: List[Tuple[int, str]] = []
|
to_remove: List[Tuple[int, str]] = []
|
||||||
now = time.monotonic()
|
now = time.monotonic()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user