Exemplo n.º 1
0
    async def ach_display(bot, user, channel, index):
        achievements = AchievementBrowser.getachievements()
        index = achievements[index]
        embed = discord.Embed(title="**__Achievement Unlocked!__**")

        s = ""
        for x in index["reward"]:
            if x[0] == "clothing":
                s += "\n{} (equip with `s!ch {}`)".format(x[1], x[1])
                server = "global" if index["global"] else channel.guild.id
                bot.hippoclothing.setdefault(server, {})
                bot.hippoclothing[server].setdefault(user.id, set())
                bot.hippoclothing[server][user.id].add(x[1])
                basics.save(bot, "hippoclothing")
            if x[0] == "ot":
                oooooo = ot.otedit(bot, user, x[1], True, channel=channel)
                s += "\n{} Obama Tokens (total is now {})".format(x[1], oooooo)
            if x[0] == "en":
                s += "\nEvernick Character Discount"
        if s != "":
            # embed.set_footer(text="Rewards:\n"+s)
            s = "\n\nRewards:" + s

        embed.add_field(name="{} **{}**".format(index["icon"], index["name"]),
                        value=index["desc"] + s,
                        inline=False)

        if index["secret"]:
            embed.set_footer(
                text=
                "Because of the ease of obtaining this achievement, it's more valuable as a surprise than a challenge. Keep its requirements to yourself."
            )
            await user.send(embed=embed)
            # await asyncio.sleep(random.randint(60*2,60*5))

            # ADD A DAILY POST ANNOUNCEMENT

            # main = bot.epicord.get_channel("112760669178241024")
            # for x in range(random.randint(200, 1000)):
            #     await bot.wait_for_message(channel=main)
            # embed = discord.Embed(title="**__Achievement Unlocked!__**")
            # embed.add_field(name="❔ **???**", value="???", inline=False)
            # await talking.say(main, content=ccc.repuser(bot, user), embed=embed, tts=bot.tts)
        else:
            embed.set_footer(text="Use s!ach to see all achievements.")
            await channel.send(user.mention, embed=embed)
        # Achievements for getting achiemenets
        info = []
        for n, i in enumerate(achievements):
            server = "global" if i["global"] else user.guild.id
            if n not in bot.ach_tracking[server][user.id].keys():
                bot.ach_tracking[server][user.id][n] = []
                for x in range(0, len(achievements[n][3])):
                    bot.ach_tracking[server][user.id][n].append(False)
            info.append(bot.ach_tracking[server][user.id][n])
            await AchievementBrowser.ach_check(bot, user, channel, "ach", info)
Exemplo n.º 2
0
    async def preend(self):
        if self.collectors:
            bot = self.bot
            context = self.context
            m = context.message

            asyncio.ensure_future(utility.safelyclear(self.bot, self.foreignmessages[0], [[self.obamasilver]]))

            fullcollectors = set()
            for u in self.collectors:
                fullcollectors.add(self.context.message.guild.get_member(u))

            names = ""
            for u in fullcollectors:
                names += f"{ccc.shownames(self.bot, u)}\n"
                ot.otedit(bot, u, 0.2, True, channel=m.channel, type="silver", extras=
                {
                    "collectors": fullcollectors,
                    "allthesame": all(qwerty.display_name == next(iter(fullcollectors)).display_name for qwerty in fullcollectors)
                })
            s = f"<:obamasilver:349436656236888066> The following users have collected from the pile of Obama Silver and got 0.2 Obama Tokens:\n{names}"
            await talking.say(self.context, aesthetic.indentlist(s))
Exemplo n.º 3
0
 async def runscript(self, payload):
     if payload.emoji.name == "bn_yes":
         if self.cost != 0 and ot.otedit(
                 self.bot,
                 self.context.message.author,
                 0,
                 False,
                 channel=self.context.message.channel) < self.cost:
             self.message = f"You no longer have the {ccc.pluralstr('Obama Token',self.cost)} required to do this."
         else:
             await self.yesscript(self)
     elif payload.emoji.name == "bn_no":
         await self.noscipt(self)
     await self.end()
Exemplo n.º 4
0
 async def givetoken(self, payload):
     self.disableinputs = True
     self.personpicked = self.edict[payload.emoji.id]
     otedit(self.bot,
            self.personpicked,
            1,
            True,
            channel=self.messages[0].channel,
            type="daily")
     await talking.reply(
         self.context,
         f"You've given a token to {self.personpicked.mention}.",
         channel=self.messages[0].channel)
     await AchievementBrowser.ach_check(self.bot,
                                        self.context.message.author,
                                        self.context.message.channel,
                                        "daily", [self.personpicked])
     print(self.personpicked)
     print(self.context.message.author)
     await AchievementBrowser.ach_check(self.bot, self.personpicked,
                                        self.context.message.channel,
                                        "dailyrecieved",
                                        [self.context.message.author])
     await self.end()
Exemplo n.º 5
0
    def __init__(self, bot, **kwargs):
        OngoingReactionMenu.__init__(self, bot, **kwargs)

        # Setup
        if random.randint(1, 100) == 1:
            btn_yes = utility.get_emoji(bot, "<:upstinky:288858540888686602>")
            btn_no = utility.get_emoji(bot, "<:downstinky:288858539332599808>")
        else:
            btn_yes = utility.get_emoji(bot, "<:bn_yes:331164192864206848>")
            btn_no = utility.get_emoji(bot, "<:bn_no:331164190284972034>")

        async def default(self):
            pass

        async def defaultno(self):
            self.message = 'THEN DIE'

        defaults = {
            "message": "Hit YES to confirm. Hit NO to uh, die.",
            "yesscript": default,
            "noscipt": defaultno,
            "timeoutscript": default,
            "btn_yes": btn_yes,
            "btn_no": btn_no,
            "cost": 0
        }
        self.userids = [self.context.message.author.id]
        DictSavable.__init__(self, defaults, kwargs, exclude=["validfor"])

        # Remove if broke
        ots = ot.otedit(self.bot,
                        self.context.message.author,
                        0,
                        False,
                        channel=self.context.message.channel)
        if ots < self.cost:
            self.message = f"You need {ccc.pluralstr('Obama Token', self.cost)} to do this, but you only have {ots}."
            asyncio.ensure_future(self.end())
            return
Exemplo n.º 6
0
        async def SAVETODICT_give(self):
            bot = self.bot
            gifter = self.gifter
            giftee = self.giftee
            value = self.cost

            giftertokens = ot.otedit(self.bot,
                                     gifter,
                                     0,
                                     False,
                                     channel=context.message.channel)
            gifteetokens = ot.otedit(self.bot,
                                     giftee,
                                     0,
                                     False,
                                     channel=context.message.channel)

            ot.otedit(self.bot,
                      gifter,
                      -value,
                      False,
                      channel=context.message.channel)
            ot.otedit(self.bot,
                      giftee,
                      value,
                      False,
                      channel=context.message.channel)

            self.message = "You've given `{}` Obama Token{} to {}.\n\n{}'s Tokens:\n{} ➔ {}\n\n{}'s Tokens:\n{} ➔ {}".format(
                value, ["", "s"][value != 1], basics.truename(bot, giftee),
                basics.truename(bot, gifter), giftertokens,
                round(giftertokens - value, 2), basics.truename(bot, giftee),
                gifteetokens, round(gifteetokens + value, 2))
            await AchievementBrowser.ach_check(bot, gifter,
                                               self.context.message.channel,
                                               "give", {
                                                   "giftee": giftee,
                                                   "value": value
                                               })
Exemplo n.º 7
0
    async def collect(self, payload):
        bot = self.bot
        context = self.context
        m = context.message
        u = m.guild.get_member(payload.user_id)
        tokeninfo = f"Spawn Message ID; {context.message.id}"
        if u.bot:
            return

        self.disrespectcount.setdefault(u.id, 0)
        if payload.emoji.is_unicode_emoji(
        ) or payload.emoji.id != 394587421687152640:
            self.disrespectcount[u.id] += 1
            return
        tokeninfo += f"\nDisrespect Count; {self.disrespectcount[u.id]}"
        self.disableinputs = True
        recentspeaker = False

        timestr = '%Y/%m/%d  %I:%M:%S %p'
        uh = datetime.utcnow() - timedelta(seconds=30)
        if m.created_at <= uh and m.author.id != u.id and not m.author.bot:
            recentspeaker = True
            tokeninfo += f"\nRecent Speaker Message ID; {m.id}\nRecent Speaker Message Timestamp; {m.created_at.strftime(timestr)}"
        else:
            async for msg in m.channel.history(limit=60,
                                               oldest_first=False,
                                               before=m):
                recentspeaker = False
                if msg.created_at <= uh:
                    break
                if msg.author.id != u.id and not msg.author.bot:
                    recentspeaker = True
                    tokeninfo += f"\nRecent Speaker Message ID; {m.id}\nRecent Speaker Message Timestamp; {m.created_at.strftime(timestr)}"
                    break
        tokeninfo += f"\nCollected At; {uh.strftime(timestr)}"

        self.bot.dripfeedmonth.setdefault(m.guild.id, "None")
        month = str(datetime.utcnow().strftime("%Y-%m"))
        try:
            dripfeed = self.bot.dripfeedmonth[
                m.guild.id] != month and not self.bot.ach_tracking[m.guild.id][
                    u.id][74][0]
        except:
            dripfeed = self.bot.dripfeedmonth[m.guild.id] != month
        if dripfeed:
            self.bot.dripfeedmonth[m.guild.id] = month
            basics.save(self.bot, "dripfeedmonth")

        tokens = ot.otedit(bot,
                           u,
                           1,
                           True,
                           channel=m.channel,
                           type="gold",
                           extras={
                               "disrespectcount": self.disrespectcount[u.id],
                               "recentspeaker": recentspeaker,
                               "delayed": self.delayed,
                               "dripfeed": dripfeed
                           })
        bot.preresiduecount.setdefault("gold", {})
        bot.preresiduecount["gold"].setdefault(u.id, 5)

        if bot.preresiduecount["gold"][u.id] > 0:
            bot.preresiduecount["gold"][u.id] -= 1
            await talking.say(
                context, "<:obamatoken:349037437827284992> " +
                await talking.replystring(
                    context,
                    "You got an Obama Token! You now have a total of {}. {}\n{} will be shown this message {} before it gets replaced with an Obama Residue."
                    .format(
                        tokens, aesthetic.hoveremoji(tokeninfo.replace(
                            ";", "")), basics.truename(bot, u),
                        ccc.pluralstr("more time",
                                      bot.preresiduecount["gold"][u.id])),
                    user=u))
            basics.save(bot, "preresiduecount")
        else:
            await utility.safelyclear(
                bot, context.message,
                [[utility.get_emoji(bot, "349037437827284992")]]
            )  # Prevents end() from removing the residue

            ObamaResidue(
                bot,
                validfor=timedelta(minutes=60),
                emoji=utility.get_emoji(bot, "653859091331940355"),
                otheremojis=[basics.useremoji(self.bot, u)] +
                utility.reactiontext(str(tokens)),
                info=
                f"{u.mention} got an Obama Token. They now have a total of {tokens}.\n>>> {tokeninfo.replace(';', ':').replace('  ',' ')}",
                context=context)

            await asyncio.sleep(1)  # Prevents end() from removing the residue

        asyncio.ensure_future(self.end())
Exemplo n.º 8
0
    async def obamaresidue(self, context):
        """Shows how much Obama Residue you have. Mention somebody to check how much they have instead.

        Modifiers:
        all|max|now|top|list : Displays a chart of server-wide residue counts."""
        q = basics.contentq(context.message.content, split=False)
        q, max = basics.subcommands(context, q, [r"all|max|now|top|list"])
        bot = self.bot

        ot.otedit(self.bot,
                  context.message.author,
                  0,
                  False,
                  channel=context.message.channel)
        if max is not None:
            l = [["User", "Max", "Now", "Me", "Mentioned"]]
            for k in self.bot.obamaresidue[context.message.guild.id].keys():
                k = context.message.guild.get_member(k)
                if k is None:
                    continue
                ot.otedit(self.bot,
                          k,
                          0,
                          False,
                          channel=context.message.channel)
                if k != None:
                    l.append([
                        basics.truename(bot, k),
                        round(
                            self.bot.obamaresiduemax[context.message.guild.id][
                                k.id] / 1000, 3),
                        round(
                            self.bot.obamaresidue[context.message.guild.id][
                                k.id] / 1000,
                            3), k.id == context.message.author.id, k
                        in context.message.mentions
                    ])

            SortableChart(bot,
                          lol=l,
                          validfor=timedelta(minutes=5),
                          context=context,
                          initialsort=[4, 1, 2, 3, 5],
                          addnumbers=True,
                          resetnumbers={2, 3},
                          defaultreverse={2, 3, 4, 5})

            return
        target = context.message.author
        if len(context.message.mentions) > 0:
            target = context.message.mentions[0]
            ot.otedit(self.bot,
                      target,
                      0,
                      False,
                      channel=context.message.channel)

        if target == context.message.author:
            targetstr = "You currently have"
            targetstr2 = "Your"
        else:
            targetstr = "{} currently has".format(ccc.shownames(bot, target))
            targetstr2 = "Their"
        await talking.reply(
            context, "{} {} Obama Residue. {} all-time count is {}.".format(
                targetstr,
                round(self.bot.obamaresidue[target.guild.id][target.id] / 1000,
                      3), targetstr2,
                round(
                    self.bot.obamaresiduemax[target.guild.id][target.id] /
                    1000, 3)))
Exemplo n.º 9
0
    async def give(self, context):
        """Gives x Obama Tokens to the mentioned user."""
        async def SAVETODICT_give(self):
            bot = self.bot
            gifter = self.gifter
            giftee = self.giftee
            value = self.cost

            giftertokens = ot.otedit(self.bot,
                                     gifter,
                                     0,
                                     False,
                                     channel=context.message.channel)
            gifteetokens = ot.otedit(self.bot,
                                     giftee,
                                     0,
                                     False,
                                     channel=context.message.channel)

            ot.otedit(self.bot,
                      gifter,
                      -value,
                      False,
                      channel=context.message.channel)
            ot.otedit(self.bot,
                      giftee,
                      value,
                      False,
                      channel=context.message.channel)

            self.message = "You've given `{}` Obama Token{} to {}.\n\n{}'s Tokens:\n{} ➔ {}\n\n{}'s Tokens:\n{} ➔ {}".format(
                value, ["", "s"][value != 1], basics.truename(bot, giftee),
                basics.truename(bot, gifter), giftertokens,
                round(giftertokens - value, 2), basics.truename(bot, giftee),
                gifteetokens, round(gifteetokens + value, 2))
            await AchievementBrowser.ach_check(bot, gifter,
                                               self.context.message.channel,
                                               "give", {
                                                   "giftee": giftee,
                                                   "value": value
                                               })

        ammount = basics.contentq(context.message.content)
        bot = self.bot
        value = re.sub("[^0-9\.]", "",
                       re.sub("<@!?[0-9]{18}>", "", " ".join(ammount)))
        gifter = context.message.author
        giftertokens = ot.otedit(self.bot,
                                 gifter,
                                 0,
                                 True,
                                 channel=context.message.channel)

        if len(value) == 0:
            await talking.reply(context, "Please give a value!")
            return
        value = round(float(value), 2)
        if len(context.message.mentions) == 0:
            await talking.reply(context, "Please mention someone!")
            return
        if context.message.mentions[0] == gifter:
            await talking.reply(context,
                                "You can't give Obama Tokens to yourself!")
            return

        giftee = context.message.mentions[0]
        gifteetokens = ot.otedit(self.bot,
                                 giftee,
                                 0,
                                 True,
                                 channel=context.message.channel)
        message = "Are you sure you want to give `{}` Obama Token{} to {}?\n\n{}'s Tokens:\n{} ➔ {}\n\n{}'s Tokens:\n{} ➔ {}".format(
            value, ["", "s"][value != 1], basics.truename(bot, giftee),
            basics.truename(bot, gifter), giftertokens,
            round(giftertokens - value, 2), basics.truename(bot, giftee),
            gifteetokens, round(gifteetokens + value, 2))

        ConfirmMessage(bot,
                       validfor=timedelta(minutes=5),
                       message=message,
                       gifter=gifter,
                       giftee=giftee,
                       cost=value,
                       yesscript=SAVETODICT_give,
                       context=context)
Exemplo n.º 10
0
    async def obamatokens(self, context):
        """Shows how many Obama Tokens you have. Mention somebody to check how much they have instead.

        Use [all] to see how many everyone has and their maxes, sorted by their maxes. Use [now] to sort by how many they have instead. Use [visual] to see it in emojis."""
        q = basics.contentq(context.message.content)
        bot = self.bot

        ot.otedit(self.bot,
                  context.message.author,
                  0,
                  False,
                  channel=context.message.channel)
        if "[all]" in " ".join(q) or "[now]" in " ".join(
                q) or "[top]" in " ".join(q) or "[max]" in " ".join(q):
            l = [["User", "Max", "Now", "Given", "Me", "Mentioned"]]
            for k in self.bot.obamatokens[context.message.guild.id].keys():
                k = context.message.guild.get_member(k)
                if k is None:
                    continue
                ot.otedit(self.bot,
                          k,
                          0,
                          False,
                          channel=context.message.channel)
                if k != None:
                    l.append([
                        basics.truename(bot, k),
                        float(self.bot.obamatokensmax[context.message.guild.id]
                              [k.id]),
                        float(self.bot.obamatokens[context.message.guild.id][
                            k.id]),
                        float(self.bot.obamatokensgiven[
                            context.message.guild.id][k.id]),
                        k.id == context.message.author.id, k
                        in context.message.mentions
                    ])

            # charlst = [["User", "Max", "Now", "Given", "Me","Mentioned"]]
            # for n, x in enumerate(l):
            #     max = str(x[0])
            #     if "." not in max:
            #         max += "."
            #     while list(max).index(".") > len(max) - 3:
            #         max += "0"
            #
            #     now = str(x[2])
            #     if "." not in now:
            #         now += "."
            #     while list(now).index(".") > len(now) - 3:
            #         now += "0"
            #     charlst.append([x[1], max, now, x[3], x[4], x[5]])

            SortableChart(bot,
                          validfor=timedelta(minutes=5),
                          context=context,
                          lol=l,
                          initialsort=[5, 1, 4, 2, 3, 6],
                          addnumbers=True,
                          resetnumbers={2, 3, 4},
                          defaultreverse={2, 3, 4, 5, 6})

            return
        target = context.message.author
        if len(context.message.mentions) > 0:
            target = context.message.mentions[0]
            ot.otedit(self.bot,
                      target,
                      0,
                      False,
                      channel=context.message.channel)
        if "[visual]" in " ".join(q):
            if target == context.message.author:
                targetstr = "Your"
            else:
                targetstr = "{}'s".format(shownames(target))
            await talking.saysplit(
                self,
                "{} current Obama Tokens:\n{}\n\n{} all-time Obama Tokens:\n{}"
                .format(
                    targetstr,
                    ot.visualtokens(self.bot.obamatokens[target.id] / 0.04),
                    targetstr,
                    ot.visualtokens(self.bot.obamatokensmax[target.id] /
                                    0.04)), [">"])
        else:
            if target == context.message.author:
                targetstr = "You currently have"
                targetstr2 = "Your"
            else:
                targetstr = "{} currently has".format(mf.shownames(target))
                targetstr2 = "Their".format(mf.shownames(target))
            await talking.reply(
                context,
                "{} {} Obama Tokens, {} of which were given. {} all-time count is {}."
                .format(targetstr,
                        self.bot.obamatokens[target.guild.id][target.id],
                        self.bot.obamatokensgiven[target.guild.id][target.id],
                        targetstr2,
                        self.bot.obamatokensmax[target.guild.id][target.id]))