Reputation: 55
I made this small discord bot to show a friend how to do it, exactly how I have done it before. But it doesnt answer my message in discord, and I cant find the error.
import discord
import os
client = discord.Client()
@client.event
async def on_ready():
print('Online as {0.user}'.format(client))
@client.event
async def in_message(message):
if message.author == client.user:
return
if message.content.startswith('Hello'):
await message.channel.send('Hello! {message.author.mention}')
client.run(os.getenv('TOKEN'))
Sorry if its obvious, I just cant see it.
Upvotes: 1
Views: 161
Reputation: 67
instead of using on_message
events u can use
@client.command()
async def hello(ctx):
await ctx.send(f"Hello {ctx.author.mention}")
This is how u create actual Commands in discord.py
Upvotes: 0
Reputation: 2917
on_message
instead of in_message
.'Hello! {message.author.mention}'
like f'Hello! {message.author.mention}'
.Upvotes: 2