Home > Blockchain >  How can I call an async function inside a command in discord python?
How can I call an async function inside a command in discord python?

Time:04-12

For example:

@client.command()
async def hello(ctx):
   await ctx.send('hello')
   facts()

async def facts(ctx):
   await ctx.send('facts')

I tried this but it usually gives an error like - RunTimeWarning: 'coroutine _____ was never awaited'

CodePudding user response:

The answer to this question is to add an await. before your async function.

@client.command()
async def hello(ctx):
   await ctx.send('hello')
   await facts(ctx)

async def facts(ctx):
   await ctx.send('facts')

And there you'd be able to call your async function.

  • Related