Issue
I am using discordpy to write a discord bot. When calling an external function from an async function, I am receiving an error telling me I am missing a parameter ‘ctx’ from my function. I believe I have to use the ‘await’ method, however, I am unsure where.
def fromRebootMethod():
return "Hello"
@client.command()
async def fromReboot(ctx):
message = await fromRebootMethod()
print(message)
await ctx.send(message)
This is the error I am receiving:
TypeError: fromReboot() missing 1 required positional argument: ‘ctx’
Solution
I don’t think the provided code sample is completely accurate. Therefore, I am recommending two steps to potentially resolve your issue:
- Only use
await
when calling a function that is defined with theasync
keyword in the function definition. - Take another look at the
fromRebootMethod
‘s function definition. It most likely requires actx
parameter which is why your interpreter is asking for it.
Regardless, we need to see the traceback and real code sample.
Answered By – Joshua Taylor Eppinette
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0