Python discord.ext.commands.guild_only() Examples
The following are 2
code examples of discord.ext.commands.guild_only().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
discord.ext.commands
, or try the search function
.
Example #1
Source File: roomhost.py From discord-roombot with GNU General Public License v3.0 | 6 votes |
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
Example #2
Source File: music.py From Lavalink.py with MIT License | 5 votes |
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