我的代码出现一些错误:
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
client = commands.Bot(command_prefix = "!")
@client.event
async def on_ready():
print("Bot is online")
@client.command()
async def raid(ctx):
while True:
await ctx.send("""@Raider come show some support and join the raid!
Meet: (link1)
Target: (link2)
Raid Call: """)
await asyncio.sleep(5)
client.run("token")
运行代码时,我得到:
答案 0 :(得分:1)
看起来像这部分:
async def raid(ctx):
while True:
await ctx.send("""@Raider come show some support and join the raid!
Meet: (link1)
Target: (link2)
Raid Call: """)
await asyncio.sleep(5)
只需正确缩进即可:
async def raid(ctx):
while True:
await ctx.send("""@Raider come show some support and join the raid!
Meet: (link1)
Target: (link2)
Raid Call: """)
await asyncio.sleep(5)
在声明函数def raid(ctx):
之后,需要缩进下面的块。然后,对于条件while True:
它的块也需要缩进。
如果您打算学习Python,我建议您学习这门课程,它是免费且非常有趣的: