Reputation: 181
I have a program that looks like this:
import things
import discord
def on_thing_happen (variable):
get_info()
do thing()
# This is where I want to send a message in Discord
For reasons, the rest of my code cannot work in an async function.
Is there any way to do this? I cannot use an async def.
Upvotes: 1
Views: 3706
Reputation: 51
Try this:
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'))
So instead of await channel.send('message')
it is client.loop.create_task(channel.send('message')
I hope this works!
Upvotes: 8