autorole.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:PTSCogs 作者: PlanetTeamSpeakk 项目源码 文件源码
def fixroles(self, ctx):
        """Adds the role members were supposed to get when they joined but didn't."""
        counter = 0
        role = discord.utils.get(ctx.message.server.roles, id=self.settings[ctx.message.server.id]['role'])
        if role == None:
            await self.bot.say("The role set doesn't exist anymore.")
            return
        status = await self.bot.say("Adding roles...")
        for m in ctx.message.server.members:
            if [r.name for r in m.roles] == ["@everyone"]:
                try:
                    await self.bot.add_roles(m, role)
                    counter += 1
                except discord.Forbidden:
                    await self.bot.say("I am not allowed to add roles.")
                    return
        await self.bot.edit_message(status, "Added the **{}** role to **{}** members.".format(role.name, str(counter)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号