33 lines
945 B
Python
33 lines
945 B
Python
from enum import Enum
|
|
|
|
|
|
class ApiVersion(Enum):
|
|
V10 = 10
|
|
V9 = 9
|
|
V8 = 8
|
|
V7 = 7
|
|
V6 = 6
|
|
|
|
|
|
class ApiAction(Enum):
|
|
DELETE = 'DELETE'
|
|
GET = 'GET'
|
|
POST = 'POST'
|
|
|
|
|
|
class Api:
|
|
class Guild:
|
|
@staticmethod
|
|
def list_guilds(guild_id: int) -> tuple[ApiAction, str]:
|
|
return ApiAction.GET, f'/guilds/{guild_id}/channels'
|
|
|
|
class Message:
|
|
@staticmethod
|
|
def delete(channel_id: int, message_id: int) -> tuple[ApiAction, str]:
|
|
return ApiAction.DELETE, f'/channels/{channel_id}/messages/{message_id}'
|
|
|
|
@staticmethod
|
|
def list_by_channel(channel_id: int, limit: int | None = None) -> tuple[ApiAction, str]:
|
|
if limit is not None and not (0 < limit <= 100): # noqa: PLR2004
|
|
raise RuntimeError('Cannot list messages by channel with limit outside [0, 100] range')
|
|
return ApiAction.GET, f'/channels/{channel_id}/messages'
|