【发布时间】:2021-06-26 11:07:06
【问题描述】:
当我尝试运行命令时,我总是收到以下错误消息: SyntaxError: 'await' outside function 可能是非常简单的错误,但我真的没有看到其中的错误。有人可以帮忙吗?
import discord
from discord.ext import commands
class unban(commands.Cog):
def __init__(self, client):
self.client = client
# Commandok
@commands.command()
async def unban(ctx, *, member): # unindent
banned_users = await ctx.guild.bans() # unindent
member_name, member_discriminator = member.split('#') # unindent
for ban_entry in banned_users:
user = ban_entry.user
if (user.name, user.discriminator) == (member_name, member_discriminator):
await ctx.guild.unban(user)
await ctx.send(f'Unbanned {user.mention}')
return
def setup(client):
client.add_cog(unban(client))
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.unban' 引发错误:TypeError: cogs must derived from Cog sys:1: RuntimeWarning: coroutine 'Command.call' was万万没想到
【问题讨论】:
标签: python if-statement discord discord.py