python类is_owner()的实例源码

blacklists.py 文件源码 项目:Chiaki-Nanami 作者: Ikusaba-san 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def blacklist(self, ctx, server_or_user: _GuildOrUser, *, reason=''):
        """Blacklists either a server or a user, from using the bot."""

        if await ctx.bot.is_owner(server_or_user):
            return await ctx.send("You can't blacklist my sensei you baka...")

        time = datetime.datetime.utcnow()
        row = Blacklist(
            snowflake=server_or_user.id,
            blacklisted_at=time,
            reason=reason
        )

        try:
            async with ctx.db.get_session() as session:
                await session.add(row)
        except asyncpg.UniqueViolationError:
            return await ctx.send(f'{server_or_user} has already been blacklisted.')
        else:
            await self._show_blacklist_embed(ctx, 0xd50000, 'blacklisted', _blocked_icon,
                                             server_or_user, reason, time)
blacklists.py 文件源码 项目:Chiaki-Nanami 作者: Ikusaba-san 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __local_check(self, ctx):
        return await ctx.bot.is_owner(ctx.author)
blacklists.py 文件源码 项目:Chiaki-Nanami 作者: Ikusaba-san 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def unblacklist(self, ctx, server_or_user: _GuildOrUser, *, reason=''):
        """Removes either a server or a user from the blacklist."""

        if await ctx.bot.is_owner(server_or_user):
            return await ctx.send("You can't blacklist my sensei you baka...")

        async with ctx.db.get_session() as session:
            query = session.select.from_(Blacklist).where(Blacklist.snowflake == server_or_user.id)
            row = await query.first()
            if not row:
                return await ctx.send(f"{server_or_user} isn't blacklisted.")

            await session.remove(row)
            await self._show_blacklist_embed(ctx, 0x4CAF50, 'unblacklisted', _unblocked_icon,
                                             server_or_user, reason, datetime.datetime.utcnow())
core.py 文件源码 项目:nyx 作者: Cappycot 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def check_privilege(self, ctx):
        """Displays your privilege rank."""
        if await self.nyx.is_owner(ctx.message.author):
            privilege = "Owner"
        else:
            privilege = str(
                self.nyx.get_user_data(ctx.message.author).get_privilege())
        if ctx.message.guild is None:
            await ctx.send("Privilege: " + privilege)
        else:
            await ctx.send("".join(
                [ctx.message.author.mention, ", your privilege level is ",
                 privilege, "."]))


问题


面经


文章

微信
公众号

扫码关注公众号