Comments (6)
No problem!
There isn't a discord server yet. That sounds like a good idea for the future :)
from dispike.
You're on the right track.
There is an helper method available with the Dispike
object called .background
. Based on your steps, you could probably have something like this.
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 time
for anything in an async function, but if you could probably use it if you replace async_create_follow_up_message
with sync_create_follow_up_message
.
I should write some documentation about this..
from dispike.
bot.background
still requires to be awaited, and if I await it I just get the same result.
from dispike.
Ah, I see what you mean. I'll push an update to fix this behavior for .background
..
from dispike.
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
from dispike.
There we go! Thank you!
Is there any discord server where I can join and get involved with this project? I see a lot of potential here.
from dispike.
Related Issues (20)
- DiscordResponse does not validate or throw error upon insufficient response HOT 1
- Responding to Interactions does not require a Bot Token HOT 1
- Reorganizing Modules/Imports
- Support default_permission for DiscordCommand HOT 3
- Rate Limiting
- Support for Resolved Application Incoming Interaction Data
- Possible Error in Event Callback Name Generation for Subcommands HOT 1
- Add add_new_action_row method to DiscordResponse HOT 1
- Callback Event Detection Fails for Subcommands Containing Hyphen HOT 1
- Support for Application Commands HOT 4
- Make bot appear online HOT 2
- Add users to roles using slash commands HOT 2
- Is 3.6+ really a caveat? HOT 2
- Django support HOT 3
- Support for Ephemeral Attachments
- Support for Slash Command Option Channel Type Restrictions
- DiscordResponse with Embed and ActionRow is invalid
- Validation error in SubcommandIncomingDiscordOptionList
- Minimum and Maximum Values for Slash Command Options
- Validation error in IncomingDiscordSlashInteraction
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dispike.