-1

so i currently have this code, which makes an 8ball for my discord bot, and i'm having this error where it says "Indented error : expected and indented block"

Here is the code i'm using (see https://hastebin.com/isageyoqih.py)

import discord
import asyncio
import random
import pickle
import os

client = discord.Client()

@client.event
async def on_ready():
    print('Ready and with')
    print(client.user.name)

@client.event
async def on_message(message):
    if message.content.startswith('_whatcanyoudo?'):
        msg = await client.send_message(message.channel, '```Heres what i can do :```')
        await asyncio.sleep(0.5)
        msg2 = await client.send_message(message.channel, '```For now, i can only do a thing called "flip a coin"```')
        await asyncio.sleep(0.5)
        msg3 = await client.send_message(message.channel, '```Bot powered by Ouindoze™, message will delete in 15 seconds```')
        await asyncio.sleep(15)
        await client.delete_message(msg)
        await client.delete_message(msg2)
        await client.delete_message(msg3)


    elif message.content.startswith('_8ball'):
    8ball = random.choice(['It is certain','As i see it, yes', 'Dont count on it', 'Without a doubt', 'Definitely', 'Very doubtful', 'Outlook not so good', 'My sources say no', 'My reply is no', 'Most likely', 'You may rely on it', 'Ask again later'])
    msg5 = await client.send_message(message.channel, 8ball)

client.run('I obiously won't share the token duh xd')

Here is the error I got.

MarianD
  • 13,096
  • 12
  • 42
  • 54
ouindoze
  • 1
  • 5

2 Answers2

0
elif message.content.startswith('_8ball'):
8ball = random.choice(['It is certain','As i see it, yes', 'Dont count on it', 'Without a doubt', 'Definitely', 'Very doubtful', 'Outlook not so good', 'My sources say no', 'My reply is no', 'Most likely', 'You may rely on it', 'Ask again later'])
msg5 = await client.send_message(message.channel, 8ball)

should be (note indentation after elif)

elif message.content.startswith('_8ball'):
    8ball = random.choice(['It is certain','As i see it, yes', 'Dont count on it', 'Without a doubt', 'Definitely', 'Very doubtful', 'Outlook not so good', 'My sources say no', 'My reply is no', 'Most likely', 'You may rely on it', 'Ask again later'])
    msg5 = await client.send_message(message.channel, 8ball)

and, by the way, 8ball is illegal name for a variable as the variable name have to start with a letter or an underline symbol (_).

Note: Long lists may be split in multiple lines for better readability:

    ball = random.choice([
        'It is certain',
        'As i see it, yes', 
        'Dont count on it', 
        'Without a doubt', 
        'Definitely', 
        'Very doubtful', 
        'Outlook not so good', 
        'My sources say no', 
        'My reply is no', 
        'Most likely', 
        'You may rely on it', 
        'Ask again later'
        ])
MarianD
  • 13,096
  • 12
  • 42
  • 54
  • Questions like this should’ve been commented and voted to close as a simple typographical error. As this question will not be any help for future readers other than the OP – Taku Oct 09 '17 at 16:57
  • Thanks a lot, i've been on this for 2 hours xD – ouindoze Oct 09 '17 at 17:01
0
elif message.content.startswith('_8ball'):
    8ball = random.choice(['It is certain','As i see it, yes', 'Dont count on it', 'Without a doubt', 'Definitely', 'Very doubtful', 'Outlook not so good', 'My sources say no', 'My reply is no', 'Most likely', 'You may rely on it', 'Ask again later'])
    msg5 = await client.send_message(message.channel, 8ball)

Well it's exactly what the error message says: Indent it.

LW001
  • 2,452
  • 6
  • 27
  • 36