Ask coding questions

← Back to all posts
it keeps on saying theres a synx error can someone help?
Flare02 (4)

if messege.channel.send is were the error is

import discord

client=discord.client

@client.event
async def on_ready() :
print ('we have logged in as {0.user}'.format(client))

@client.event
async def on_message(messege):
if messege.author == client.user:
return

if messege.content.startswith('gay'):
await if messege.channel.send

Answered by Coder100 (16809) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (16809)

1.

You have an extra space here

2.

You forgot to call the function here

3.

Your fixed code:

import discord

client = discord.client()

@client.event 
async def on_ready():
  print ('we have logged in as {0.user}'.format(client))

@client.event
async def on_message(messege):
  if messege.author == client.user: 
    return

  if messege.content.startswith('gay'):
    await messege.channel.send('nou')

client.login('<TOKEN>')

replace <TOKEN> with your actual client token.

Flare02 (4)

@Coder100 now it says Traceback (most recent call last):
File "main.py", line 3, in <module>
client = discord.client()
TypeError: 'module' object is not callable

Coder100 (16809)

you forgot to capitalize it

client = discord.Client()

silly
@Flare02

Coder100 (16809)

btw ur token is wrong it has to be the bot token

@Flare02

also from now on, use the .env file to keep your token secret: https://docs.repl.it/repls/secret-keys

Flare02 (4)

@Coder100
now it says Enable tracemalloc to get the object allocation traceback

Coder100 (16809)

oops, my bad sorry

client.run('... token ...')

@Flare02