Esempio n. 1
0
 async def isValidUser(self,msg):
     try:
         converter = UserConverter()
         await converter.convert(self.ctx,msg)
         return True
     except BadArgument:
         return False
Esempio n. 2
0
    async def unban(self,
                    ctx: Context,
                    *,
                    user: UserConverter,
                    reason: str = "Not specified.") -> None:
        try:
            await ctx.guild.unban(user)

            embed = moderation_embed(
                ctx,
                action="unbann",
                user=user,
                reason=reason,
                color=discord.Color.gold(),
            )
            embed.timestamp = datetime.utcnow()
            embed.set_thumbnail(url=user.avatar_url_as(format="png", size=256))
            await ctx.send(embed=embed)
        except discord.NotFound:
            embed = discord.Embed(
                title="Ban not Found!",
                description=dedent(f"""
                    There are no active bans on discord for {user.mention}.
                    He isn't banned here.
                    """),
                color=discord.Color.red(),
            )
            await ctx.send(embed=embed)
Esempio n. 3
0
    async def showme(self, ctx: Context, user, word=None):
        """
        Show how many times a user has said a certain word.
        """
        try:
            member = UserConverter(ctx, user).convert()
        except:
            self.bot.send_message(ctx.message.channel, 'Could not find user matching the name "{}"'.format(user))
            return

        if word is None:
            top_5_words = await self.thread_it(lambda: WordCounter.select()
                .where(WordCounter.user_id==member.id)
                .order_by(WordCounter.count.desc())
                .limit(5))
            response = '**Top 5 words for {}**'.format(member.display_name)
            for record in top_5_words:
                response += '\n{} - {}'.format(record.word, record.count)
            await self.bot.say(response)
        else:
            record = await self.thread_it(lambda: WordCounter.select()
                .where((WordCounter.user_id == member.id) & (WordCounter.word == word.lower()))
                .order_by(WordCounter.count.desc())
                .limit(1))
            if record:
                await self.bot.say('{} has said "{}" {} times.'.format(member.display_name, record[0].word, record[0].count))
            else:
                await self.bot.say('{} has never said the word "{}"'.format(member.display_name, word))
Esempio n. 4
0
 def convert(self):
     value = self.argument
     match = re.match(r'<@!?([0-9]+)>', value)
     if match is None:
         return battle_tag(value)
     else:
         return UserConverter(self.ctx, self.argument).convert()
Esempio n. 5
0
    def __init__(self, bot):

        #instance variables
        self.bot = bot
        self.equipment_requests_queue = deque()
        self.active_requests_queue = deque()
        self.converter = MemberConverter()
        self.user_converter = UserConverter()

        self.registered_users = dict()

        # open registered users spreadsheet
        USERS_WORKSHEET = 2
        self.users_sheet = client.open('Inventory').get_worksheet(
            USERS_WORKSHEET)
        self.all_reg_users = self.users_sheet.get_all_values()

        row = 2
        for entry in self.all_reg_users[1:]:
            user_id = self.users_sheet.cell(
                row, 1, value_render_option='FORMULA').value
            self.registered_users[user_id] = entry[1:]
            row += 1

        self.my_user_id = "267374448720609281"

        self.initial_response = None
        self.initial_response_trimmed = None
        self.initial_response_length = 0

        self.pid_response = None
        self.pid_length = 0

        self.inventory_selection = None
        self.user_selection = None
        self.is_number = None
        self.is_cancelled = None

        self.equipment_selection = None
        self.equipment_selection_length = 0
        self.equipment_selection_trimed = None
        self.item_id = None
        self.item_quantity = 0
        self.can_take_this_many = None
        self.avl_item_quantity = 0
        self.selected_item = None

        self.equipment_sheet = client.open('Inventory').get_worksheet(0)
Esempio n. 6
0
    async def on_message(self, message):
        #async def help (self, ctx):
        if str(message.author) == self.client.user:
            return

        if message.author.bot and str(
                message.author.id) == "760573976757010463":
            ctx = await self.client.get_context(message)
            id = message.content.split()
            converter = UserConverter()
            member = await converter.convert(ctx, id[1])
            await member.send("Thanks for voting for me, here's a 🍪")
            return

        if message.author.bot:
            return
Esempio n. 7
0
    async def convert(self, ctx, argument):
        bot = ctx.bot
        user = None
        member_converter = UserConverter()

        try:
            user = await member_converter.convert(ctx=ctx, argument=argument)
        except BadArgument:
            match = self._get_id_match(argument) or re.match(
                r'<@!?([0-9]+)>$', argument)

            try:
                if match is not None:
                    user = await bot.fetch_user(argument)

            except discord.NotFound:
                raise BadArgument('User "{}" not found'.format(argument))

        if user is None:
            raise BadArgument('User "{}" not found'.format(argument))

        return user
Esempio n. 8
0
    async def fc(self, ctx):
        if ctx.invoked_subcommand is None:
            responce = str(ctx.message.content)
            content = responce.split()
            try:
                content[1]
            except:
                fc = await seefc(self, ctx)
                Friend = discord.Embed(title=str(ctx.author) +
                                       "'s Friend Codes",
                                       description="",
                                       color=0x2962FF)
                Friend.set_thumbnail(url=ctx.author.avatar_url)
                if fc[0] != None:
                    Friend.add_field(name="Switch 1:",
                                     value=str(fc[0]),
                                     inline=True)
                if fc[1] != None:
                    Friend.add_field(name="Switch 2:",
                                     value=str(fc[1]),
                                     inline=True)
                if fc[2] != None:
                    Friend.add_field(name="Switch 3:",
                                     value=str(fc[2]),
                                     inline=True)
                if fc[3] != None:
                    Friend.add_field(name="Switch 4:",
                                     value=str(fc[3]),
                                     inline=True)
                if fc[4] != None:
                    Friend.add_field(name="Switch 5:",
                                     value=str(fc[4]),
                                     inline=True)
                if fc[5] != None:
                    Friend.add_field(name="Switch 6:",
                                     value=str(fc[5]),
                                     inline=True)
                if fc[6] != None:
                    Friend.add_field(name="Switch 7:",
                                     value=str(fc[6]),
                                     inline=True)
                if fc[7] != None:
                    Friend.add_field(name="Switch 8:",
                                     value=str(fc[7]),
                                     inline=True)
                if fc[8] != None:
                    Friend.add_field(name="PoGo 1:",
                                     value=str(fc[8]),
                                     inline=True)
                if fc[9] != None:
                    Friend.add_field(name="Pogo 2:",
                                     value=str(fc[9]),
                                     inline=True)
                if fc[10] != None:
                    Friend.add_field(name="Pogo 3:",
                                     value=str(fc[10]),
                                     inline=True)
                if fc[11] != None:
                    Friend.add_field(name="Pogo 4:",
                                     value=str(fc[11]),
                                     inline=True)
                if fc[12] != None:
                    Friend.add_field(name="3DS 1:",
                                     value=str(fc[12]),
                                     inline=True)
                if fc[13] != None:
                    Friend.add_field(name="3DS 2:",
                                     value=str(fc[13]),
                                     inline=True)
                if fc[14] != None:
                    Friend.add_field(name="Shuffle:",
                                     value=str(fc[14]),
                                     inline=True)
                if fc[15] != None:
                    Friend.add_field(name="Master:",
                                     value=str(fc[15]),
                                     inline=True)
                if fc[16] != None:
                    Friend.add_field(name="Home:",
                                     value=str(fc[16]),
                                     inline=True)
                if fc[17] != None:
                    Friend.add_field(name="Cafemix:",
                                     value=str(fc[17]),
                                     inline=True)
                if fc[1:] == fc[:-1]:
                    await ctx.send(
                        "You don't have any friend codes set on this server.")
                    return

                Friend.set_footer(
                    text="Provided by Nexus-Z",
                    icon_url=
                    "https://raw.githubusercontent.com/Sollisnexus/Sollisnexus.github.io/master/NexusZ/NexusZLogo_2.png"
                )
                await ctx.send(embed=Friend)

            else:
                if content[1].startswith("<") and content[1].endswith(">"):
                    converter = UserConverter()
                    member = await converter.convert(ctx, content[1])
                    fc = await seeotherfc(self, ctx, member.id)
                    Friend = discord.Embed(title=str(member) +
                                           "'s Friend Codes",
                                           description="",
                                           color=0x2962FF)
                    Friend.set_thumbnail(url=member.avatar_url)
                    if fc[0] != None:
                        Friend.add_field(name="Switch 1:",
                                         value=str(fc[0]),
                                         inline=True)
                    if fc[1] != None:
                        Friend.add_field(name="Switch 2:",
                                         value=str(fc[1]),
                                         inline=True)
                    if fc[2] != None:
                        Friend.add_field(name="Switch 3:",
                                         value=str(fc[2]),
                                         inline=True)
                    if fc[3] != None:
                        Friend.add_field(name="Switch 4:",
                                         value=str(fc[3]),
                                         inline=True)
                    if fc[4] != None:
                        Friend.add_field(name="Switch 5:",
                                         value=str(fc[4]),
                                         inline=True)
                    if fc[5] != None:
                        Friend.add_field(name="Switch 6:",
                                         value=str(fc[5]),
                                         inline=True)
                    if fc[6] != None:
                        Friend.add_field(name="Switch 7:",
                                         value=str(fc[6]),
                                         inline=True)
                    if fc[7] != None:
                        Friend.add_field(name="Switch 8:",
                                         value=str(fc[7]),
                                         inline=True)
                    if fc[8] != None:
                        Friend.add_field(name="PoGo 1:",
                                         value=str(fc[8]),
                                         inline=True)
                    if fc[9] != None:
                        Friend.add_field(name="Pogo 2:",
                                         value=str(fc[9]),
                                         inline=True)
                    if fc[10] != None:
                        Friend.add_field(name="Pogo 3:",
                                         value=str(fc[10]),
                                         inline=True)
                    if fc[11] != None:
                        Friend.add_field(name="Pogo 4:",
                                         value=str(fc[11]),
                                         inline=True)
                    if fc[12] != None:
                        Friend.add_field(name="3DS 1:",
                                         value=str(fc[12]),
                                         inline=True)
                    if fc[13] != None:
                        Friend.add_field(name="3DS 2:",
                                         value=str(fc[13]),
                                         inline=True)
                    if fc[14] != None:
                        Friend.add_field(name="Shuffle:",
                                         value=str(fc[14]),
                                         inline=True)
                    if fc[15] != None:
                        Friend.add_field(name="Master:",
                                         value=str(fc[15]),
                                         inline=True)
                    if fc[16] != None:
                        Friend.add_field(name="Home:",
                                         value=str(fc[16]),
                                         inline=True)
                    if fc[17] != None:
                        Friend.add_field(name="Cafemix:",
                                         value=str(fc[17]),
                                         inline=True)
                    if fc[1:] == fc[:-1]:
                        await ctx.send(
                            "This user doesn't have any friend codes set on this server."
                        )
                        return

                    Friend.set_footer(
                        text="Provided by Nexus-Z",
                        icon_url=
                        "https://raw.githubusercontent.com/Sollisnexus/Sollisnexus.github.io/master/NexusZ/NexusZLogo_2.png"
                    )
                    await ctx.send(embed=Friend)

                else:
                    ctx.send(
                        "Please @ a real user to check if they have any friend codes on this server"
                    )
Esempio n. 9
0
async def execute(ctx, player : commands.UserConverter):
    game = get_game_with_player(ctx.message.author.id)
    if not game:
        await ctx.send("You are not in a game")
        return

    if game.state is not GameStates.EXECUTION:
        await ctx.send("You can't execute somebody at the moment")
        return

    if game.president.player_id is not ctx.message.author.id:
        await ctx.send("You are not the president")
        return

    if not game.has_player(player.id):
        await ctx.send("This player is not in the same game as you")
        return

    executed = game.execute_player(player.id)
    if executed is None:
        await ctx.send("This player could not be executed")
        return

    fascists = []
    liberal = []

    for player in game.players:
        if player.get_party() == 'Fascist':
            fascists.append(player)
        elif player.get_party() == 'Liberal':
            liberal.append(player)

    if executed.role == "Hitler":
        game.state = GameStates.GAME_OVER
        game.winner = "Liberal"
        embed = discord.Embed(title='Game over!',
                              description=game.winner + 's won the game. Use -restart to restart the game.',
                              color=discord.Color.dark_red())
        for player in game.players:
            embed.add_field(name=client.get_user(player.player_id).name, value=player.role, inline=False)
        for player in game.dead:
            embed.add_field(name=client.get_user(executed.player_id).name, value=player.role, inline=False)
        await client.get_channel(game.channel_id).send(embed=embed)
    elif len(game.players) <= 1:
        game.state = GameStates.GAME_OVER
        game.winner = game.players[0].get_party()
        embed = discord.Embed(title='Game over!',
                              description=game.winner + 's won the game. Use -restart to restart the game.',
                              color=discord.Color.dark_red())
        for player in game.players:
            embed.add_field(name=client.get_user(player.player_id).name, value=player.role, inline=False)
        for player in game.dead:
            embed.add_field(name=client.get_user(executed.player_id).name, value=player.role, inline=False)
        await client.get_channel(game.channel_id).send(embed=embed)
    elif len(liberal) == 0:
        game.state = GameStates.GAME_OVER
        game.winner = game.players[0].get_party()
        embed = discord.Embed(title='Game over!',
                              description='Liberals won the game. Use -restart to restart the game.',
                              color=discord.Color.dark_red())
        await client.get_channel(game.channel_id).send(embed=embed)
    elif len(fascists) == 0:
        game.state = GameStates.GAME_OVER
        game.winner = game.players[0].get_party()
        embed = discord.Embed(title='Game over!',
                              description='Fascists won the game. Use -restart to restart the game.',
                              color=discord.Color.dark_red())
        await client.get_channel(game.channel_id).send(embed=embed)
    else:
        embed = discord.Embed(title='Player executed', description=client.get_user(executed.player_id).name+ " was executed.")
        embed.set_thumbnail(url=client.get_user(executed.player_id).avatar_url)
        await client.get_channel(game.channel_id).send(embed=embed)
        game.state = GameStates.NOMINATION
        game.set_president()
        await start_nomination(game)