I am trying to program a Discord bot in Python using the discord.py
module.
When I run the code, it doesn't say anything, waits a little (probably importing/connecting stuff) and then closes - or in IDLE, >>
appears.
There is no problem with the code, as it doesn't give any errors. Plus, if I run a command out of on_ready()
it works as expected.
So the problem isn't because of not being able to connect to the bot or Discord, is it? Perhaps the asnyc
function doesn't work, or the interpreter doesn't recognize it?
Here is the basic form of the main code:
import discord
token = 'blahblah'
client = discord.Client()
@client.event
async def on_message(message):
if message.content=="some input":
msg = 'some output'
await message.channel.send(msg)
@client.event
async def on_ready():
print("All works fine!")
client.run(token)