Ask coding questions

← Back to all posts
Why is this having a syntaxerror?
MrDeer (0)
@client.event
async def on_message(message):
  if message.author == client.user:
    return

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

@client.command(pass_context = True)
async def join(ctx):
    if (ctx.author.voice):
        channel = ctx.message.author.voice.channel
        await channel.connect()
    else:
        await ctx.send('You are not in a voice channel, you must be in a voice channel to run this command!')

@client.command(pass_context = True)
async def leave(ctx):
    if (ctx.voice_client):
        await ctx.guild.voice_client.disconnect()
        await ctx.send('I left the Voice Channel')
    else:
        await ctx.send("I am not in a voice channel")

Its only the async def parts thats having this error.

Answered by QuickV (130) [earned 5 cycles]
View Answer
Comments
hotnewtop
QuickV (130)

Like Coder100 said, line 10 is missing a ) at the end, so just add that on and it should be fine :P

Coder100 (18939)

Look at line 10:

you are missing a ). So change your line 10 to:

print('We have logged in as {0.user}'.format(client))

whenever you are dealing with nested parentheses, replit isn't super good with it and you will have to do it one more than the normal amount.