Пример #1
0
 async def cog_check(self, ctx):
     s = Settings.get_for(ctx.guild.id)
     is_enabled_command = ctx.command.name in s.allowed_host_commands
     is_host = Room.get_hosted(ctx.message.author.id, ctx.guild.id)
     is_admin = ctx.message.author.guild_permissions.administrator
     searched_room = Room.get_by_mention(ctx,
                                         ctx.message.content.split(' ')[1:])
     return (is_host and is_enabled_command) or (is_admin and searched_room)
Пример #2
0
 def get_context(self, ctx, *args):
     is_admin = ctx.message.author.guild_permissions.administrator
     mentions = len(ctx.message.mentions)
     role_mentions = ctx.message.role_mentions
     player = ctx.message.author
     context = RoomContext(ctx=ctx,
                           settings=Settings.get_for(ctx.guild.id),
                           args=list(list(args)[0]),
                           player=player)
     if is_admin and (len(role_mentions) >= 1):
         room = Room.get_by_role(role_mentions[0].id)
     else:
         room = Room.get_hosted(player.id, ctx.guild.id)
     if room:
         context.room = room
         context.mentioned_player = ctx.message.mentions[
             0] if ctx.message.mentions else None
         context.channel = ctx.guild.get_channel(room.channel_id)
         context.voice_channel = ctx.guild.get_channel(
             room.voice_channel_id)
         context.role = ctx.guild.get_role(room.role_id)
     return context