Esempio n. 1
0
 async def changelog(self, ctx, *, pageNum: Optional[Converters.SafeInt]):
     embed = libneko.Embed()
     embed.colour = random.randint(0, 0xffffff)
 
     maxPage = len(self.bot.changelogContents)
 
     if type(pageNum) is int:
         pageNum -= 1
     else:
         if pageNum == "oldest":
             pageNum = subtract(maxPage)
         else:
             pageNum = 0
 
     if pageNum < 0 or pageNum > subtract(maxPage):
         await ctx.send(f"{ctx.author.mention}, that is an invalid page number! Range: `1 - {maxPage}`")
         return
 
     if pageNum == 0:
         embed.title = f"Latest Update (page {add(pageNum)} of {maxPage}):"
     elif pageNum == subtract(maxPage):
         embed.title = f"Oldest Version (page {add(pageNum)} of {maxPage}):"
     else:
         embed.title = f"Older Update (page {add(pageNum)} of {maxPage}):"
     
     embed.description = self.bot.changelogContents[pageNum]
     embed.set_footer(icon_url = str(ctx.author.avatar_url), text = f"Invoked by {ctx.author}")
     
     try:
         await ctx.send(content = None, embed = embed)
     except discord.errors.Forbidden:
         await ctx.channel.send(f"{ctx.author.mention}, the bot is unable to send the requested data! Please grant the bot the \"Embed Links\" permission or ask an admin / moderator to do so.")
Esempio n. 2
0
    async def work(self, ctx):
        isSuccessful = random.choice([True, False, True, False, True, False])
        amount = int(random.randint(15, 50) * random.uniform(0.95, 2.95))

        embed = libneko.Embed(
            title=
            f"Work {'Successful <:le:808638475229986876>' if isSuccessful else 'Failed <:nogis:808638474646978560>'}"
        )

        if isSuccessful:
            embed.color = random.choice(
                [Color.green(), Color.blue(),
                 Color.blurple()])
            embed.add_field(name="Outcome:",
                            value=random.choice(
                                workOutcome[isSuccessful]).format(
                                    ctx.author, amount))
            await self.bot.eco.edit_money(ctx.author.id, amount, "wallet",
                                          "add")
        else:
            embed.color = random.choice(
                [Color.red(), Color.orange(), 0xffff00])
            embed.add_field(name="Outcome:",
                            value=random.choice(
                                workOutcome[isSuccessful]).format(ctx.author))
        embed.set_footer(icon_url=str(ctx.author.avatar_url),
                         text=f"Invoked by {ctx.author}")

        try:
            await ctx.send(f"{ctx.author.mention}", embed=embed)
        except discord.errors.Forbidden:
            await ctx.send(
                f"{ctx.author.mention}, I am unable to send the requested data! Please grant the bot the \"Embed Links\" permission or ask an admin / moderator to do so."
            )
Esempio n. 3
0
 async def suggest(self, ctx, *, suggestion):
     """Suggest a feature to <@268085347462676480>"""
     creator = (await bot.application_info()).owner
     await creator.send(f"New suggestion from {ctx.message.author.mention}: {suggestion}")
     embed=libneko.Embed(title=f'Your suggestion has been sent: {suggestion}')
     embed.set_footer(text=f"Requested by {ctx.author}", icon_url=f"{ctx.author.avatar_url_as(size=1024)}")
     await ctx.send(embed=embed)
Esempio n. 4
0
    async def balance(self, ctx, user: Optional[discord.Member]):
        uid = 0
        wallet = bank = None

        if user == None:
            user = ctx.author
            uid = ctx.author.id
        else:
            uid = user.id

        while wallet == None and bank == None:
            wallet = await self.bot.eco.get_money(uid, "wallet")
            bank = await self.bot.eco.get_money(uid, "bank")

        total = wallet + bank

        embed = libneko.Embed(title=f"{user}'s Balance")
        embed.description = f"**Wallet**: :coin: {wallet}\n**Bank**: :coin: {bank}\n**Total Balance**: :coin: {total}"
        embed.set_thumbnail(url=str(user.avatar_url))

        embed.set_footer(icon_url=str(ctx.author.avatar_url),
                         text=f"Invoked by {ctx.author}")
        embed.colour = random.randint(0, 0xffffff)

        try:
            await ctx.send(content=None, embed=embed)
        except discord.errors.Forbidden:
            await ctx.send(
                f"{ctx.author.mention}, I am unable to send the requested data! Please grant the bot the \"Embed Links\" permission or ask an admin / moderator to do so."
            )
Esempio n. 5
0
 async def help(self, ctx, command: Optional[str]):
     embed = libneko.Embed(title = "Commands List")
     embed.colour = random.randint(0, 0xffffff)
     
     prefix = "c-" if isAlpha else "c+"
     
     leCogs = self.bot.cogs
     if not type(command) is str:
         embed.set_footer(icon_url = str(ctx.author.avatar_url), text = f"Invoked by {ctx.author}")
         for b in leCogs:
             cogCommands = leCogs.get(b).get_commands()
             commandinfo = ""
             
             for a in cogCommands:
                 shortHelp = getattr(a, "brief", "(Brief command info not found.)")
                 isHidden = getattr(a, "hidden", False)
             
                 if not isHidden:
                     commandinfo += str(f"\n**{prefix}" + str(a) + f"** --> {shortHelp}")
                 else:
                     pass
                 
             embed.add_field(name = f"**{b}**", value = leCogs.get(b).description + commandinfo)
     else:
         embed.set_footer(icon_url = str(ctx.author.avatar_url), text = f"Invoked by {ctx.author}")
         embed.title = "Specific Command Info"
         commR = self.bot.get_command(command)
         commCat = str()
         
         try:
             for a in leCogs:
                 if commR in leCogs.get(a).get_commands():
                     commCat = a
                     raise Exception("cog found")
         except Exception:
             pass
         else:
             commCat = "No Category"
         
         if commR is None:
             await ctx.send(f"Command \"{command}\" not found.")
             return
         else:
             helpMessage = getattr(commR, "help", f"No info given for command \"{commR}\".")
             aliases = getattr(commR, "aliases", "None")
             isHidden = getattr(commR, "hidden", False)
             
             if aliases == []:
                 aliases = "None"
             
             if isHidden:
                 helpMessage += "\n**Note: This is a hidden command. It will not be listed when the list of commands is displayed.**"
             
             embed.add_field(name = prefix + str(commR), value = f"{helpMessage}\n\nAlias/es: {aliases}\nBelongs to: **{commCat}**")
     try:
         await ctx.send(content = None, embed = embed)
     except discord.errors.Forbidden:
         await ctx.channel.send(f"{ctx.author.mention}, the bot is unable to send the requested data! Please grant the bot the \"Embed Links\" permission or ask an admin / moderator to do so.")
Esempio n. 6
0
 async def test(self, ctx):        
     emojis = [str(x) for x in self.bot.get_guild(Constants.ServerIDs[2]).emojis]
     embed = libneko.Embed(title = "test")
     embed.add_field(name = "This is YouTube:", value = "[link](https://www.youtube.com)")
     
     print(emojis)
     try:
         await ctx.send(content = None, embed = embed)
     except discord.errors.Forbidden:
         await ctx.channel.send(f"{ctx.author.mention}, the bot is unable to send the requested data! Please grant the bot the \"Embed Links\" permission or ask an admin / moderator to do so.")      
Esempio n. 7
0
    async def avatar(self, ctx, *, user: discord.Member = None):
        """ Get the avatar of you or someone else """
        if user is None:
            user = ctx.author

        embed = libneko.Embed(title=f"{user.name}\'s avatar",
                              url=f"{user.avatar_url_as(size=1024)}")
        embed.set_image(url=f"{user.avatar_url_as(size=1024)}")
        embed.set_footer(text=f"Requested by {ctx.author}",
                         icon_url=f"{ctx.author.avatar_url_as(size=1024)}")
        await ctx.send(embed=embed)
Esempio n. 8
0
    async def accountage(self, ctx, *, user: discord.Member = None):
        """Determines age of account"""

        if user is None:
            user = ctx.author
            name = "Your"
        else:
            name = f"{user.mention}\'s"
        created = datetime.utcnow() - user.created_at
        created_string = format_seconds(created.total_seconds(), precision=3)
        description = f"{name} account was created {created_string} ago!"
        embed = libneko.Embed(description=description)
        embed.set_footer(text=f"Requested by {ctx.author}",
                         icon_url=f"{ctx.author.avatar_url_as(size=1024)}")
        await ctx.send(embed=embed)
Esempio n. 9
0
 async def userinfo(self, ctx, *, user: discord.Member = None):
     """Get info about a user"""
     if user is None:
         user = ctx.author
     embed = libneko.Embed(title=f"{user.name}#{user.discriminator}")
     embed.add_field(name="ID:", value=user.id, inline=True)
     embed.add_field(name="Nickname:", value=user.nick, inline=True)
     embed.add_field(name="Mention:", value=user.mention, inline=True)
     embed.add_field(name="Joined at:",
                     value=user.joined_at.strftime('%d/%m/%y at %H:%M'),
                     inline=True)
     embed.add_field(name="Created at:",
                     value=user.created_at.strftime('%d/%m/%y at %H:%M'),
                     inline=True)
     embed.set_thumbnail(url=user.avatar_url_as(size=1024))
     embed.set_footer(text=f"Requested by {ctx.author}",
                      icon_url=f"{ctx.author.avatar_url_as(size=1024)}")
     await ctx.send(embed=embed)
Esempio n. 10
0
 async def suggest(self, ctx, *, args: Optional[str]):
     sNum = sn_add()
     if sNum == -1:
         await ctx.send("Command failed!")
         raise CommandError("error in sn file")
     
     embed = libneko.Embed(title = f"Suggestion #{sNum}")
     embed.colour = random.randint(0, 0xffffff)
     
     if ctx.channel.id == Constants.Suggestions[0]:
         await ctx.message.delete()
         
         if args.isspace() or args == "":
             await ctx.send(f"{ctx.author.mention}, please add what to suggest!")
             return
         else:
             embed.description = f"Suggested by {ctx.author}:\n\"{args}\""
             embed.set_footer(icon_url = ctx.author.avatar_url, text = f"\"c.suggest < suggestions > \" is the command.")
             await ctx.send(f"{ctx.author.mention}, your suggestion has been added!")
             await self.bot.get_channel(Constants.Suggestions[1]).send(content = None, embed = embed)
Esempio n. 11
0
 async def serverinfo(self, ctx):
     """Get info about the current server"""
     dt = ctx.guild.created_at
     embed = libneko.Embed(title=ctx.guild.name)
     embed.add_field(name="Server Name:", value=ctx.guild.name, inline=True)
     embed.add_field(name="Server Owner:",
                     value=f"{ctx.guild.owner}",
                     inline=True)
     embed.add_field(name="Members:",
                     value=f"{ctx.guild.member_count}",
                     inline=True)
     embed.add_field(name="Server Region:",
                     value=f"{ctx.guild.region}",
                     inline=True)
     embed.add_field(name="Created at:",
                     value=dt.strftime('%d/%m/%y at %H:%M'),
                     inline=True)
     embed.set_thumbnail(url=ctx.guild.icon_url)
     embed.set_footer(text=f"Requested by {ctx.author}",
                      icon_url=f"{ctx.author.avatar_url_as(size=1024)}")
     await ctx.send(embed=embed)
Esempio n. 12
0
    async def daily(self, ctx):
        id = ctx.author.id
        amount = 500
        sA = 0
        valid = False
        day = await self.bot.eco.get_dailycd(id)

        embed = libneko.Embed(title="Daily Rewards")
        embed.set_footer(icon_url=str(ctx.author.avatar_url),
                         text=f"Invoked by {ctx.author}")
        embed.colour = random.randint(0, 0xffffff)

        if type(day) is str:
            valid = False
        elif day == 1:
            await self.bot.eco.edit_streak(id, "add")
            valid = True
        else:
            await self.bot.eco.edit_streak(id, "set")
            valid = True

        if valid:
            streak = await self.bot.eco.get_streak(id)
            await self.bot.eco.set_dailycd(id)

            sA = (0.33 * (streak - 1))
            amount += int(50 * sA)

            await self.bot.eco.edit_money(id, amount, "wallet", "add")

            embed.description = f"You have received your daily :coin: {amount}!\n**Streak**: Day {streak} (+:coin: {int(50 * sA)})"
        else:
            embed.description = f"Your daily reward is on cooldown, please try again tomorrow!\n**Cooldown**: {day}"

        try:
            await ctx.send(f"{ctx.author.mention}", embed=embed)
        except discord.errors.Forbidden:
            await ctx.send(
                f"{ctx.author.mention}, I am unable to send the requested data! Please grant the bot the \"Embed Links\" permission or ask an admin / moderator to do so."
            )
Esempio n. 13
0
 async def presence(self, ctx, *, newpresence):
     """Change presence (Bot Owner Only)"""
     game = discord.Game(f"{newpresence}")
     await bot.change_presence(activity=game)
     await ctx.send(embed=libneko.Embed(
         title=f'Set presence to `{newpresence}`'))
Esempio n. 14
0
    async def cardinfo(self, ctx, *, cardID: Optional[Converters.SafeInt]):
        moveInfo = None
        if isinstance(cardID, str):
            cardID = cardID.lower()
        elif isinstance(cardID, int):
            pass
        else:
            await ctx.channel.send(
                f"{ctx.author.mention}, please enter the name or ID of a Card!"
            )
            return

        if type(cardID) is int:
            for x in cards.UniversalCards:
                try:
                    c = cards.UniversalCards[cardID]
                except:
                    pass
                else:
                    for a in cards.NormalCards:
                        if a == c:
                            moveInfo = cards.NormalCards[c]

            for x in cards.SpecialCards_:
                try:
                    c = cards.SpecialCards_[cardID]

                    if c == None:
                        raise Exception("pass")
                except:
                    pass
                else:
                    moveInfo = cards.SpecialCards[c]
        else:
            for o in cards.AllCards:
                if o == cardID:
                    moveInfo = cards.AllCards[o]

        if moveInfo == None:
            await ctx.channel.send(
                f"{ctx.author.mention}, there is no Card with that name or ID!"
            )
            return
        elif moveInfo.id == 1000:
            await ctx.channel.send(
                f"{ctx.author.mention}, there is no Card with that name or ID!"
            )
            return

        desc = moveInfo.effectDesc

        if moveInfo.power == -1:
            moveInfo.power = "--"
        elif moveInfo.power == 999:
            moveInfo.power = "OHKO"
            desc += "** Requires charging in a few turns before use.**"

        if moveInfo.id == 11:
            moveInfo.power = "0 or 20 - 50"
        elif moveInfo.id == 13:
            moveInfo.power = "35 - 70"

        embed = libneko.Embed(title=f"More Card Information")

        cl = moveInfo.classification.split(",", 1)
        clinfo = ""

        if len(cl) == 1:
            clinfo = cl[0].title()
        elif len(cl) == 2:
            clinfo = f"{cl[0].title()} / {cl[1].title()}"

        if moveInfo.isSpecial:
            embed.description = f"**Card Name**: {moveInfo.name} (ID: {moveInfo.id})\n**Classification/s**: {clinfo} [Special]\n**Card Power**: {moveInfo.power}\n**Accuracy**: {moveInfo.accuracy}%\n**Energy Cost**: {moveInfo.energycost} Energy"
        else:
            embed.description = f"**Card Name**: {moveInfo.name} (ID: {moveInfo.id})\n**Classification/s**: {clinfo} [Universal]\n**Card Power**: {moveInfo.power}\n**Accuracy**: {moveInfo.accuracy}%\n**Energy Cost**: {moveInfo.energycost} Energy"

        embed.add_field(name="**Card Description**:",
                        value=f"\"{moveInfo.description}\"")
        embed.add_field(name="**Battle Effect/s**:", value=desc)

        if moveInfo.isSpecial:
            if moveInfo.originalUser != 0:
                try:
                    embed.add_field(
                        name=
                        f"**Special / Additional Effect(s)** ({await self.bot.fetch_user(moveInfo.originalUser)}):",
                        value=f"{moveInfo.originalUserDesc}")
                except discord.NotFound:
                    embed.add_field(
                        name=
                        f"**Special / Additional Effect(s)** (MissingUser#0000):",
                        value=f"{moveInfo.originalUserDesc}")

        embed.set_footer(icon_url=str(ctx.author.avatar_url),
                         text=f"Invoked by {ctx.author}")
        embed.colour = random.randint(0, 0xffffff)

        try:
            await ctx.channel.send(content=None, embed=embed)
        except discord.errors.Forbidden:
            await ctx.channel.send(
                f"{ctx.author.mention}, I am unable to send the requested data! Please grant the bot the \"Embed Links\" permission or ask an admin / moderator to do so."
            )
Esempio n. 15
0
    async def sub_mee6(self, ctx, args: Optional[str]):        
        if self.bot.noMEE6:
            await ctx.send("MEE6 Leaderboards is disabled!")
            return
        
        leaderboard = self.bot.leaderboards
        top_length = 15
            
        user_details = {}
        for page in leaderboard:
            for player in page['players']:
                if int(player['id']) == ctx.author.id:
                    user_details = player
                    
        try:
            user_level = user_details["level"]
        except:
            user_level = 0
            
        try:
            user_xp = user_details["xp"]
        except:
            user_xp = 0
        
        try:
            user_mc = user_details["message_count"]
        except:
            user_mc = 0
            
        user_name = ctx.author
        user_rank = "∅"
        user_position = 0
        user_league = "Unranked"
        
        level_range = range(100)
        xp_range = [0, 1889250]
        league = "Unranked"
        
        if user_level >= 100:
            user_league = league = "Ionosphere"
        elif user_level >= 65:
            user_league = league = "Exosphere"
        elif user_level >= 45:
            user_league = league = "Thermosphere"
        elif user_level >= 25:
            user_league = league = "Mesosphere"
        elif user_level >= 15:
            user_league = league = "Stratosphere"
        elif user_level >= 5:
            user_league = league = "Troposphere"
        else:
            user_league = league = "Unranked"
            
        user_rank = rank_prefix[league]
        
        if type(args) is str:
            try:
                if args.lower() in ["exosphere", "exo", "65"]:
                    args = "exosphere"
                elif args.lower() in ["ionosphere", "iono", "100"]:
                    args = "ionosphere"
                elif args.lower() in ["thermosphere", "thermo", "45"]:
                    args = "thermosphere"
                elif args.lower() in ["stratosphere", "strato", "15"]:
                    args = "stratosphere"
                elif args.lower() in ["mesosphere", "meso", "25"]:
                    args = "mesosphere"
                elif args.lower() in ["troposphere", "tropo", "5"]:
                    args = "troposphere"
                elif args.lower() in ["unranked", "sphere", "0"]:
                    args = "unranked"
                elif args.lower() in ["all", "unified", "global", "server", "server-wide"]:
                    args = "server-wide"
                    top_length = 10

                if args.title() != league and args in ["ionosphere", "exosphere", "thermosphere", "mesosphere", "stratosphere", "troposphere", "unranked", "server-wide"]:
                    league = args.title()
                else:
                    args = None
            except KeyError:
                args = None

        level_range = level_ranges[league]
        xp_range = xp_ranges[league]

        league_players = []
        top15_players = []
        iterate = 0

        for page in leaderboard:
            for players in page["players"]:
                if players["level"] in level_range:
                    league_players.append(players)
                        

        if len(league_players) <= 0:
            if league == "Unranked":
                await ctx.send(f"There are no members in Creosphere who are Unranked, which is practically impossible.")
            else:
                await ctx.send(f"There are no members in Creosphere who are in the {league} League.")

            return

        for player in league_players:
            if iterate >= top_length:
                break
            else:
                top15_players.append(player)
                iterate += 1
                
        embed = libneko.Embed(title = "MEE6 Leaderboards - Creosphere")
        embed.set_footer(icon_url = str(ctx.author.avatar_url), text = f"Invoked by {ctx.author}")
        embed.colour = random.randint(0, 0xffffff)
        embed.set_thumbnail(url = f"https://cdn.discordapp.com/icons/{leaderboard[0]['guild']['id']}/{leaderboard[0]['guild']['icon']}.gif?size=1024")
        value = ""

        iterate = 1
            
        if xp_range[1] == -1:
            exp_range = f"{number_format(xp_range[0])}+ XP"
        else:
            exp_range = f"{number_format(xp_range[0])} - {number_format(xp_range[1] - 1)} XP"

        for player in top15_players:
            if league == "Server-Wide":
                value += f"{get_prefix(player['level'])}-"
                
            value += f"{iterate}. **{player['username']}#{player['discriminator']}**"

            if iterate == 1:
                value += " :crown:"
            elif len(top15_players) >= 15:
                if iterate <= 3:
                    value += " :sparkles:"
                elif iterate <= 5:
                    value += " :star2:"
                elif iterate <= 7:
                    value += " :star:"
            elif len(top15_players) >= 10:
                if iterate <= 2:
                    value += " :sparkles:"
                elif iterate <= 3:
                    value += " :star2:"
                elif iterate <= 5:
                    value += " :star:"
            elif len(top15_players) >= 6:
                if iterate <= 2:
                    value += " :sparkles:"
                elif iterate <= 3:
                    value += " :star2:"
                elif iterate <= 4:
                    value += " :star:"
            elif len(top15_players) == 5:
                if iterate <= 2:
                    value += " :star2:"
                elif iterate <= 3:
                    value += " :star:"

            value += f": Level {player['level']} ({number_format(player['xp'])} XP / {number_format(player['message_count'])} Messages)\n"

            iterate += 1

        if level_range == range(0, 5):
            embed.add_field(name = f"Top {iterate - 1} -  Unranked ({exp_range}):", value = value)
        elif level_range == range(0, 2147483648):
            embed.add_field(name = f"Top {iterate - 1} -  Server-wide ({exp_range}):", value = value)
        else:
            embed.add_field(name = f"Top {iterate - 1} - {league} League ({exp_range}):", value = value)

        description = f"**Full Server Leaderboard**: [Creosphere]({leaderboard[0]['guild']['leaderboard_url']})\n\n"

        if user_league != league and league != "Server-wide":
            league_players = []
            level_range = level_ranges[user_league]

            for page in leaderboard:
                for players in page["players"]:
                    if players["level"] in level_range:
                        league_players.append(players)
                        
        try:
            user_position = league_players.index(user_details) + 1
        except:
            user_position = len(league_players) + 1

        if user_league != league and league != "Server-Wide":
            if user_league != "Unranked":
                description += f"**Your Ranking** ({user_league} League):\n{user_rank}-"
            else:
                description += f"**Your Ranking** ({user_league}):\n{user_rank}-"
        else:
            if league == "Server-Wide":
                description += f"**Your Ranking**:\n{user_rank}-"
            else:
                description += "**Your Ranking**:\n"

        if user_position == 1:
            description += f"{user_position}. **{user_name}** :crown:: Level {user_level} ({number_format(user_xp)} XP / {number_format(user_mc)} Messages)"
        else:
            description += f"{user_position}. **{user_name}**: Level {user_level} ({number_format(user_xp)} XP / {number_format(user_mc)} Messages)"
        
        embed.description = description
        
        try:
            await ctx.send(content = f"{ctx.author.mention}", embed = embed)
        except discord.errors.Forbidden:
            await ctx.send(f"{ctx.author.mention}, the bot is unable to send the requested data! Please grant the bot the \"Embed Links\" permission or ask an admin / moderator to do so.")
Esempio n. 16
0
async def on_command_error(ctx, error):
    cause = error.__cause__ if error.__cause__ else error

    if isinstance(cause, commands.CheckFailure):
        await ctx.send(embed=libneko.Embed(
            title='You don\'t have permission to run that command!'))
Esempio n. 17
0
async def on_command_error(ctx: commands.Context, error):
    if hasattr(ctx.command, "on_error"):
        return
        
    error = getattr(error, 'original', error)
        
    if isinstance(error, commands.CommandNotFound):
        message = await ctx.send(f"{ctx.author.mention}, that command is not found!")
        await message.delete(delay = 10)
    
    elif isinstance(error, commands.CommandOnCooldown):
        message = await ctx.send(f"{ctx.author.mention}, that command is on cooldown for {error.retry_after:,.0f} seconds!")
        await message.delete(delay = 10)

    elif isinstance(error, commands.DisabledCommand):
        message = await ctx.send(f"{ctx.author.mention}, that command is disabled!")
        await message.delete(delay = 10)
        
    elif isinstance(error, commands.NotOwner):
        message = await ctx.send(f"{ctx.author.mention}, you may not use that command!")
        await message.delete(delay = 10)

    elif isinstance(error, commands.MissingPermissions):
        message = await ctx.send(f"{ctx.author.mention}, you do not have the permissions necessary to invoke this command!")
        await message.delete(delay = 10)
    
    elif isinstance(error, Checks.AuthorIsBot):
        pass
    
    elif isinstance(error, Checks.NoOpusLoaded):
        message = await ctx.send(f"{ctx.author.mention}, the music module is disabled because the Opus library is not loaded!")
        await message.delete(delay = 10)
    
    elif isinstance(error, Checks.BotShuttingDown):
        await ctx.send(f"{error}")

    elif isinstance(error, Checks.UserCheckFailure):
        message = await ctx.send(f"User check failed due to: `{error}`.")
        
        if ctx.guild.id in Constants.ServerIDs:
            await message.delete(delay = 10)
        else:
            ctx.guild.leave()
    
    else:
        print(f"Ignoring exception in command {ctx.command}:", file = sys.stderr)
        traceback.print_exception(type(error), error, error.__traceback__, file = sys.stderr)
        
        embedError = libneko.Embed(title = f"Ignoring exception in command {ctx.command}:", description = "")
        embedError.color = random.randint(0x000000, 0xffffff)
        for line in traceback.TracebackException(
            type(error), error, error.__traceback__, limit = None).format(chain = True):
            embedError.description += line
        
        channel = await bot.fetch_channel(814357796035624980)
        try:
            await channel.send(content = "An error had occurred!", embed = embedError)
        except:
            await channel.send("An error had occurred! Please check the server console.")
        await ctx.send("Something went wrong! Please try again later.")
        
    return
Esempio n. 18
0
    async def cardlist(self, ctx):
        colorhex = random.randint(0, 0xffffff)

        paginatr = discordutils.Pagination.CustomEmbedPaginator(ctx)

        paginatr.add_reaction("◀", "back")
        paginatr.add_reaction("<:block:812970244222091295>", "clear")  #⏹
        paginatr.add_reaction("▶", "next")

        embeds = []

        stri = ""
        w = True
        y = 0
        z = 1
        aa = 0
        ab = 1
        max = len(cards.UniversalCards)

        pageMax = len(cards.UniversalCards) / 20
        if pageMax % 1 != 0:
            pageMax += 1

        while w:
            for x in cards.UniversalCards:
                stri += f"ID {cards.NormalCards[x].id}: **{cards.NormalCards[x].name}** (Energy Cost: {cards.NormalCards[x].energycost} Energy)\n"
                y += 1
                aa += 1

                if y == 20 or aa == max:
                    embed = libneko.Embed(
                        title="List of Cards (ascendingly sorted by IDs)")
                    embed.add_field(
                        name=f"Normal Cards (Page {z}/{int(pageMax)}): ",
                        value=stri)
                    embed.set_footer(icon_url=str(ctx.author.avatar_url),
                                     text=f"Page {ab}/{int(pageMax + 1)}")
                    embed.colour = colorhex

                    embeds.append(embed)
                    y = 0
                    z += 1
                    ab += 1
                    del embed
                    stri = ""

                if aa == max:
                    w = False
                    break
        del stri

        stri = ""
        for x in cards.SpecialCards_:
            if x == None:
                pass
            else:
                stri += f"ID {cards.SpecialCards[x].id}: **{cards.SpecialCards[x].name}** (Energy Cost: {cards.SpecialCards[x].energycost} Energy)\n"

        embed = libneko.Embed(
            title="List of Cards (ascendingly sorted by IDs)")
        embed.set_footer(icon_url=str(ctx.author.avatar_url),
                         text=f"Page {ab}/{int(pageMax + 1)}")
        embed.add_field(name="Special Cards: ", value=stri)
        embed.colour = colorhex
        embeds.append(embed)

        del stri, embed

        try:
            if random.randint(1, 100) <= 30:
                await paginatr.run(embeds)
                #await ctx.channel.send(content = random.choice(["Note: Special Cards have a 5% chance of being added to a User's deck, except for their respective Users which have their own Special Card automatically added into their hand.", "Note: Cards in each of the player's decks in battle are randomized.", "Note: The ranges of stats of a player are 20 - 200 for Attack & Defense, and 50 - 150 for Accuracy and Evasion."]), embed = embed)
            else:
                await paginatr.run(embeds)
                #await ctx.channel.send(content = None, embed = embed)
        except discord.errors.Forbidden:
            await ctx.channel.send(
                f"{ctx.author.mention}, the bot is unable to send the requested data! Please grant the bot the \"Embed Links\" permission or ask an admin / moderator to do so."
            )