diff options
| author | Nakidai <nakidai@disroot.org> | 2024-09-14 14:25:55 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2024-09-14 14:25:55 +0300 |
| commit | 3c241c7c97f2cc49eeecf7de74d5f8f7f794c73b (patch) | |
| tree | 0c7bb3a6d2bc713cf846c42de146f9c10d88227e | |
| parent | 252d5d634f141926f6f1553476594a832ee0009e (diff) | |
| download | petthecord-3c241c7c97f2cc49eeecf7de74d5f8f7f794c73b.tar.gz petthecord-3c241c7c97f2cc49eeecf7de74d5f8f7f794c73b.zip | |
Add discord command v1.2.0
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | src/petthecord/bot.py | 29 |
2 files changed, 31 insertions, 1 deletions
diff --git a/README.md b/README.md index 0fb7048..dd72cda 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +# FOR PEOPLE WHO JUST WANNA USE IT +Click [there](https://discord.com/oauth2/authorize?client_id=1280933495845290005) and use the `/petpet` command + PetTheCord -- This is a Web API for petting any user you know which has avatar diff --git a/src/petthecord/bot.py b/src/petthecord/bot.py index de1277b..0725943 100644 --- a/src/petthecord/bot.py +++ b/src/petthecord/bot.py @@ -1,10 +1,34 @@ from aiohttp.web import AppRunner, TCPSite -from discord import Intents +from discord import app_commands, Interaction, Intents, User from discord.ext import commands from .server import Server +class PatTheCordCog(commands.Cog): + def __init__(self, client: commands.Bot) -> None: + self.client = client + + @app_commands.allowed_installs(users=True) + @app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True) + @app_commands.command( + name="petpet", + description="Pat some user" + ) + @app_commands.describe( + user="User to pet", + r="Some random stuff, set it if avatar is not up to date" + ) + async def petthecord( + self, + interaction: Interaction, + + user: User, + r: str = "" + ) -> None: + await interaction.response.send_message(f"https://ptc.nakidai.ru/{user.id}.{r}.gif") + + class Bot(commands.Bot): def __init__(self, host: str = "127.0.0.1", port: int = 8080) -> None: super().__init__( @@ -15,6 +39,9 @@ class Bot(commands.Bot): self._port = port async def on_ready(self) -> None: + await self.add_cog(PatTheCordCog(self)) + await self.tree.sync() + runner = AppRunner(Server(self)) await runner.setup() site = TCPSite(runner, self._host, self._port) |