Esempio n. 1
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
Esempio n. 2
0
 async 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(args) if args else [],
         player=player )
     if is_admin and (len(role_mentions) >= 1):
         room = Room.get_by_role(role_mentions[0].id)
     else:
         (room, m) = Room.get_hosted_rooms(ctx, context.args)
         if m:
             await ctx.send(m)
             raise discord.ext.commands.errors.CheckFailure()
     if room:
         context.room = room
         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