Home>

I want to run a DISCORD responsive BOT with a Google colaboratory PYTHON3 file.
You can do it normally on AWS Cloud9, but if you do it with colaboratory as follows
I get a "Runtime Error: Event loop is closed" error and cannot execute successfully.

Contents of code cell 1:
! pip install discord

Contents of code cell 2:
import discord
import asyncio

client = discord.Client ()

@ client.event
async def on_ready ():
print ('Logged in as')
print (client.user.name)
print (client.user.id)
print ('------')

@ client.event
async def on_message (message):
if message.content.startswith ("Hello"):
m = "Hello," + message.author.name + "Mr."
await client.send_message (message.channel, m)

client.run ("Set DISCORD token here")

If i execute cells 1 and 2 in order with the above contents, 2
] (5d52bda2fe28334aaa0f22ef483b2e26.png)

I get the error.

What's missing or wrong to successfully start a BOT?

Postscript:
What I want to do is to return text or images after commenting on DISCORD in colaboratory.
The above logic is just a sample. As long as the error can be resolved, the process I want to implement is already
Since it is completed, it is in a state where the purpose can be achieved.

Trends