Python 3.x 不协调变化区
很抱歉,如果这是一个如此愚蠢的问题,我想知道这个命令有什么问题,因为我得到了Python 3.x 不协调变化区,python-3.x,discord,discord.py,Python 3.x,Discord,Discord.py,很抱歉,如果这是一个如此愚蠢的问题,我想知道这个命令有什么问题,因为我得到了discord.ext.commands.errors.BadArgument:转换为“EnumMeta”失败。是一个错误。错误的确切含义是什么?正确的命令是什么 @commands.command(pass_context = True) @commands.has_permissions(manage_server=True) async def region(self, ctx, region=discord.Se
discord.ext.commands.errors.BadArgument:转换为“EnumMeta”失败。
是一个错误。错误的确切含义是什么?正确的命令是什么
@commands.command(pass_context = True)
@commands.has_permissions(manage_server=True)
async def region(self, ctx, region=discord.ServerRegion):
"""Changes the server region."""
if not region:
await self.bot.say("What region are we changing to, {ctx.message.author.mention}?")
await self.bot.edit_server(region)
await self.bot.say("Ok! We're now in " + str(ctx.message.server.region) + " :smiley:")
print('ok')
ServerRegion
没有内置转换器。幸运的是,通过使用ServerRegion('amsterdam')
相当于ServerRegion这一事实,我们可以很容易地完成这项工作。amsterdam
:
region_converter = lambda region: discord.ServerRegion('-'.join(region.lower().split()))
@commands.command(pass_context = True)
@commands.has_permissions(manage_server=True)
async def region(self, ctx, *, region: region_converter=None):
"""Changes the server region."""
if not region:
await self.bot.say("What region are we changing to, {ctx.message.author.mention}?")
return
await self.bot.edit_server(ctx.message.server, region=region)
await self.bot.say("Ok! We're now in " + str(ctx.message.server.region) + " :smiley:")
print('ok')
谢谢你的回答
discord.ext.commands.errors.CommandInvokeError:Command引发异常:AttributeError:“ServerRegion”对象没有属性“icon”
显示,但是:(@DanielCasares尝试将edit_server
行更改为wait self.bot.edit_服务器(ctx.message.server,region=region)
。您还应该在if
中添加一个return
,这样,如果未设置区域
,您就不会尝试编辑服务器。discord.ext.commands.errors.CommandInvokeError:Command引发异常:AttributeError:module'discord.server'没有属性'region'
我做错了什么吗?@DanielCasares It's w为我工作。错误在哪一行?等待self.bot。说(“好的!我们现在在”+server.region+”:smiley:“)AttributeError:module'discord.server'没有属性'region'
这是一个错误,但是你的代码工作得很好,非常感谢!我已经为此发疯了