-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Followup messages after delay #32
Comments
You're on the right track. There is an helper method available with the async def pong(ctx: IncomingDiscordInteraction):
followup_message = FollowUpMessages(bot, interaction=ctx)
await asyncio.sleep(2)
response_followup = DiscordResponse(content="pong")
await follow_up_message.async_create_follow_up_message(response_followup)
@bot.interaction.on("ping")
async def ping(ctx: IncomingDiscordInteraction) -> DiscordResponse:
response = DiscordResponse(content="pong")
# background
bot.background(pong, ctx)
return response I wouldn't use I should write some documentation about this.. |
|
Ah, I see what you mean. I'll push an update to fix this behavior for |
Just pushed version 0.9.0a.. Testing with this example async def later_pong(time_recieved, interaction: IncomingDiscordInteraction):
now_time = datetime.datetime.now()
time_diff = (now_time - time_recieved).total_seconds() * 1000
_followup_object = FollowUpMessages(bot, interaction=interaction)
await asyncio.sleep(10)
pong_message = DiscordResponse(show_user_input=False)
pong_message.content = f"Pong: {time_diff}ms"
await _followup_object.async_create_follow_up_message(pong_message)
@bot.interaction.on("ping")
async def ping(ctx: IncomingDiscordInteraction) -> DiscordResponse:
await bot.background(later_pong, datetime.datetime.now(), ctx)
logger.info("sending response ?")
return DiscordResponse(
content="Ping: ..."
) Let me know if you works out for you |
There we go! Thank you! |
No problem! There isn't a discord server yet. That sounds like a good idea for the future :) |
What The command I want to add to my bot goes somewhat like this:
Of course there will be a delay between steps 3 and 5, until step 4 is done. If I use followup messages it just waits until step 4 is done and then sends all messages at the same time.
Here is a sample code where I use
time.sleep
for testing:I'm pretty sure I am doing something wrong.I am very unfamiliar with asyncio and event loops. Any help with that?
The text was updated successfully, but these errors were encountered: