@slash.slash(name='test', ...)
async def test(ctx, txt: str):
await ctx.send(f'1st: {txt}')
await ctx.send(f'2nd: {txt}')
await ctx.send(f'3nd: {txt}')
And the result is that all of the messages are replies to the first message that the bot sent. I don’t want the bot to reply to itself. I want it to just send a normal message. How do I do this?
An interaction (slash-command) will always require a direct response towards the user. If you do not use ctx.send(str)
, the interaction will fail.
You've got 2 options to make it seem, like you are not responding to the slash command
You can post a hidden answer ctx.send('ok', hidden=True)
and then send the intented message into the channel ctx.channel.send(str)
.
This will make the initial 'ok' only visible for the invoking users and all other members of the server will neither see the request, nor the first response.
Your second option is to automatically delete the answer after a very short period (ctx.send('ok', delete_after=1)
), followed by a normal message into the channel ctx.channel.send(str)
.
You might need to defer
your response if you can't respond within 3 seconds of the invocation. Defering an interaction (ctx.defer(hidden=True)
or ctx.defer()
) must be called with the same hidden
attribute as your future ctx.send()
.
If you want to hide your respons ctx.send('ok', hidden=True)
, you need to defer in the same state ctx.defer(hidden=True)
.