mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 20:47:44 +00:00
29 lines
702 B
Python
29 lines
702 B
Python
import typing
|
|
from dataclasses import dataclass
|
|
|
|
if typing.TYPE_CHECKING:
|
|
from aioredis import Redis
|
|
from bot import TuneBot
|
|
from discord import Interaction
|
|
from context import CustomContext
|
|
|
|
|
|
@dataclass
|
|
class ContextLike:
|
|
redis: "Redis"
|
|
bot: "TuneBot"
|
|
guild_id: int
|
|
|
|
@staticmethod
|
|
def from_discord_context(ctx: "CustomContext") -> "ContextLike":
|
|
return ContextLike(redis=ctx.redis, bot=ctx.bot, guild_id=ctx.guild.id)
|
|
|
|
@staticmethod
|
|
def from_discord_interaction(ctx: "Interaction") -> "ContextLike":
|
|
return ContextLike(
|
|
redis=ctx.client._redis_client, bot=ctx.client, guild_id=ctx.guild_id
|
|
)
|
|
|
|
|
|
__all__ = ("ContextLike",)
|