Пример #1
0
    async def _check_bal(self, ctx: NewCtx, target: Optional[discord.Member]):
        """"""
        user_id = getattr(target, 'id', None) or ctx.author.id
        target = target or ctx.author

        query = "SELECT * FROM game_data WHERE user_id=$1;"
        result = await self.bot.pool.fetchrow(query, user_id)
        if result:
            e = BetterEmbed(title=target.display_name)
            e.add_field(name=f"Your currently have {result['amount']} <:peepee:712691831703601223>.",
                        value='\u200b')
            e.description = f"Wins : {result['wins']}\nLosses : {result['losses']}"
            e.set_author(name=target.display_name, icon_url=str(target.avatar_url))
            return await ctx.send(embed=e)
        else:
            await ctx.send("Yoink hasn't seen you before, wait one.")
            query = "INSERT INTO game_data (user_id, wins, losses, amount)" \
                    "VALUES ($1, $2, $3, $4);"
            await self.bot.pool.execute(query, user_id, 0, 0, 150)
            e = BetterEmbed(title=target.display_name)
            e.add_field(name = f"Your currently have 150 <:peepee:712691831703601223>.",
                        value = '\u200b')
            e.description = f"Wins : 0\nLosses : 0"
            e.set_author(name = target.display_name, icon_url = str(target.avatar_url))
            return await ctx.send(embed = e)
Пример #2
0
    async def about(self, ctx):
        """ This is the 'about the bot' command. """
        description = dedent(f"""\
                             A ~~shit~~ fun bot that was thrown together by a team of complete nincompoops.
                             In definitely no particular order:\n
                            {', '.join([self.bot.get_user(i).__str__() for i in self.bot.owner_ids])}
                             """)
        # uniq_mem_count = set(
        #     member for member in guild.members if not member.bot for guild in self.bot.guilds) #! TODO fix set comp
        uniq_mem_count = set()
        for guild in self.bot.guilds:
            for member in guild.members:
                if not member.bot:
                    uniq_mem_count.add(member)
        
        # {member for member in ctx.bot.get_all_members() if not member.bot}

        embed = BetterEmbed(title=f"About {ctx.guild.me.display_name}")
        embed.description = description
        embed.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url)
        embed.add_field(name="Current guilds",
                        value=f'{len(self.bot.guilds):,}')
        embed.add_field(name="Total fleshy people being memed",
                        value=f'{len(uniq_mem_count):,}')
        await ctx.send(embed=embed)
Пример #3
0
    async def about(self, ctx):
        """ This is the 'about the bot' command. """
        description = dedent("""\
                             A ~~shit~~ fun bot that was thrown together by a team of complete nincompoops.
                             In definitely no particular order:\n
                             『 Moogs 』#2009, MrSnek#3442, nickofolas#0066 and Umbra#0009
                             """)
        # uniq_mem_count = set(
        #     member for member in guild.members if not member.bot for guild in self.bot.guilds) #! TODO fix set comp
        uniq_mem_count = set()
        for guild in self.bot.guilds:
            for member in guild.members:
                if not member.bot:
                    uniq_mem_count.add(member)

        # {member for member in ctx.bot.get_all_members() if not member.bot}

        embed = BetterEmbed(title=f"About {ctx.guild.me.display_name}")
        embed.description = description
        embed.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url)
        embed.add_field(name="Current guilds",
                        value=len(self.bot.guilds),
                        inline=True)
        embed.add_field(name="Total fleshy people being memed",
                        value=len(uniq_mem_count))
        await ctx.send(embed=embed)
Пример #4
0
    async def _blackjack(self, ctx: NewCtx, bet: int = 30):
        """Plays blackjack against the house, default bet is 30 <:peepee:712691831703601223>"""
        if not(1 <= bet <= 100):
            return await ctx.send("You must bet between 1 and 100 <:peepee:712691831703601223>.")
        else:
            result = await self.db_query(self.bot, 'get_user_data', ctx.author.id)
            if result:
                available_currency = result['amount']
                if bet > available_currency:
                    return await ctx.send("You don't have enough <:peepee:712691831703601223> for that bet.")
                else:
                    await ctx.send(f"Very well, your {bet}<:peepee:712691831703601223> will be gladly accepted.")
                    wins = result['wins']
                    losses = result['losses']

            else:
                query = self.queries['new_user']
                await self.bot.pool.execute(query, ctx.author.id, 0, 0, 150)
                wins = 0
                losses = 0
                available_currency = 150
                await ctx.send("Yoink has not seen you before, have 150 <:peepee:712691831703601223> on the house.")

            house = await self.db_query(self.bot, 'get_user_data', self.bot.user.id)

            embed = BetterEmbed()
            embed.add_field(
                name=f"{ctx.author.display_name} vs the house",
                value="[h | hit] [s | stay] [q | quit (only on the first turn)] ",
                inline=False
            )

            original = await ctx.send(embed=embed)

            game = blackjack.Blackjack(ctx, original, embed, self.timeout)
            await original.edit(embed=game.embed)

            await game.player_turn()
            await game.dealer_turn()
            winner = await game.game_end()

            if winner == 'Draw' and not isinstance(winner, blackjack.Player):
                await ctx.send("The game was drawn, your <:peepee:712691831703601223> have been returned.")

            elif winner.id == ctx.author.id:
                await ctx.send(f"Congratulations, you beat the house, take your {bet}<:peepee:712691831703601223> ")
                end_amount = available_currency + bet
                query = self.queries['win']
                await self.bot.pool.execute(query, wins + 1, end_amount, ctx.author.id)
                other_query = self.queries['loss']
                await self.bot.pool.execute(other_query, house['losses'] + 1, house['amount'] - bet, self.bot.user.id)

            else:
                await ctx.send(f"The house always wins, your {bet}<:peepee:712691831703601223> have been yoinked.")
                end_amount = available_currency - bet
                query = self.queries['loss']
                await self.bot.pool.execute(query, losses + 1, end_amount, ctx.author.id)
                other_query = self.queries['win']
                await self.bot.pool.execute(other_query, house['wins'] + 1, house['amount'] + bet, self.bot.user.id)
Пример #5
0
    def format_snapshot(self, *, response: MagmaChainResponse,
                        is_nsfw: bool) -> BetterEmbed:
        """Formats the snaphot into an embed"""
        embed = BetterEmbed(
            title=f"Screenshot | Safe : {'OFF' if is_nsfw else 'ON'}",
            url=response.website)

        embed.add_field(name='Link', value=maybe_url(response.website))

        return embed.set_image(url=response.snapshot)
Пример #6
0
 async def userinfo(self, ctx, *, user: BetterUserConverter = None):
     flags = Flags(user.http_dict['public_flags']).flags
     user = user.obj
     user_info = UserInfo(user)
     badges = [badge_mapping.get(f) for f in flags]
     if user_info.is_nitro:
         badges.append('<:nitro:711628687455420497>')
     embed = BetterEmbed(
         title=user.__str__(), description=' '.join(badges))\
         .set_thumbnail(url=user.avatar_url_as(static_format='png'))
     embed.add_field(name='Info', value=f'Account Created: {humanize.naturaltime(user.created_at)}')
     await ctx.send(embed=embed)
Пример #7
0
    def format_page(self, menu, response: Result) -> BetterEmbed:
        """Formats the repsponse into an embed"""
        header = response.header
        data = response.data
                    
        embed = BetterEmbed(title=f"{header.index_name} | {header.similarity}%")
        embed.set_thumbnail(url=header.thumbnail)
        embed.add_field(name='External urls', 
                        value='\n'.join([maybe_url(url) for url in data.get('ext_urls', [])]))

        for key, value in data.items():
            if not isinstance(value, list):
                if url := maybe_url(value):
                    embed.add_field(name=key, value=url)  # no idea about what it will return
Пример #8
0
    async def webhook_send(self,
                           content: str,
                           *,
                           webhook: discord.Webhook,
                           skip_wh: bool = False,
                           skip_ctx: bool = False) -> None:
        """ This is a custom ctx addon for sending to the webhook and/or the ctx.channel. """
        content = content.strip("```")
        embed = BetterEmbed(title="Error", description=f"```py\n{content}```",
                            timestamp=datetime.now(tz=timezone.utc))
        embed.add_field(name="Invoking command",
                        value=f"{self.prefix}{self.invoked_with}", inline=True)
        embed.add_field(name="Author", value=f"{str(self.author)}")
        if not skip_ctx:
            await super().send(embed=embed)

        if not skip_wh:
            await webhook.send(embed=embed)
Пример #9
0
    async def on_spinning(self, channel_id):
        channel = self.bot.get_channel(channel_id)
        game_state: roulette.Game = self.roulette_games[channel_id]
        del self.roulette_games[channel_id]
        text = "The wheel is spinning, all new bets are ignored"
        await asyncio.sleep(2)
        original = await channel.send(text)
        results = game_state.handle_bets()
        embed = BetterEmbed(title=f"Roulette : {channel.name}")
        for player_id, bet_info in results.items():
            player = self.bot.get_user(player_id)
            embed.add_field(
                name=f"{player.display_name} \nBet | Amount",
                value='`\n`'.join([f"{bet} : {amount}" for bet, amount in bet_info]),
                inline=True
            )

        text += f"\nThe ball rolls, landing on {game_state.landed}"
        await original.edit(content=text)
        await asyncio.sleep(2)
        await original.edit(content=text, embed=embed)
Пример #10
0
    async def about(self, ctx: NewCtx):
        """ This is the 'about the bot' command. """
        # Github id of the contributors and their corresponding discord id
        DISCORD_GIT_ACCOUNTS = {
            64285270: 361158149371199488,
            16031716: 155863164544614402,
            4181102: 273035520840564736,
            54324533: 737985288605007953,
            60761231: 723268667579826267,
        }

        contributors = ""
        for contributor in await self.get_profiles():
            if contributor["type"] == "Anonymous":
                contributor["login"] = contributor["name"]
                discord_profile = "unknown"
            else:
                discord_profile = DISCORD_GIT_ACCOUNTS.get(
                    contributor["id"], "unkown")
                if discord_profile != "unknown":
                    discord_profile = self.bot.get_user(discord_profile)
            contributors += f"{contributor['login']}({str(discord_profile)}): \
                            **{contributor['contributions']}** commits.\n"

        uniq_mem_count = set()
        for guild in self.bot.guilds:
            for member in guild.members:
                if not member.bot:
                    uniq_mem_count.add(
                        member)  # can't we just filter bot.users there ?

        embed = BetterEmbed(title=f"About {ctx.guild.me.display_name}")
        embed.description = "A ~~shit~~ fun bot that was thrown together by a team of complete nincompoops."
        embed.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url)
        embed.add_field(name="Contributors", value=contributors, inline=False)
        embed.add_field(name="Current guilds",
                        value=f'{len(self.bot.guilds):,}',
                        inline=False)
        embed.add_field(name="Total fleshy people being memed",
                        value=f'{len(uniq_mem_count):,}',
                        inline=False)
        embed.add_field(name='Come check out our source at ;',
                        value='https://github.com/uYert/yert',
                        inline=False)
        await ctx.send(embed=embed)