Ok, so I'm trying to create Discord Bot and i can't figure out why my commands don't work. The on_message() events work properly if i type shrug the bot sends the emoji but when i try to call the $test command bot doesn't respond literraly no errors and no response on the channel. I've spent like 2 hours reading the documentation and everything is ok, but its not.
Python 3.6.8
discord-py 1.2.2
Please somebody help.
from discord.ext.commands import Bot
TOKEN = 'Here goes my token'
client = discord.Client()
bot = Bot(command_prefix='$') """ Command prefix is marked red in PyCharm"""
@bot.command()
async def test(ctx, arg):
await ctx.send(arg)
"""
After the bot logging on to the server
on_ready event occurs and prints the name of the logged in Bot
"""
@client.event
async def on_ready():
print("We have logged in as: {0.user}".format(client))
"""
When the message is sent event on_message() occurs
"""
@client.event
async def on_message(message):
"""
If the message is from the bot nothing happens.
...
When the user inputs $hello bot sends Hello! message on the channel.
...
For the message = 'shrug' bot sends shrug emoji in ASCII onto the channel.
"""
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send("Hello!")
if message.content.startswith("shrug"):
await message.channel.send('¯\_(ツ)_/¯')
client.run(TOKEN)