コード例 #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 _dice(self, ctx: NewCtx, dice: str = '1d6'):
        """Generates dice with the supplied format `NdN`"""
        dice_list = dice.lower().split('d')
        try:
            d_count, d_value = int(dice_list[0]), int(dice_list[1])
        except ValueError:
            raise commands.BadArgument(
                "The entered format was incorrect, `NdN` only currently")

        counter = []
        crit_s, crit_f = 0, 0
        if d_count < 0 or d_value < 0:
            raise commands.BadArgument("You cannot have negative values")
        for dice_num in range(d_count):
            randomnum = random.randint(1, d_value)
            if randomnum == d_value:
                crit_s += 1
            if randomnum == 1:
                crit_f += 1
            counter.append(randomnum)

        total = sum(counter)

        embed = BetterEmbed()
        embed.description = f"{dice} gave {', '.join([str(die) for die in counter])} = {total} with {crit_s} crit successes and {crit_f} fails"

        await ctx.send(embed=embed)
コード例 #4
0
ファイル: meta.py プロジェクト: Peppermint777/yert
    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)
コード例 #5
0
 async def send_cog_help(self, cog):
     embed = BetterEmbed(title=f'{cog.qualified_name} Category')\
         .set_footer(text='⇶ indicates subcommands')
     description = f'{cog.description or ""}\n\n'
     entries = await self.filter_commands(cog.get_commands(), sort=True)
     description += "\n".join([f'{"⇶" if isinstance(c, commands.Group) else "⇾"} **{c.name}** -'
                               f' {c.short_doc or "No description"}' for c in entries])
     embed.description = description
     await self.context.send(embed=embed)
コード例 #6
0
 async def send_group_help(self, group):
     embed = BetterEmbed(title=self.get_command_signature(group))
     description = f'{group.help or "No description provided"}\n\n'
     entries = await self.filter_commands(group.commands, sort=True)
     description += "\n".join([f'{"⇶" if isinstance(command, commands.Group) else "⇾"} **{command.name}** -'
                               f' {command.short_doc or "No description"}' for command in entries])
     embed.description = description
     footer_text = '⇶ indicates subcommands'
     if checks := retrieve_checks(group):
         footer_text += f' | Checks: {checks}'
コード例 #7
0
 async def send_bot_help(self, mapping):
     def key(c):
         return c.cog_name or '\u200bUncategorized'
     bot = self.context.bot
     embed = BetterEmbed(title=f'{bot.user.name} Help')
     description = f'Use `{self.clean_prefix}help <command/category>` for more help\n\n'
     entries = await self.filter_commands(bot.commands, sort=True, key=key)
     for cog, cmds in itertools.groupby(entries, key=key):
         cmds = sorted(cmds, key=lambda c: c.name)
         description += f'**➣ {cog}**\n{" • ".join([c.name for c in cmds])}\n'
     embed.description = description
     await self.context.send(embed=embed)
コード例 #8
0
    async def _rand_num(self, ctx: NewCtx, start: Union[int, float],
                        stop: Union[int, float]):
        """Generates a random number from start to stop inclusive, if either is a float, number will be float"""

        if isinstance(start, float) or isinstance(stop, float):
            number = random.uniform(start, stop)
        else:
            number = random.randint(start, stop)

        embed = BetterEmbed()
        embed.description = f"Number between {start} and {stop}, {number=}"

        await ctx.send(embed=embed)
コード例 #9
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)
コード例 #10
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")
        embed.description = f"```py\n{content}```"
        embed.add_field(name="Invoking command",
                        value=f"{self.invoked_with}", inline=True)
        embed.add_field(name="Author", value=f"{self.author.display_name}")
        embed.timestamp = datetime.utcnow()
        if not skip_ctx:
            await super().send(embed=embed)

        if not skip_wh:
            await webhook.send(embed=embed)
コード例 #11
0
 async def send_command_help(self, command):
     embed = BetterEmbed(title=self.get_command_signature(command))
     description = f'{command.help or "No description provided"}\n\n'
     embed.description = description
     if c := retrieve_checks(command):
         embed.set_footer(text=f'Checks: {c}')