Skip to content

Commit 0f5fd79

Browse files
committed
✨ Make pycord_rest_bot optional
1 parent 6e3fee6 commit 0f5fd79

File tree

3 files changed

+8
-156
lines changed

3 files changed

+8
-156
lines changed

pdm.lock

Lines changed: 1 addition & 151 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ dependencies = [
2222
"tortoise-orm[asyncpg]>=0.23.0",
2323
"aerich[toml]>=0.8.1",
2424
"py-cord>=2.7.0rc1",
25-
"pycord-rest-bot>=0.1.3",
2625
]
2726
requires-python = "==3.12.*"
2827
readme = "README.md"

src/custom/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
import aiocache
99
import discord
10-
import pycord_rest
10+
try:
11+
from pycord_rest import Bot as PycordRestBot
12+
except ImportError:
13+
class PycordRestBot: ...
14+
1115
import uvicorn
1216
from discord import Interaction, Message, WebhookMessage
1317
from discord.ext import bridge
@@ -192,8 +196,7 @@ def configure_logging(self) -> None:
192196
log.patch("uvicorn.error")
193197
log.patch("uvicorn.access")
194198

195-
196-
class CustomRestBot(pycord_rest.Bot, CustomBot): # pyright: ignore[reportIncompatibleMethodOverride,reportUnsafeMultipleInheritance]
199+
class CustomRestBot(PycordRestBot, CustomBot): # pyright: ignore[reportIncompatibleMethodOverride,reportUnsafeMultipleInheritance]
197200
__rest__: bool = True
198201

199202
_UvicornConfig: type[uvicorn.Config] = CustomUvicornConfig
@@ -202,7 +205,7 @@ def __init__(
202205
self, *args: Any, cache_type: str = "memory", cache_config: RedisConfig | None = None, **options: Any
203206
) -> None:
204207
CustomBot.__init__(self, *args, cache_type=cache_type, cache_config=cache_config, **options)
205-
pycord_rest.Bot.__init__(self, *args, **options)
208+
PycordRestBot.__init__(self, *args, **options)
206209

207210
@self.listen(name="on_connect", once=True)
208211
async def on_connect() -> None:

0 commit comments

Comments
 (0)