本文整理汇总了Python中discord.ext.commands.guild_only方法的典型用法代码示例。如果您正苦于以下问题:Python commands.guild_only方法的具体用法?Python commands.guild_only怎么用?Python commands.guild_only使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类discord.ext.commands
的用法示例。
在下文中一共展示了commands.guild_only方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: color
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import guild_only [as 别名]
def color(self, ctx, *args):
c = self.get_context(ctx, args)
color = get_color(remove_mentions(args)[0] if remove_mentions(args) else '')
try:
await asyncio.wait_for(c.role.edit(color=color), timeout=3.0)
except asyncio.TimeoutError:
return await ctx.send(c.settings.get_text('rate_limited'))
c.room.update('color', color.value)
return await ctx.send(c.settings.get_text('updated_field').format(c.settings.get_text('color'), color, c.player.display_name, c.channel.mention))
# TODO: set view/send perms
# @commands.command()
# @commands.guild_only()
# async def view_permission(self, ctx, *args):
# pass
# @commands.command()
# async def send_permission(self, ctx, *args):
# pass
示例2: cog_before_invoke
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import guild_only [as 别名]
def cog_before_invoke(self, ctx):
""" Command before-invoke handler. """
guild_check = ctx.guild is not None
# This is essentially the same as `@commands.guild_only()`
# except it saves us repeating ourselves (and also a few lines).
if guild_check:
await self.ensure_voice(ctx)
# Ensure that the bot and command author share a mutual voicechannel.
return guild_check