MCausc78 / pyvolt

An API wrapper for Revolt written in Python.
MIT License
4 stars 1 forks source link

Commands extension #2

Open MCausc78 opened 4 months ago

MCausc78 commented 4 months ago

Copy it from discord.py and re-add self_bot and user_bot parameters

NotAussie commented 3 weeks ago

Hai, what's the progress on getting commands working? I'm hoping to use this package in an up-coming project, so I wanted to see if you need any help getting commands finished!

MCausc78 commented 3 weeks ago

Hai, what's the progress on getting commands working? I'm hoping to use this package in an up-coming project, so I wanted to see if you need any help getting commands finished!

The main problem is self binding, which is somehow complex thing to properly implement due to CPython not providing any information (except name, docs and signature) if function is declared in class.

Right now I have very bare commands prototype in my bot but it doesn't parse signature and just gives Context with ctx.args, ctx.prefix, and ctx.subcommand.

NotAussie commented 3 weeks ago

Ah alright, good luck with getting it working, keep me posted!

MCausc78 commented 1 week ago

Current bot example:

import pyvolt
from pyvolt.ext import commands

bot = commands.Bot(
  '!',
  bot=False,
  self_bot=True,
  token='your token lol',
)

@bot.command()
async def ping(ctx: commands.Context[commands.Bot]):
  await ctx.send('pong!')

@bot.command()
@commands.user_command
async def gping(ctx: commands.Context[commands.Bot]):
  await ctx.send('pong! [global command]')

bot.run()

The commands.user_command would bypass self_bot check (allow everyone to invoke this command, including the logged in user).