本文整理汇总了Python中discord.ext.commands.is_owner方法的典型用法代码示例。如果您正苦于以下问题:Python commands.is_owner方法的具体用法?Python commands.is_owner怎么用?Python commands.is_owner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类discord.ext.commands
的用法示例。
在下文中一共展示了commands.is_owner方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: echo
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import is_owner [as 别名]
def echo(self, ctx, channel, *, message):
"""
Echoes a string into a different channel
:params channel: channel to echo into params message: message to
:echo
"""
is_owner = await ctx.bot.is_owner(ctx.author)
if not is_owner:
return
if not ctx.message.channel_mentions:
return await ctx.send(
f'<command> <channel mention> <message> u idiot')
try:
for channel in ctx.message.channel_mentions:
await channel.send(f'{message}')
except Exception as e:
self.logger.warning(f"Error while echoing: {e}")
await ctx.send('Error when trying to send fam')
示例2: makedoc
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import is_owner [as 别名]
def makedoc(self, ctx):
cogs = {name: {} for name in ctx.bot.cogs.keys()}
all_commands = []
for command in ctx.bot.commands:
all_commands.append(command)
if isinstance(command, commands.Group):
all_commands.extend(command.commands)
for c in all_commands:
if c.cog_name not in cogs or c.help is None or c.hidden:
continue
if c.qualified_name not in cogs[c.cog_name]:
skip = False
for ch in c.checks:
if 'is_owner' in repr(ch): # mine. don't put on docs
skip = True
if skip:
continue
help = c.help.replace('\n\n', '\n>')
cogs[c.cog_name][
c.qualified_name] = f'#### {c.qualified_name}\n>**Description:** {help}\n\n>**Usage:** `{ctx.prefix + c.signature}`'
index = '\n\n# Commands\n\n'
data = ''
for cog in sorted(cogs):
index += '- [{0} Commands](#{1})\n'.format(cog, (cog + ' Commands').replace(' ', '-').lower())
data += '## {0} Commands\n\n'.format(cog)
extra = inspect.getdoc(ctx.bot.get_cog(cog))
if extra is not None:
data += '#### ***{0}***\n\n'.format(extra)
for command in sorted(cogs[cog]):
index += ' - [{0}](#{1})\n'.format(command, command.replace(' ', '-').lower())
data += cogs[cog][command] + '\n\n'
fp = io.BytesIO((index.rstrip() + '\n\n' + data.strip()).encode('utf-8'))
await ctx.author.send(file=discord.File(fp, 'commands.md'))
示例3: cog_check
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import is_owner [as 别名]
def cog_check(self, ctx):
return await self.bot.is_owner(ctx.author)