Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

import asyncio
import inspect
from typing import Callable

from .client import *
from .client import Client


class ApplicationCommand:
Expand All @@ -52,11 +53,7 @@ def __init__(self, func, *args, **kwargs):
self.callback = func

def to_dict(self):
_data = {
"name": self.name,
"description": self.description
}
return _data
return {"name": self.name, "description": self.description}


class ApplicationMixin:
Expand All @@ -69,16 +66,25 @@ def add_application_command(self, command):
async def register_application_commands(self):
if len(self.application_commands) == 0:
return
dbg = await self.http.bulk_upsert_global_commands(self.user.id, [i.to_dict for i in self.application_commands])
print(dbg)
await self.http.bulk_upsert_global_commands(
self.user.id, [i.to_dict() for i in self.application_commands]
)


class BotBase(ApplicationMixin):
pass


class Bot(BotBase, Client):
pass
def interaction_command(self, **kwargs):
def wrap(func: Callable) -> ApplicationCommand:
command = ApplicationCommand(func, **kwargs)
self.add_application_command(command)
return command

return wrap

command = slash = interaction_command


class AutoShardedBot(BotBase, Client):
Expand Down