'Pycord Delete Slash Message Command Respond
I am making a Discord python bot and I have a Message Slash command implemented with
@bot.message_command(name="TestCmd", guild_ids=[id])
async def hello(ctx):
msg = await ctx.respond("Hello!")
When running the code I am able to "right-click" on a message and I see and can run the "TestCmd" command. When I click it the bot responds with the message "Hello"
I would like the Message slash command to not actually have a response, but since discord requires slash commands to have a response I was hoping to be able to delete it right after responding.
Adding code like this
await msg.delete()
or
await msg.deleteResponse()
does not work. Is there any way to be able to delete the 'ctx.respond()' message?
The only option I have found so far is to use "ctx.respond(..., ephemeral=True)" which will only display the response to the user which triggered the slash command.
Is there anyway to clear the response?
Solution 1:[1]
You can delete the response after a set amount of time. In your case that would be 0 seconds.
Here's the code you need:
await ctx.respond("Hello!", delete_after=0)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
