From a94ffb6729e3e6d44a312a5c5fab93bc858b9144 Mon Sep 17 00:00:00 2001 From: Paillat Date: Mon, 10 Mar 2025 23:31:49 +0100 Subject: [PATCH] :sparkles: Add not_supported decorator and override latency property in App class (#4) --- src/pycord_rest/app.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pycord_rest/app.py b/src/pycord_rest/app.py index 16dffc2..8fc0ecd 100644 --- a/src/pycord_rest/app.py +++ b/src/pycord_rest/app.py @@ -1,6 +1,7 @@ # Copyright (c) Paillat-dev # SPDX-License-Identifier: MIT +import functools import logging from collections.abc import Callable, Coroutine from functools import cached_property @@ -42,6 +43,15 @@ class InvalidCredentialsError(PycordRestError): pass +def not_supported[T, U](func: Callable[[T], U]) -> Callable[[T], U]: + @functools.wraps(func) + def inner(*args: T, **kwargs: T) -> U: + logger.warning(f"{func.__qualname__} is not supported by REST apps.") + return func(*args, **kwargs) + + return inner + + class App(discord.Bot): def __init__(self, *args: Any, **options: Any) -> None: # pyright: ignore [reportExplicitAny] super().__init__(*args, **options) # pyright: ignore [reportUnknownMemberType] @@ -49,6 +59,12 @@ class App(discord.Bot): self.router: APIRouter = APIRouter() self._public_key: str | None = None + @property + @override + @not_supported + def latency(self) -> float: + return 0.0 + @cached_property def _verify_key(self) -> VerifyKey: if self._public_key is None: