xuathegrate / slash_util Goto Github PK
View Code? Open in Web Editor NEWA simple script to add application command support to discord.py v2.0
License: MIT License
A simple script to add application command support to discord.py v2.0
License: MIT License
Hi! I'm trying to migrate from discord.py 2.0 to slash_util, but in my class which I use to add an attribute to my context (and it works on 2.0) is raising a TypeError: __init__() got an unexpected keyword argument 'prefix'
This is my current code. The only things I've changed were commands.Bot
to slash_util.Bot
and commands.Context
to slash_util.Context
.
class Noether(slash_util.Bot):
async def get_context(self, message, *, cls=slash_util.Context):
ctx = await super().get_context(message, cls=cls)
# ... more code
And this is the full traceback:
Ignoring exception in on_message
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "bot.py", line 404, in on_message
await bot.process_commands(message)
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 1030, in process_commands
ctx = await self.get_context(message)
File "bot.py", line 54, in get_context
ctx = await super().get_context(message, cls=cls)
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 935, in get_context
ctx = cls(prefix=None, view=view, bot=self, message=message)
TypeError: __init__() got an unexpected keyword argument 'prefix'
I also tried and saw that changing slash_util.Context
back to commands.Context
makes it work, but that would be pointless since I could not use most of the features of the library.
Maybe publish to pypi so users can install straight from pip instead of copy from github?
bot events don't work anymore:
@bot.event def on_ready(): # something
returns error: TypeError: event() missing 1 required positional argument: 'coro'
And bot is my slash_util init cog
Will be accomplished as the following:
@slash_util.slash_command()
async def slash(self, ctx, file: discord.Attachment):
# basically equivalent to checking the message attachments i guess?
This will have to involve either overriding discord.Interaction.send
, or making slash_util.Context
stateful.
Edit: #14 has added support for checks. cooldowns still required.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.