【发布时间】:2018-06-04 20:24:14
【问题描述】:
我刚接触 Python 和通用编程,我已经开始编写自己的机器人,但现在我在使用机器人命令更改权限时遇到问题,更准确地说,我想更改权限超过一个角色,这是我知道的,我知道这很混乱,我非常感谢一些帮助!
@bot.command(pass_context=True)
@commands.has_role("botadmin")
async def giveperm(ctx, *rankName: str):
rank = discord.utils.get(ctx.message.server.roles, name=' '.join(rankName))
await bot.say("Give me a moment! Giving permissions to post in " + str(ctx.message.channel))
perms = discord.PermissionOverwrite(send_messages=True)
for rankName in str(rank):
await bot.edit_channel_permissions(channel=ctx.message.channel, target=rankName, overwrite=perms)
if ctx.message.channel == "suggestions":
await bot.say("Suggestions are now open again for a week! \n\n Please only post suggestions here to prevent any chaos, with that said, have fun and happy suggesting!")
else:
await bot.say("Permissions granted to " + rankName + " to post in " + str(ctx.message.channel))
提前致谢!
【问题讨论】:
标签: python-3.x discord.py