Is there any way to make a command both text-based and slash-based in Pycord?
Question:
I’ve made a music bot in Pycord, and I want to make the commands both slash and text-based. I’ve implemented slash commands using discord.Bot
in a cog
and used the slash_command
decorator.
All the code of the music bot can be seen here (the main_slash.py
file contains the cog
)
I have some hint that discord.ext.commands.Bot
can be used, but well, to say the least, I am bewildered and perplexed in this context on using this class in my code.
I have tried these things:-
- Using
discord.ext.commands.Bot
, but this ended up in failure (as mentioned before).
- (current method, but inefficient I guess) Running two instances of the bot parallelly, with one implementing slash commands, while the other implementing text-based commands.
Answers:
I suggest creating a seperate async function and then the slash command an prefixed command call that separate async function.
discord.ext.commands.Bot
supports slash commands and prefix commands please read the docs
Bridges exist on Pycord now and you can just do:
@bot.bridge_command()
async def hello(ctx):
await ctx.respond("Hello!")
and it’ll be both a text-based and slash-based command.
I’ve made a music bot in Pycord, and I want to make the commands both slash and text-based. I’ve implemented slash commands using discord.Bot
in a cog
and used the slash_command
decorator.
All the code of the music bot can be seen here (the main_slash.py
file contains the cog
)
I have some hint that discord.ext.commands.Bot
can be used, but well, to say the least, I am bewildered and perplexed in this context on using this class in my code.
I have tried these things:-
- Using
discord.ext.commands.Bot
, but this ended up in failure (as mentioned before). - (current method, but inefficient I guess) Running two instances of the bot parallelly, with one implementing slash commands, while the other implementing text-based commands.
I suggest creating a seperate async function and then the slash command an prefixed command call that separate async function.
discord.ext.commands.Bot
supports slash commands and prefix commands please read the docs
Bridges exist on Pycord now and you can just do:
@bot.bridge_command()
async def hello(ctx):
await ctx.respond("Hello!")
and it’ll be both a text-based and slash-based command.