【发布时间】:2021-05-02 08:53:01
【问题描述】:
我想做一个 CopyChannel(Permissions) 命令,但我的代码有问题:
@bot.command()
async def copych(ctx, *, channame, id: int = None):
await ctx.message.delete()
if id == None:
chan = ctx.channel
else:
chan = bot.get_channel(id=id)
chan_perm = chan.overwrites
await ctx.guild.create_text_channel(name=channame, overwrites=chan_perm)
没有错误,正在创建频道,但不会覆盖权限。
我也在这里尝试过,但同样的事情:
@bot.command()
async def copych(ctx, *, channame, id: int = None):
await ctx.message.delete()
if id == None:
chan = ctx.channel
else:
chan = bot.get_channel(id=id)
chan_perm = chan.overwrites
f = await ctx.guild.create_text_channel(name=channame)
await f.edit(overwrites=chan_perm)
谁能告诉我代码中的问题出在哪里。
提前致谢
【问题讨论】:
-
使用
*与您使用seen in the docs 的方式不同。您可能想要这样做:(ctx, id:int=None, *, channame) -
啊,是的,这不是我在我的机器人中的代码。我只是写了它,并没有提到。
标签: python discord.py discord.py-rewrite