Python discord.ext.commands 模块,is_owner() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用discord.ext.commands.is_owner()

项目:Chiaki-Nanami    作者:Ikusaba-san    | 项目源码 | 文件源码
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)
项目:Chiaki-Nanami    作者:Ikusaba-san    | 项目源码 | 文件源码
def __local_check(self, ctx):
        return await ctx.bot.is_owner(ctx.author)
项目:Chiaki-Nanami    作者:Ikusaba-san    | 项目源码 | 文件源码
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())
项目:nyx    作者:Cappycot    | 项目源码 | 文件源码
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, "."]))