'(Discord.py) My 8 Ball Command is having a small error here. It says that the thing that picks the responses to give is a error on startup?
@commands.command(name='8ball', description='Let the 8 Ball Predict!\n')
async def _8ball(self, ctx, question):
responses = ['As I see it, yes.',
'Yes.',
'Positive',
'From my point of view, yes',
'Convinced.',
'Most Likley.',
'Chances High',
'No.',
'Negative.',
'Not Convinced.',
'Perhaps.',
'Not Sure',
'Mayby',
'I cannot predict now.',
'Im to lazy to predict.',
'I am tired. *proceeds with sleeping*']
response = random.choice(responses)
embed=discord.Embed(title="The Magic 8 Ball has Spoken!")
embed.add_field(name='Question: ', value=f'{question}', inline=True)
embed.add_field(name='Answer: ', value=f'{response}', inline=False)
await ctx.send(embed=embed)
This is my code, it says for some reason that "response = random.choice(responses)" is having a problem. This occurs on start up.
"IndentationError: unexpected indent"
Solution 1:[1]
I see it needs to indented properly like below. Try this, if not then post your full code we can see whats happening.
@commands.command(name='8ball', description='Let the 8 Ball Predict!\n')
async def _8ball(self, ctx, question):
responses = ['As I see it, yes.',
'Yes.',
'Positive',
'From my point of view, yes',
'Convinced.',
'Most Likley.',
'Chances High',
'No.',
'Negative.',
'Not Convinced.',
'Perhaps.',
'Not Sure',
'Mayby',
'I cannot predict now.',
'Im to lazy to predict.',
'I am tired. *proceeds with sleeping*']
response = random.choice(responses)
embed=discord.Embed(title="The Magic 8 Ball has Spoken!")
embed.add_field(name='Question: ', value=f'{question}', inline=True)
embed.add_field(name='Answer: ', value=f'{response}', inline=False)
await ctx.send(embed=embed)
Solution 2:[2]
Solution 3:[3]
@commands.command(name='8ball', description='Let the 8 Ball Predict!\n')
async def _8ball(self, ctx, question):
responses = ['As I see it, yes.',
'Yes.',
'Positive',
'From my point of view, yes',
'Convinced.',
'Most Likley.',
'Chances High',
'No.',
'Negative.',
'Not Convinced.',
'Perhaps.',
'Not Sure',
'Mayby',
'I cannot predict now.',
'Im to lazy to predict.',
'I am tired. *proceeds with sleeping*']
response = random.choice(responses)
embed=discord.Embed(title="The Magic 8 Ball has Spoken!")
embed.add_field(name='Question: ', value=f'{question}', inline=True)
embed.add_field(name='Answer: ', value=f'{response}', inline=False)
await ctx.send(embed=embed)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | |
Solution 3 | Emi OB |