我有一个看起来像这样的程序:
import things
import discord
def on_thing_happen (variable):
    get_info()
    do thing()
    # This is where I want to send a message in Discord由于某些原因,我的其余代码不能在异步函数中工作。
有没有办法做到这一点?我不能使用异步定义。
发布于 2020-10-20 00:21:17
试试这个:
import things
import discord
client = discord.Client()
def on_thing_happen (variable):
    get_info()
    do thing()
    channel = client.get_channel(CHANNEL ID) #replace with channel id of text channel in discord
    client.loop.create_task(channel.send('Message'))所以它不是await channel.send('message'),而是client.loop.create_task(channel.send('message')
我希望这能起作用!
https://stackoverflow.com/questions/64199358
复制相似问题