【发布时间】:2020-01-29 02:58:19
【问题描述】:
我在 Python 中制作了一个不和谐的机器人,当我想运行它时 - 发生了错误 - 需要一个缩进块,我将显示一些代码:
我试图移动一些东西,但没有成功。此外,我对 Python 完全陌生,并且在 YouTube 上的教程中做了一些事情。请帮帮我。
import discord
import random
client = discord.Client()
@client.event
async def on_ready():
await client.change_presence(status=discord.Status.idle, activity=discord.Game('?help'))
print('Bot jest online.')
@client.event
async def on_message(message):
id = client.get_guild(586513031765426198)
if message.content.find("?ping") != -1:
await message.channel.send("Pong! Jestem gotowy do użytku!")
if message.content.find("?plany") != -1:
await message.channel.send("Mam zamiar dodać do bota dużo komend!")
if message.content == "?rzut-monetą":
variable = [
'Orzeł!',
'Reszka!',]
await message.channel.send(random.choice(variable))
if message.content == "?pomoc":
embed = discord.Embed(title="Komendy!", description="Znajdziecie tutaj wszystkie komendy.", colour=discord.Colour.red())
embed.add_field(name="!ping", value="Sprawdza, czy bot jest teraz online.", inline=False)
embed.add_field(name="!info", value="Daje informacje o bocie.", inline=False)
embed.add_field(name="!plany", value="Pokazuje plany na przyszłość dotyczące bota.", inline=False)
embed.add_field(name="!pomoc", value="Pokazuje tą wiadomość.", inline=False)
embed.add_field(name="!rzut-monetą", value="Losuje pomiędzy orłem a reszką. Świetne do rozstrzygania sporów.", inline=False)
await message.channel.send(content=None, embed=embed)
if message.content == "?info":
embed = discord.Embed(title="Informacje!", description="Krótkie info o bocie.", colour=discord.Colour.blue())
embed.add_field(name="Autor", value="Pomi ;3#2203", inline=False)
embed.add_field(name="O bocie", value="Zadanie tego bota to głównie rozrywka, ale ma też wbudowanego auto-moderatora do polskich przekleństw.", inline=False)
await message.channel.send(content=None, embed=embed)
?info 命令下的一行第一个嵌入显示在红色背景上。这意味着什么?
【问题讨论】:
-
Python 中的空格很重要——仔细检查你的缩进。
-
检查
?info的if语句缩进不正确。
标签: python