Skip to content

Commit c4a8e2f

Browse files
committed
feat: work more on Extension command building.
1 parent 7ffb1ad commit c4a8e2f

File tree

6 files changed

+63
-3
lines changed

6 files changed

+63
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ dist/
1010
.env
1111
.venv
1212
.vscode
13+
__pycache__

.token

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ODgzNzg4ODkzNTEyNjgzNTIw.YTPCjA.HUk8b7AkX-C2t3Hv_gOvktUHUXk

interactions/api/models/misc.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Snowflake(object):
4343
def __str__(self) -> str: ...
4444
def __int__(self) -> int: ...
4545

46-
class Format(object):
46+
class Format:
4747
USER: str
4848
USER_NICK: str
4949
CHANNEL: str

interactions/client.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import sys
22
from asyncio import get_event_loop
3+
4+
# from functools import partial
35
from importlib import import_module
46
from importlib.util import resolve_name
57
from logging import Logger, StreamHandler, basicConfig, getLogger
@@ -604,9 +606,9 @@ async def raw_guild_create(self, guild) -> dict:
604606

605607
# class CoolCode(interactions.Extension):
606608
# def __init__(self, client):
607-
# ...
609+
# self.client = client
608610

609-
# @self.client.command(
611+
# @command(
610612
# type=interactions.ApplicationCommandType.USER,
611613
# name="User command in cog",
612614
# )
@@ -618,6 +620,15 @@ async def raw_guild_create(self, guild) -> dict:
618620
# """
619621

620622
# client: Client
623+
# commands: Optional[List[ApplicationCommand]]
624+
# listeners: Optional[List[Listener]]
621625

622626
# def __new__(cls, bot: Client) -> None:
623627
# cls.client = bot
628+
# cls.commands = []
629+
630+
# for _, content in cls.__dict__.items():
631+
# content = content if isinstance(content.callback, partial) else None
632+
# if isinstance(content, ApplicationCommand):
633+
# cls.commands.append(content)
634+
# bot.command(**content)

simple_bot.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import interactions
2+
3+
bot = interactions.Client(token=open(".token").read())
4+
5+
6+
@bot.event
7+
async def on_ready():
8+
print("bot is now online.")
9+
10+
11+
@bot.command(
12+
name="basic-command",
13+
description="ever wanted a basic command? well, here it is!",
14+
scope=852402668294766612,
15+
options=[
16+
interactions.Option(
17+
type=interactions.OptionType.STRING,
18+
name="option",
19+
description="please PLEASE write in me! UwU :(",
20+
required=True,
21+
)
22+
],
23+
)
24+
async def basic_command(ctx, option):
25+
await ctx.send(f"{option}")
26+
27+
28+
bot.load("simple_cog")
29+
bot.start()

simple_cog.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import interactions
2+
3+
4+
class SimpleCog(interactions.Extension):
5+
def __init__(self, client) -> None:
6+
super().__init__(client)
7+
8+
# @command(
9+
# name="cog-command",
10+
# description="wanna be in a cog? :)) ok.",
11+
# scope=852402668294766612,
12+
# )
13+
# async def cog_command(self, ctx):
14+
# await ctx.send("we're a cog in the machine!")
15+
16+
17+
def startup(client):
18+
SimpleCog(client)

0 commit comments

Comments
 (0)