0
votes

Ok so i was building a discord bot using python on repl.it the thing is that my bot even shows that it's online but whenever i type $hello it just throws the big fat error on my face This is the photo of my code and the error

import os
import discord
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('TOKEN')

client = discord.Client()

@client.event
async def on_ready():
    print(f'{client.user} has connected to Discord!')

@client.event
async def on_message(message):

  if message.author == client.user:
    return

  if message.content.startswith('$hello'):
    await message.send.channel('Hello there young shona follower!')

client.run(TOKEN)

And this is the error

Ignoring exception in on_message Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs) File "main.py", line 21, in on_message await message.send.channel('Hello there young shona follower!') AttributeError: 'Message' object has no attribute 'send'

2

2 Answers

1
votes

It's message.channel.send, not message.send.channel:

await message.channel.send('Hello there young shona follower!')
0
votes

The error is self explanatory. You cannot call send method on message object in on_message function.