Beispiel #1
0
    async def upgrade(self, ctx: commands.Context, faction=None, number=None):
        """Retrieves information of a Faction Upgrade from Not-a-Wiki"""
        if faction in ['help', 'Help'] or (faction == None and number == None):
            emoji = discord.utils.get(ctx.guild.emojis, name="SuggestionMaster")
            description = "**.upgrade <faction>**\n**Aliases: **" + ', '.join(alias["upgrade"]) + \
                          "\n\nRetrieves a Faction upgrade information " \
                          "directly from Not-a-Wiki. <faction> inputs can be using two-letter Mercenary Template with " \
                          "upgrade number, or full Faction name with an upgrade number.\n\nExamples: Fairy 7, MK10 "
            embed = discord.Embed(title=f"{emoji}  Upgrade", description=description, colour=self.color)
            return await ctx.send(embed=embed)

        # Checking if input returns an abbreviation faction i.e. FR7 or MK11, also accepts lowercase inputs
        if faction[2].isdigit() and number is None:
            faction = faction.upper()
            color = FactionUpgrades.getFactionColour(faction[0:2])

        # if number is added as an input, we automatically assume the full term, i.e. "Fairy 7"
        elif number is not None:
            # Some people just like to watch the world burn
            if int(number) < 1 or int(number) > 12:
                raise Exception("The upgrade number must be between 1 and 12, Your Majesty.")

            faction = faction.lower()
            faction = faction.capitalize()
            checks, fac, color = FactionUpgrades.getFactionAbbr(faction)

            # checks is retrieved from FactionUpgrades, if the term is not in dictionary it returns False and we
            # raise Exception error
            if checks is False:
                raise Exception("I seem to can\'t find that upgrade anywhere, Your Majesty.")
            else:
                faction = fac + number

        # if inputs match neither above, raise Exception
        else:
            raise Exception("I seem to can\'t find that upgrade anywhere, Your Majesty.")

        async with ctx.channel.typing():
            # We get our list through Not-a-Wiki Beautiful Soup search
            upgradeEmbed = NaWSearch.factionUpgrade(faction)
            author: discord.Member = ctx.author

            # Embed things, using the list retrieved from factionUpgradeSearch
            title = f'**{upgradeEmbed[1]}**'
            embed = discord.Embed(title=title, colour=discord.Colour(color), timestamp=datetime.datetime.utcnow())
            embed.set_footer(text="http://musicfamily.org/realm/FactionUpgrades/",
                             icon_url="http://musicfamily.org/realm/Factions/picks/RealmGrinderGameRL.png") \
                 .set_thumbnail(url=upgradeEmbed[0]) \
                 .set_author(name=author, icon_url=author.avatar_url)

            # Since the first two lines always are guaranteed to be an url and name of Faction upgrade, we ignore
            # them, and then start processing adding new fields for each line
            try:
                for line in upgradeEmbed[2:]:
                    line = line.split(": ")
                    embed.add_field(name=f'**{line[0]}**', value=line[1], inline=False)
            except IndexError:
                return await ctx.send('There is something wrong with this upgrade. Notify Alright#2304')

        await ctx.send(embed=embed)
Beispiel #2
0
    async def combo(self, ctx: commands.Context, faction1: str = None, faction2: str = None):
        print(type(faction1), type(faction2))
        if (faction1 in ['Help', 'help']) or (faction1 is None and faction2 is None):
            emoji = discord.utils.get(ctx.guild.emojis, name="SuggestionMaster")
            description = "**.combo <faction1> <faction2>**\n**Aliases: **" + ', '.join(alias["combo"]) + \
                          "\n\nRetrieves the Legacy Combo info from the wiki. " \
                          "<faction> inputs can be using two-letter Mercenary Template or the full Faction name. " \
                          "\n\nExamples: .combo Fairy Demon, .lc UD EL"
            embed = discord.Embed(title=f"{emoji} Legacy Combo", description=description, colour=self.color)
            return await ctx.send(embed=embed)

        if len(faction1) == 2:
            faction1 = faction1.upper()
        else:
            check1, faction1, ignore1 = FactionUpgrades.getFactionAbbr(faction1.capitalize())

        if len(faction2) == 2:
            faction2 = faction2.upper()
        else:
            check2, faction2, ignore2 = FactionUpgrades.getFactionAbbr(faction2.capitalize())

        print(faction1, faction2)

        if not faction1 or not faction2 or faction1 == faction2:
            raise Exception("Invalid User Input")

        async with ctx.channel.typing():
            legacyEmbed = NaWSearch.legacyCombo(faction1, faction2)
            author: discord.Member = ctx.message.author
            color = discord.Colour.dark_green()

            embed = discord.Embed(title=legacyEmbed[1], colour=color) \
                .set_footer(text="http://musicfamily.org/realm/Legacies/",
                            icon_url="http://musicfamily.org/realm/Factions/picks/RealmGrinderGameRL.png") \
                .set_author(name=author, icon_url=author.avatar_url) \
                .set_thumbnail(url=legacyEmbed[0])

            for line in legacyEmbed[2:]:
                try:
                    line = line.split(": ", maxsplit = 1)
                    embed.add_field(name=f'**{line[0]}**', value=line[1], inline=False)
                except Exception as e:
                    print(e)

        await ctx.send(embed=embed)
Beispiel #3
0
    async def challenge(self, ctx: commands.Context, faction=None, number=None):
        """Retrieves information of a Faction Challenge from Not-a-Wiki"""
        # Help command
        if faction in ['help', 'Help'] or (faction == None and number == None):
            emoji = discord.utils.get(ctx.guild.emojis, name="SuggestionMaster")
            description = "**.challenge <faction>**\n**Aliases: **" + ', '.join(alias["challenge"]) + "\n\nRetrieves " \
                          "challenge info from Not-a-Wiki displaying name, requirements, effects, and formulas. Valid " \
                          "inputs include using faction name and the challenge number, or r for spell challenge " \
                          "reward. Mercenary templates in place of full name can be used, adding C# or \"R\".\n\nExample: " \
                          "Fairy 2, Makers r, DGC5, DJR"
            embed = discord.Embed(title=f"{emoji}  Challenge", description=description,
                                  colour=self.color)
            return await ctx.send(embed=embed)

        # Too many people call Mercenary "merc" so this is to make it easier
        if faction in ["merc", "Merc"]:
            faction = "Mercenary"

        # Checking if input returns an abbreviation faction i.e. FR2 or MK5, also accepts lowercase inputs
        if faction[2].isdigit() or faction[2] in ["R", "r", "C", "c"] and number is None:
            if faction[2] in ["C", "c"]:
                faction = faction[:2] + faction[3:]
            faction = faction.upper()
            factionColor = faction[0:2]
            color = FactionUpgrades.getFactionColour(factionColor)
            # No huge dictionary this time around
            faction2 = FactionUpgrades.getFactionNameFull(factionColor)
            faction = faction2 + faction[0] + "C" + faction[2:]

        # if number is added as an input, we automatically assume the full term, i.e. "Fairy 7"
        elif number is not None:
            # Number checker has been moved to factionChallengeSearch()
            faction = faction.lower()
            faction = faction.capitalize()
            checks, fac, color = FactionUpgrades.getFactionAbbr(faction)

            # checks is retrieved from FactionUpgrades, if the term is not in dictionary it returns False and we
            # raise Exception error
            if checks is False:
                raise Exception('Invalid Input')
            else:
                faction = faction + faction[0] + "C" + str(number).upper()

        # if inputs match neither above, raise Exception
        else:
            raise Exception('Invalid Input')

        async with ctx.channel.typing():
            challengeEmbed = NaWSearch.challenge(faction)
            author: discord.Member = ctx.message.author

            embed = discord.Embed(title=f'**{challengeEmbed[1]}**', colour=discord.Colour(color), timestamp=datetime.datetime.utcnow()) \
                .set_footer(text="http://musicfamily.org/realm/Challenges/",
                            icon_url="http://musicfamily.org/realm/Factions/picks/RealmGrinderGameRL.png") \
                .set_thumbnail(url=challengeEmbed[0]) \
                .set_author(name=author, icon_url=author.avatar_url)

            if faction == "MercenaryMCR":
                return await ctx.send(
                    'This challenge reward is disabled for a bit due to the embed being too large. See: http://musicfamily.org/realm/Challenges/')

            # Ignore the first 4 fields and create the rest
            for line in challengeEmbed[2:]:
                newline = line.split(": ")
                embed.add_field(name=f'**{newline[0]}**', value=newline[1], inline=False)

        await ctx.send(embed=embed)
Beispiel #4
0
    async def challenge(self, ctx, arg=None, number=None):
        """Retrieves information of a Faction Challenge from Not-a-Wiki"""
        global color
        global faction

        # Help panel in case of no input
        if (arg is None and number is None) or (arg == "help"
                                                and number is None):
            emoji = discord.utils.get(ctx.guild.emojis,
                                      name="SuggestionMaster")
            description = "**.challenge <faction>**\n**Aliases: **" + ', '.join(alias["challenge"]) + "\n\nRetrieves " \
                        "challenge info from Not-a-Wiki displaying name, requirements, effects, and formulas. Valid " \
                        "inputs include using faction name and the challenge number, or r for spell challenge " \
                        "reward.\n\nExample: Fairy 2, Makers r"
            embed = discord.Embed(title=f"{emoji}  Challenge",
                                  description=description,
                                  colour=discord.Colour.dark_gold())
            return await ctx.send(embed=embed)

        # Checking if input returns an abbreviation faction i.e. FR2 or MK5, also accepts lowercase inputs
        if arg[2].isdigit() or arg[2] in ["R", "r", "C", "c"
                                          ] and number is None:
            if arg[2] in ["C", "c"]:
                arg = arg[:2] + arg[3:]
            faction = arg.upper()
            argColor = faction[0:2]
            color = FactionUpgrades.getFactionColour(argColor)
            # No huge dictionary this time around
            faction2 = FactionUpgrades.getFactionNameFull(argColor)

            faction = faction2 + faction[0] + "C" + faction[2:]

        # if number is added as an input, we automatically assume the full term, i.e. "Fairy 7"
        elif number is not None:
            # Number checker has been moved to factionChallengeSearch()
            arg2 = arg.lower()
            arg2 = arg2.capitalize()
            checks, fac, color = FactionUpgrades.getFactionAbbr(arg2)

            # checks is retrieved from FactionUpgrades, if the term is not in dictionary it returns False and we
            # raise Exception error
            if checks is False:
                raise Exception('Invalid Input')
            else:
                faction = arg2 + arg2[0] + "C" + str(number).upper()

        # if inputs match neither above, raise Exception
        else:
            raise Exception('Invalid Input')

        async with ctx.channel.typing():
            # We get our list through Not-a-Wiki Beautiful Soup search
            # factionChallengeSearch takes parameters like "FairyFC1" or "FacelessFC1" (note the similar last 3 characters)
            data = factionChallengeSearch(faction)

            ignore = 4

            # Embed things, using the list retrieved from factionChallengeSearch
            thumbnail = data[0]
            # Spell rewards need special formatting
            if faction[-1:] == "R":
                title = f'**{data[1]}**'
                ignore = 3
            else:
                title = f'**{data[2]} : {data[1]}**'
            embed = discord.Embed(title=title,
                                  colour=discord.Colour(color),
                                  timestamp=datetime.datetime.utcnow())
            embed.set_footer(
                text="http://musicfamily.org/realm/Challenges/",
                icon_url=
                "http://musicfamily.org/realm/Factions/picks/RealmGrinderGameRL.png"
            )
            embed.set_thumbnail(url=thumbnail)

            # Ignore the first 4 fields and create the rest
            for line in data[ignore:]:
                newline = line.split(": ")
                first = f'**{newline[0]}**'
                embed.add_field(name=first, value=newline[1], inline=True)

        await ctx.send(embed=embed)
Beispiel #5
0
    async def upgrade(self, ctx, arg=None, number=None):
        """Retrieves information of a Faction Upgrade from Not-a-Wiki"""
        global color
        global faction

        # basic Help command
        if (arg is None and number is None) or (arg == "help"
                                                and number is None):
            emoji = discord.utils.get(ctx.guild.emojis,
                                      name="SuggestionMaster")
            description = "**.upgrade <faction>**\n**Aliases: **" + ', '.join(alias["upgrade"]) + \
                          "\n\nRetrieves a Faction upgrade information " \
                          "directly from Not-a-Wiki. <faction> inputs can be using two-letter Mercenary Template with " \
                          "upgrade number, or full Faction name with an upgrade number.\n\nExamples: Fairy 7, MK10 "
            embed = discord.Embed(title=f"{emoji}  Upgrade",
                                  description=description,
                                  colour=discord.Colour.dark_gold())
            return await ctx.send(embed=embed)

        # Checking if input returns an abbreviation faction i.e. FR7 or MK11, also accepts lowercase inputs
        if arg[2].isdigit() and number is None:
            faction = arg.upper()
            argColor = faction[0:2]
            color = FactionUpgrades.getFactionColour(argColor)

        # if number is added as an input, we automatically assume the full term, i.e. "Fairy 7"
        elif number is not None:
            # Some people just like to watch the world burn
            if int(number) < 0 or int(number) > 12:
                raise Exception('Invalid Input')

            arg2 = arg.lower()
            arg2 = arg2.capitalize()
            checks, fac, color = FactionUpgrades.getFactionAbbr(arg2)

            # checks is retrieved from FactionUpgrades, if the term is not in dictionary it returns False and we
            # raise Exception error
            if checks is False:
                raise Exception('Invalid Input')
            else:
                faction = fac + number

        # if inputs match neither above, raise Exception
        else:
            raise Exception('Invalid Input')

        async with ctx.channel.typing():
            # We get our list through Not-a-Wiki Beautiful Soup search
            data = factionUpgradeSearch(faction)

            # Embed things, using the list retrieved from factionUpgradeSearch
            thumbnail = data[0]
            title = f'**{data[1]}**'
            embed = discord.Embed(title=title,
                                  colour=discord.Colour(color),
                                  timestamp=datetime.datetime.utcnow())
            embed.set_footer(
                text="http://musicfamily.org/realm/FactionUpgrades/",
                icon_url=
                "http://musicfamily.org/realm/Factions/picks/RealmGrinderGameRL.png"
            )
            embed.set_thumbnail(url=thumbnail)

            # Since the first two lines always are guaranteed to be an url and name of Faction upgrade, we ignore
            # them, and then start processing adding new fields for each line
            for line in data[2:]:
                newline = line.split(": ")
                first = f'**{newline[0]}**'
                embed.add_field(name=first, value=newline[1], inline=True)

        await ctx.send(embed=embed)