Example #1
0
    async def petition(self, context):
        """Start a petition with the given title.

        People can "sign" the petition by hitting a pen reaction, adding their name to a list.

        Modifiers:
        nounsign|noundo : Disables unsigning.
        EMOJI : Replaces the pen with that emoji."""
        bot = self.bot
        q = basics.contentq(context.message.content, split=False)
        q, undo, match = basics.subcommands(context, q,
                                            ["nounsign|noundo", r".*?"])

        if match != None:
            emoji = utility.get_emoji(self.bot, match.group(1))
            if emoji == None:
                await talking.reply(
                    context, "{} isn't a valid emoji!".format(match.group(1)))
                return
        else:
            emoji = utility.get_emoji(self.bot,
                                      "<a:rolling:393641477068029953>")

        Petition(bot,
                 validfor=datetime.timedelta(minutes=60),
                 messagecount=1,
                 emoji=emoji,
                 q=q,
                 lit=await ccc.lit(context.message, binary=True),
                 context=context)
Example #2
0
def useremoji(bot, user, guild=None, default="aes", actualemoji=False):
    import modules.utility as utility

    if user.id == 114147806469554185 and not actualemoji:
        return "<a:ppixel:458887989091893248>"
    ret = utility.get_emoji(bot, "ae_" + user.name)
    if ret == None:
        emojis = list(aesthetic.get_aes_previews_nonew(bot).values())
        if default == "aes":
            ret = aesthetic.hoveremoji("ae_" + user.name,
                                       id=emojis[user.id % len(emojis)].id)
        elif default == "none":
            ret = ""
        elif default == "ping":
            ret = user.mention
    return str(ret) if not actualemoji else utility.get_emoji(bot, str(ret))
Example #3
0
    async def end(self):
        if self.ended:
            return
        self.ended = True
        await self.preend()

        self.remove_reaction_menu()
        for x in range(len(self.messages)):
            asyncio.ensure_future(self.updatemessage(x, final=True))
        l = []
        ul = []
        for uid in self.userids:
            ul.append(
                utility.get_member_or_user(self.bot,
                                           self.context.message.guild, uid))
        if ul != []:
            ul.append(
                utility.get_member_or_user(self.bot,
                                           self.context.message.guild,
                                           self.bot.me.id))

        for k in utility.nodups(
                list(self.adddict.keys()) + list(self.removedict.keys())):
            l.append([utility.get_emoji(self.bot, str(k))] + ul)

        for m in self.messages:
            await utility.safelyclear(self.bot, m, l)
Example #4
0
 async def start(self):
     await OngoingReactionMenu.start(self)
     emoji = utility.get_emoji(self.bot, "<:bn_re:362741439211503616>")
     asyncio.ensure_future(self.messages[0].add_reaction(emoji))
     self.adddict[emoji.id] = self.reroll
     await self.specificroll()
     await self.updatemessage(0)
Example #5
0
 async def input(self, m, s):
     print(1)
     d = self.reactions
     words = re.findall(r"[^ ]+", s)
     print(words)
     for w in words[:-1]:
         print(d.keys())
         for k in d.keys():
             print(k)
             if k == w or f":{w}:" in k:
                 found = k
                 break
         else:
             return
         d = d[found]["subreactions"]
     print(2)
     newemoji = utility.get_emoji(self.bot, words[-1])
     if newemoji is None:
         aesthetic.hoveremoji(words[-1])
     newemoji = str(newemoji)
     d.setdefault(newemoji, {})
     d[newemoji].setdefault("users", [])
     d[newemoji].setdefault("subreactions", {})
     d[newemoji]["users"].append(m.author.id)
     print()
     await self.updatemessage(0)
Example #6
0
 async def end(self):
     asyncio.ensure_future(
         utility.safelyclear(self.bot, self.foreignmessages[0], [[
             utility.get_emoji(self.bot,
                               "a:spinningobamatoken:394587421687152640")
         ]]))
     await OngoingReactionMenu.end(self)
Example #7
0
    async def start(self):
        await OngoingReactionMenu.start(self)
        # Arrows
        emoji = utility.get_emoji(self.bot, "<:bn_ba:328062456905728002>")
        asyncio.ensure_future(self.messages[0].add_reaction(emoji))
        self.adddict[emoji.id] = self.backpage

        emoji = utility.get_emoji(self.bot, "<:bn_fo:328724374465282049>")
        asyncio.ensure_future(self.messages[0].add_reaction(emoji))
        self.adddict[emoji.id] = self.fowardpage
        # Numbers
        for x in range(len(self.pages))[:16]:
            emoji = utility.get_emoji(self.bot, btn_num[x])
            asyncio.ensure_future(self.messages[0].add_reaction(emoji))
            self.adddict[emoji.id] = self.jumptopage
        await self.updatemessage(0)
Example #8
0
 def __init__(self,bot,**kwargs):
     OngoingReactionMenu.__init__(self,bot,**kwargs)
     # Setup
     defaults = {
         "collectors": set()
     }
     self.obamasilver = utility.get_emoji(bot, ":obamasilverpile:349449386692050944")
     DictSavable.__init__(self, defaults, kwargs, exclude=["validfor"])
Example #9
0
    async def start(self):
        await OngoingReactionMenu.start(self)

        for x in ["331164189399711767", "331164189039132673"]:
            emoji = utility.get_emoji(self.bot, x)
            asyncio.ensure_future(self.messages[0].add_reaction(emoji))
            self.adddict[emoji.id] = self.addvote
            self.removedict[emoji.id] = self.removevote
Example #10
0
def statusemoji(bot, u):
    statusn = ["online", "idle", "dnd", "offline"].index(str(u.status))
    from modules.utility import get_emoji
    return get_emoji(bot, [
        "<:status_online:353069536880361472>",
        "<:status_idle:353074751947800576>",
        "<:status_dnd:353069536884424714>",
        "<:status_offline:353069536884555776>"
    ][statusn])
Example #11
0
    async def start(self):
        await OngoingReactionMenu.start(self)

        bot = self.bot
        context = self.context
        m = context.message

        obamatoken = utility.get_emoji(
            bot, "a:spinningobamatoken:394587421687152640")
        self.adddict[obamatoken.id] = self.collect
        asyncio.ensure_future(self.foreignmessages[0].add_reaction(obamatoken))
Example #12
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
Example #13
0
def sms(bot, s):
    if s.startswith("/shrug"):
        s = s.replace("/shrug", "", 1) + " ¯\_(ツ)_/¯"
    elif s.startswith("/tableflip"):
        s = s.replace("/tableflip", "", 1) + " (╯°□°)╯︵ ┻━┻"
    elif s.startswith("/unflip"):
        s = s.replace("/unflip", "", 1) + " ┬─┬ ノ( ゜-゜ノ)"

    for e in re.findall(r"<a?:\w+:\d+>", s):
        actualemoji = get_emoji(bot, e)
        if actualemoji != None:
            s = s.replace(e, f"[ {actualemoji.name} : {actualemoji.url} ]")

    return s
Example #14
0
    async def addvote(self, payload):
        if payload.user_id in [self.suer.id, self.suee.id]:
            return
        # Remove other reaction
        if payload.emoji.name == "bn_i":
            asyncio.ensure_future(self.messages[0].remove_reaction(
                utility.get_emoji(self.bot, "331164189039132673"),
                self.bot.get_user(payload.user_id)))
            a = self.innocentlist
        if payload.emoji.name == "bn_g":
            asyncio.ensure_future(self.messages[0].remove_reaction(
                utility.get_emoji(self.bot, "331164189399711767"),
                self.bot.get_user(payload.user_id)))
            a = self.guiltylist
        # Modify list
        id = payload.user_id
        while id in self.guiltylist:
            self.guiltylist.remove(id)
        while id in self.innocentlist:
            self.innocentlist.remove(id)
        a.append(id)

        await self.updatemessage(0)
Example #15
0
    def __init__(self, bot, **kwargs):
        OngoingReactionMenu.__init__(self, bot, **kwargs)

        async def default(self, payload):
            pass

        defaults = {
            "anyscript": default,
            "singlescript": default,
            "doublescript": default,
            "timeoutscript": default,
            "startscript": default,
            "emoji": utility.get_emoji(bot, "628461134999191568"),
            "currentreactors": set(),
            "messagecount": 0,
        }
        self.userids = [self.context.message.author.id]
        DictSavable.__init__(self, defaults, kwargs, exclude=["validfor"])
Example #16
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())
Example #17
0
 def __init__(self, bot, **kwargs):
     self.guildid = kwargs["context"].message.guild.id
     self.channelid = kwargs["context"].message.channel.id
     OngoingReactionMenu.__init__(self, bot, **kwargs)
     self.btn_write = utility.get_emoji(bot, "<:bn_xat:331164192793165824>")
Example #18
0
async def say(context,string=None,embed=None,split=False,reaction=False,channel=None,file=None,viaspoilerbot=False,PIL=None,nowebhook=False,specificwebhook=None, disableaes=False):
    bot=context.bot
        
    if channel==None:
        channel=context.message.channel
        
    try:
        if [context.message.id,context.message.content] in bot.runmutemessages:
            channel=bot.testserver.get_channel("315666280185069568")
    except:
        pass
    if string!=None:
        string=await detailsaystring(context,string,disableaes=disableaes)
    if string==None:
        return await channel.send(string,embed=embed)
    elif split:
        lst = []
        buildup=""
        for x in string.split("\n"):
            ecount=0
            for y in list(unicodeemojis):
                ecount+=(buildup+x).count(y)
            if len(buildup+x+"\n")+ecount>2000 or ecount>=100:
                lst.append(await channel.send(buildup))
                buildup=""
            buildup+=x+"\n"
        lst.append(await channel.send(buildup))
        return lst
    else:
        #print("HI")
        string=trimsaystring(context,string)
        #print(len(string))
        if False and reaction and context.message.author.id in bot.confirmationroationusers and context.message not in bot.disableconfirmreactions:
            asyncio.ensure_future(sayconfirmreaction(bot,context.message,string,embed,channel))
            return
        if False and context.message in bot.disableconfirmreactions:
            bot.disableconfirmreactions.remove(context.message)
        if PIL!=None:
            if not os.path.exists("tobedeleted"):
                os.makedirs("tobedeleted")
            filename = f"tobedeleted/{context.message.channel.id}-{context.message.id}.png"
            PIL.save(filename)
            file = open(filename,"rb")
        if file==None:
            if viaspoilerbot and False:
                headers = {'Authorization': 'Bot NDUwODY3NDgzODk4MDE5ODQw.De5f3g.uPdsah3IGRr-12swwSZ_N5OeBjw'}
                headers = {'Authorization': 'Bot MzA5OTYwODYzNTI2Mjg5NDA4.DBXuJA.ijF9bk3E9JJwDG5KHyc67t3Wt18'}
                url = f'https://discordapp.com/api/channels/{channel.id}/messages'
                params = {'content': "hi",'Authorization': 'Bot MzA5OTYwODYzNTI2Mjg5NDA4.DBXuJA.ijF9bk3E9JJwDG5KHyc67t3Wt18'}
                r = requests.post(url, params=params, headers=headers)
                if r.ok:
                    print("JSON: ", r.json())
                else:
                    r.raise_for_status()
            else:
                # Send as webhook
                if not nowebhook:
                    if specificwebhook==None and context.message.author.id == 116718249567059974 and False:
                        specificwebhook = ("WHO SUMMONED ME","https://cdn.discordapp.com/attachments/315666280185069568/507424421430951936/owen.png")
                    if specificwebhook=="default":
                        print(context.guild.me.avatar_url)
                        specificwebhook = (context.guild.me.display_name, context.guild.me.avatar_url)
                if specificwebhook != None:
                    if len(specificwebhook[0])<2:
                        specificwebhook = (specificwebhook[0]+"_",specificwebhook[1])
                    webhook = None
                    for wh in await channel.webhooks():
                        if wh.name == "RSRB - Webhook":
                            webhook = wh 
                            break
                    if webhook == None:
                        with open("images/main_avatar.png","rb") as f:
                            webhook = await channel.create_webhook(name = "RSRB - Webhook", avatar=f.read())
                    # List all avaliable emojis
                    elist = []
                    for e in context.message.guild.emojis:
                        elist.append(str(e))
                    # Gather all unavaliable emojis
                    reactlist = []
                    for e in re.findall(r"<a?:[A-Za-z_]+:[0-9]+>",string):
                        if e not in elist and e in string: # if it's not in the string it's been processed already
                            string = string.replace(e,"▪")
                            e = utility.get_emoji(bot,e)
                            if e!=None:
                                reactlist.append(e)
                    await webhook.send(string,embed=embed,tts=None,username=specificwebhook[0], avatar_url=specificwebhook[1])
                    # the webhook thing doesn't return a message yet so
                    msg = None
                    for x in range(10):
                        async for m in context.message.channel.history(limit=10):
                            if m.webhook_id!=None and m.content == string:
                                msg = m
                                break
                        if msg!=None:
                            break
                    else:
                        print("f**k")
                        return
                    for e in reactlist:
                        asyncio.ensure_future(msg.add_reaction(e))
                    return msg
                    return await webhook.send(string,embed=embed,tts=None,username="******", avatar_url="https://discordapp.com/assets/f78426a064bc9dd24847519259bc42af.png")
                    return await webhook.send(string,embed=embed,tts=None,username="******", avatar_url="https://cdn.discordapp.com/avatars/439205512425504771/ed79680e6df20be63efcc708a32a3eab.webp?size=1024")
                # Send normally
                else:
                    return await channel.send(string,embed=embed,tts=None)
        # Send File
        else:
            return await channel.send(file=discord.File(file,filename=file.name.split("/")[-1]),content=string,tts=None)
Example #19
0
    async def kothnew(self, context):
        """Makes you king. Or whatever.

        The king of the hill will get an automatic crown reaction to their messages. You can also become the queen/loli/furry/cheese, based on what alias you use. Or whatever you type after the command. Use [bot] to make the bot take it. After that, you can put an emoji in brackets to get any emoji.
        You get an increasingly sexy secondary reaction as you hit 15 minutes, two hours, six hours, and 24 hours uninterupted.
        You can view the top 10 with [top], [high], or [score]. You can use [long] to view the top 500. You can view everyone's best scores with [best], [one], or [records].
        See who's currently king and for how long with [time].
        When taking the hill, whoever is already on it gets 5 seconds to say something and defend their title. If you try to take it from somebody you didn't want to take it from, if you say . before they defend, it gets canceled.
        The command has a starting cooldown of 15 seconds. When the hill is defended successfully, and the attacker isn't the king, that cooldown is increased by half a second for the next 10 minutes.
        Scores earned after koth's death have a skull next to them. You can hide all the death scores with [legacy]."""
        bot = self.bot
        m = context.message

        q = basics.contentq(context.message.content)
        q, specialemoji = basics.subcommands(context, q, ["EMOJI"])

        words = " ".join(q)
        legacy = "[legacy]" in words
        if "[bs]" in words and context.message.author.id == self.bot.rnl.id:
            self.bot.koth = copy.deepcopy(self.bot.kothlast)
            basics.save(bot,"koth")
            await talking.reply(context, "Cool.")
            return

        if "[time]" in words:
            secs = (datetime.utcnow() - self.bot.koth[4]).seconds + (
                        (datetime.utcnow() - self.bot.koth[4]).days * 24 * 60 * 60)
            mins = 0
            hours = 0
            while secs >= 60:
                mins += 1
                secs -= 60
            while mins >= 60:
                hours += 1
                mins -= 60
            await talking.reply(context,
                           "{} has been {} for the last {}, {}, and {}. If the hill was lost now, it would be worth {} pixels.".format(
                               self.bot.koth[1],
                               self.bot.koth[2],
                               ccc.pluralstr("hour", hours),
                               ccc.pluralstr("minute", mins),
                               ccc.pluralstr("second", secs),
                               koth.pixelcalc(self.bot.koth[4], datetime.utcnow()))
                           )
            return
        if "[top]" in words or "[high]" in words or "[score]" in words:
            embed = discord.Embed(title="King of the Hill Highscores", type="rich")
            high = self.bot.kothhigh[::-1][:10]
            numbers = "<:bn_1:327896448232325130> <:bn_2:327896448505217037> <:bn_3:327896452363976704> <:bn_4:327896452464508929> <:bn_5:327896454733627403> <:bn_6:327896456369274880> <:bn_7:327896458067968002> <:bn_8:327896459070537728> <:bn_9:327896459292704769> <:bn_10:327896459477385226>".split(
                " ")

            s = ""
            for x in range(0, len(high)):
                if legacy and high[x][4]:
                    continue
                u = self.bot.epicord.get_member(high[x][0])
                limit = 23
                if len(u.display_name) > limit:
                    name = u.display_name[:limit - 3] + "..."
                else:
                    name = "<@!" + high[x][0] + ">"
                if x <= 9:
                    s += numbers[x] + basics.useremoji(self.bot, high[x][0]) + name + "\n"
                else:
                    s += "`" + str(x + 1) + "`" + basics.useremoji(self.bot, high[x][0]) + name + "\n"
            embed.add_field(name="# User", value=s, inline=True)

            s = ""
            for x in high:
                if legacy and x[4]:
                    continue
                if x[2] == None:
                    emoji = "👑"
                elif len(x[2]) == 1:
                    emoji = x[2]
                else:
                    emoji = "<" + x[2] + ">"
                name = x[1]
                limit = 15
                if len(name) > limit:
                    name = name[:limit - 3] + "..."
                s += emoji + name + "\n"
            embed.add_field(name="Title", value=s, inline=True)

            s = ""
            for x in high:
                if legacy and x[4]:
                    continue
                seconds = x[3]
                emoji = "<:bl:230481089251115018>"
                if seconds > (60 * 60) * 24:
                    emoji = "<:tier4:348277627598929922>"
                elif seconds > (60 * 60) * 6:
                    emoji = "<:tier3:348279546765901826>"
                elif seconds > (60 * 60) * 2:
                    emoji = "<:tier2:348276583741521921>"
                elif seconds > 60 * 15:
                    emoji = "<:tier1:348266722526101505>"
                if x[4]:
                    emoji = "💀"
                minutes = 0
                while seconds >= 60:
                    seconds -= 60
                    minutes += 1
                hours = 0
                while minutes >= 60:
                    minutes -= 60
                    hours += 1
                minutes += round(seconds / 60, 2)
                s += emoji + str(hours) + " hours, " + str(minutes) + " min.\n"
            embed.add_field(name="Time", value=s, inline=True)

            s = "You don't have a score on this list."
            high = self.bot.kothhigh
            for x in range(0, len(high)):
                if high[x][0] == context.message.author.id:
                    s = "Your highest placement is {} out of {}.".format(len(high) - x, len(high))
            embed.set_footer(text=s)

            await mf.say(context, embed=embed)
            return
        # WOAH MAMA
        if "[long]" in words:
            numbers = "<:bn_1:327896448232325130> <:bn_2:327896448505217037> <:bn_3:327896452363976704> <:bn_4:327896452464508929> <:bn_5:327896454733627403> <:bn_6:327896456369274880> <:bn_7:327896458067968002> <:bn_8:327896459070537728> <:bn_9:327896459292704769> <:bn_10:327896459477385226>".split(
                " ")
            msg = await talking.say(context, "­")
            for n in numbers + [":bn_up:328724374540779522", ":bn_do:328724374498836500"]:
                asyncio.ensure_future(self.bot.add_reaction(msg, n.replace("<", "").replace(">", "")))
            page = 0
            while True:
                embed = discord.Embed(title="Extended King of the Hill Highscores (Page {})".format(page + 1),
                                      type="rich")
                place = 0
                names = ["# User", "Title", "Time"]
                for place in range(0 + (page * 5), 5 + (page * 5)):
                    # print("uh")
                    high = self.bot.kothhigh[::-1][(place * 10):10 + (place * 10)]
                    s = ""
                    for x in range(0, len(high)):
                        if legacy and high[x][4]:
                            continue
                        u = context.message.guild.get_member(high[x][0])
                        if u == None:
                            u = self.bot.epicord.get_member(high[x][0])
                        limit = 16
                        if len(u.display_name) > limit:
                            name = u.display_name[:limit - 3] + "…"
                        else:
                            name = "<@!" + high[x][0] + ">"
                        if x + (place * 10) <= 9:
                            s += numbers[x] + basics.useremoji(self.bot, high[x][0]) + name + "\n"
                        else:
                            s += "`" + str(x + 1 + (place * 10)) + ")`" + basics.useremoji(self.bot,
                                                                                       high[x][0]) + name + "\n"
                    embed.add_field(name=names[0], value=s, inline=True)

                    s = ""
                    for x in high:
                        if legacy and x[4]:
                            continue
                        if x[2] == None:
                            emoji = "👑"
                        elif len(x[2]) <= 10:
                            emoji = x[2]
                        else:
                            if utility.get_emoji(self.bot, x[2]) != None:
                                emoji = "<" + x[2] + ">"
                            else:
                                emoji = str(utility.get_emoji(self.bot, x[2].split(":")[1]))
                        name = x[1]
                        limit = 15
                        if len(name) > limit:
                            name = name[:limit - 3] + "…"
                        s += emoji + name + "\n"
                    embed.add_field(name=names[1], value=s, inline=True)

                    s = ""
                    for x in high:
                        if legacy and x[4]:
                            continue
                        seconds = x[3]
                        emoji = "<:bl:230481089251115018>"
                        if seconds > (60 * 60) * 24:
                            emoji = "<:tier4:348277627598929922>"
                        elif seconds > (60 * 60) * 6:
                            emoji = "<:tier3:348279546765901826>"
                        elif seconds > (60 * 60) * 2:
                            emoji = "<:tier2:348276583741521921>"
                        elif seconds > 60 * 15:
                            emoji = "<:tier1:348266722526101505>"
                        if x[4]:
                            emoji = "💀"
                        minutes = 0
                        while seconds >= 60:
                            seconds -= 60
                            minutes += 1
                        hours = 0
                        while minutes >= 60:
                            minutes -= 60
                            hours += 1
                        minutes += round(seconds / 60, 2)
                        s += emoji + str(hours) + "h, " + str(round(minutes, 2)) + "m\n"
                    embed.add_field(name=names[2], value=s, inline=True)

                    names = ["­", "­", "­"]

                s = "You don't have a score on this list."
                high = self.bot.kothhigh
                for x in range(0, len(high)):
                    if high[x][0] == context.message.author.id:
                        s = "Your highest placement is {} out of {}.".format(len(high) - x, len(high))
                embed.set_footer(text=s)

                msg = await talking.edit(context, msg, embed=embed)

                def tempcheck(reaction, user):
                    return user.id != self.bot.me.id

                rea = await self.bot.wait_for_reaction(self.bot.buttons, message=msg, check=tempcheck, timeout=120)
                if rea == None:
                    await self.bot.clear_reactions(msg)
                    break
                else:
                    await self.bot.remove_reaction(msg, rea[0].emoji, rea[1])
                    if rea[0].emoji.name == "bn_up":
                        page -= 1
                    elif rea[0].emoji.name == "bn_do":
                        page += 1
                    else:
                        page = int(rea[0].emoji.name.replace("bn_", "")) - 1
                    if page == -1:
                        page = 9
                    elif page == 10:
                        page = 0
            return
        # WOAH MAMA again
        if "[best]" in words or "[one]" in words or "[records]" in words:
            embed = discord.Embed(title="Top King of the Hill Scores For Each Player", type="rich")
            high = self.bot.kothhigh[::-1]
            numbers = "<:bn_1:327896448232325130> <:bn_2:327896448505217037> <:bn_3:327896452363976704> <:bn_4:327896452464508929> <:bn_5:327896454733627403> <:bn_6:327896456369274880> <:bn_7:327896458067968002> <:bn_8:327896459070537728> <:bn_9:327896459292704769> <:bn_10:327896459477385226>".split(
                " ")
            playersshown = []

            s = ""
            s2 = ""
            s3 = ""
            for x in range(0, len(high)):
                if legacy and high[x][4]:
                    continue
                if high[x][0] not in playersshown:
                    playersshown.append(high[x][0])
                    u = context.message.server.get_member(high[x][0])
                    if u == None:
                        u = self.bot.epicord.get_member(high[x][0])
                    limit = 16
                    name = "<@!" + high[x][0] + ">"
                    if u != None:
                        if len(u.display_name) > limit:
                            name = u.display_name[:limit - 3] + "…"
                        else:
                            name = "<@!" + high[x][0] + ">"
                    if x <= 9:
                        s += numbers[x] + basics.useremoji(self.bot, high[x][0]) + name + "\n"
                    else:
                        s += "`" + str(x + 1) + "`" + basics.useremoji(self.bot, high[x][0]) + name + "\n"

                    if high[x][2] == None:
                        emoji = "👑"
                    elif len(high[x][2]) == 1:
                        emoji = high[x][2]
                    else:
                        emoji = str(utility.get_emoji(self.bot, high[x][2].split(":")[1]))
                    name = high[x][1]
                    limit = 15
                    if len(name) > limit:
                        name = name[:limit - 3] + "…"
                    s2 += emoji + name + "\n"

                    seconds = high[x][3]
                    emoji = "<:bl:230481089251115018>"
                    if seconds > (60 * 60) * 24:
                        emoji = "<:tier4:348277627598929922>"
                    elif seconds > (60 * 60) * 6:
                        emoji = "<:tier3:348279546765901826>"
                    elif seconds > (60 * 60) * 2:
                        emoji = "<:tier2:348276583741521921>"
                    elif seconds > 60 * 15:
                        emoji = "<:tier1:348266722526101505>"
                    if high[x][4]:
                        emoji = "💀"
                    minutes = 0
                    while seconds >= 60:
                        seconds -= 60
                        minutes += 1
                    hours = 0
                    while minutes >= 60:
                        minutes -= 60
                        hours += 1
                    minutes += round(seconds / 60, 2)
                    s3 += emoji + str(hours) + " hours, " + str(minutes) + " min.\n"
            embed.add_field(name="# User", value=s[:1024], inline=True)
            embed.add_field(name="Title", value=s2[:1024], inline=True)
            embed.add_field(name="Time", value=s3[:1024], inline=True)

            s = "You don't have a score on this list."
            high = self.bot.kothhigh
            for x in range(0, len(high)):
                if high[x][0] == context.message.author.id:
                    s = "Your highest placement is {} out of {}.".format(len(high) - x, len(high))
            embed.set_footer(text=s)

            await talking.say(context, embed=embed)
            return

        if context.message.channel.id != "160197704226439168" and context.message.guild.id != self.bot.testserver.id:
            await talking.reply(context, "This only works in the bot channel.")
            return

        if context.message.author.bot:
            await talking.reply(context,
                           "Non-RSRB bots can't become king, because multiple people would be able to defend the hill.")
            return

        seconds = (datetime.utcnow() - self.bot.kothcooldown).seconds
        if m.guild.id not in self.bot.kothcooldowndict.keys():
            self.bot.kothcooldowndict[m.guild.id] = 15
        if seconds < self.bot.kothcooldowndict[m.guild.id]:
            if m.guild.id not in self.bot.kothcooldownnotovertolddict.keys():
                self.bot.kothcooldownnotovertolddict[m.guild.id] = []
            if m.author.id not in self.bot.kothcooldownnotovertolddict[m.guild.id]:
                await talking.reply(context, "Please wait, the cooldown's not over yet.")
                self.bot.kothcooldownnotovertolddict[m.guild.id].append(m.author.id)
            else:
                await self.bot.delete_message(m)
            return
        self.bot.kothcooldownnotovertolddict[m.guild.id] = []

        bot = False
        if words.startswith("[bot]"):
            bot = True
            words = words[5:]

        specialemoji = None
        if words.startswith("[") and words.count("]") != 0:
            words = words.split("]")
            specialemoji = words[0][1:].replace("<", "").replace(">", "").strip()
            errorspecialemoji = str(specialemoji)
            words = "]".join(words[1:])
            msg = await self.bot.send_message(self.bot.testserver.get_channel("329187094620667906"), "hi")
            try:
                await self.bot.add_reaction(msg, specialemoji)
            except:
                specialemoji = str(utility.get_emoji(self.bot, specialemoji)).replace("<", "").replace(">", "")
                try:
                    await self.bot.add_reaction(msg, specialemoji)
                except:
                    await talking.reply(context, "`{}` is not a valid emoji!".format(errorspecialemoji))
                    return
        if specialemoji != None:
            if "hippofrumplequest" in specialemoji:
                await talking.reply(context, "no")
                return
            if "obama" in specialemoji:
                await talking.reply(context, "no")
                return

        self.bot.kothcooldown = datetime.utcnow()

        if seconds < 15:
            await talking.reply(context, "Please wait, the cooldown's not over yet.")
            return

        seconds = (datetime.utcnow() - self.bot.kothcooldown).seconds

        u = self.bot.epicord.get_member(self.bot.koth[0])
        timestampmsg = await talking.say(context,
                                    u.mention + ": Quick! Fight off {} by saying something!\n{}: Say . if this was a mistake.".format(
                                        ccc.shownames(context.message.author), context.message.author.mention))
        statement = "doesn't defend the hill."
        if u.id != self.bot.me.id:
            def tempcheck(m):
                return m.author == u or (m.author == context.message.author and m.content == ".")

            reply = await self.bot.wait_for_message(timeout=15, author=None, channel=context.message.channel,
                                                    content=None, check=tempcheck)
            if reply != None and reply.author == context.message.author:
                await talking.reply(context, "Heh. Nice going, mate.")
                return
            statement = ""
            if reply == None:
                statement = "never defended the hill."
                # await mf.say(context,u.mention+", nice work. The hill is yours... for now.".format(mf.shownames(context.message.author)))
                # return
            else:
                seconds = (reply.timestamp - timestampmsg.timestamp).seconds
                if seconds <= 5:
                    await talking.say(context, u.mention + ", nice work. You've defended the hill with {} to spare.".format(
                        ccc.pluralstr("second", round(5 - seconds, 2))))
                    if context.message.author != u:
                        asyncio.ensure_future(mf.kothincreasecooldown(self.bot, m.guild.id))
                    return
                else:
                    statement = "attempted to defend the hill, but was late by {}.".format(
                        ccc.pluralstr("second", round(seconds - 5, 2)))

        self.bot.kothlast = copy.deepcopy(self.bot.koth)
        self.bot.kothcooldowndict[m.guild.id] = 15

        if self.bot.koth == "":
            self.bot.koth = [context.message.author.id, ccc.shownames(context.message.author), "king"]
            basics.save(bot,"koth")
        elif context.message.author.id == "238459957811478529" or context.message.author.id == "208304366719860737":
            await talking.reply(context, "F**K OFF!!!")
        elif context.message.guild != self.bot.epicord and context.message.guild != self.bot.testserver:
            await talking.reply(context, "You can't overthrow the {} in secret.".format(self.bot.koth[2]))
        else:
            if context.message.content[2] == "k":
                type = "king"
            if context.message.content[2] == "q":
                type = "queen"
            if context.message.content[2] == "l":
                type = "loli"
            if context.message.content[2] == "f":
                type = "furry"
            if context.message.content[2] == "c":
                type = "cheese"
            # if context.message.content[2]=="h":
            #    type = "hippo"
            if len(words) > 0:
                type = words.strip()

            if specialemoji != None:
                if ":markedforpinning:" in specialemoji:
                    await talking.reply(context, "F**K OFF!!!")
                    return

            # Save highscore stuff
            seconds = (datetime.utcnow() - self.bot.koth[4]).seconds
            seconds += (datetime.utcnow() - self.bot.koth[4]).days * 24 * 60 * 60
            add = [self.bot.koth[0], self.bot.koth[2], self.bot.koth[3], seconds, True]
            added = False
            rank = 0
            for x in range(0, len(self.bot.kothhigh)):
                if add[3] < self.bot.kothhigh[x][3]:
                    added = True
                    rank = x
                    self.bot.kothhigh.insert(x, add)
                    break
            if added == False:
                rank = len(self.bot.kothhigh)
                self.bot.kothhigh.append(add)
            basics.save(bot,"kothhigh")

            emoji = ""
            if seconds > (60 * 60) * 24:
                emoji = "<:tier4:348277627598929922>"
            elif seconds > (60 * 60) * 6:
                emoji = "<:tier3:348279546765901826>"
            elif seconds > (60 * 60) * 2:
                emoji = "<:tier2:348276583741521921>"
            elif seconds > 60 * 15:
                emoji = "<:tier1:348266722526101505>"
            minutes = 0
            while seconds >= 60:
                seconds -= 60
                minutes += 1
            hours = 0
            while minutes >= 60:
                minutes -= 60
                hours += 1
            minutes += round(seconds / 60, 2)
            highs = emoji + str(hours) + " hours and " + str(minutes) + " minutes"
            try:
                highs = "\n\n<@{}> lasted {}, ranking at #{}. They've earned {} pixels for a total of {}.".format(
                    self.bot.koth[0], highs, len(self.bot.kothhigh) - rank,
                    koth.pixelcalc(self.bot.koth[4], datetime.utcnow()),
                    mf.pixeledit(self.bot, self.bot.koth[0], mf.pixelcalc(self.bot.koth[4], datetime.utcnow())))
            except:
                pass

            previouskoth = list(self.bot.koth)
            if bot == False:
                await talking.reply(context,
                               "<@{}> {} As such, you've become {} of the hill, overthrowing the previous {}!".format(
                                   self.bot.koth[0], statement, type, self.bot.koth[2]) + highs)

                self.bot.koth = [context.message.author.id, ccc.shownames(context.message.author), type,
                                 specialemoji, datetime.utcnow()]
            else:
                await talking.reply(context,
                               "<@{}> {} As such, the bot has become {} of the hill, overthrowing the previous {}!".format(
                                   self.bot.koth[0], statement, type, self.bot.koth[2]) + highs)
                # await mf.reply(context,"The bot has become {} of the hill, overthrowing <@{}>, the previous {}!".format(type,self.bot.koth[0],self.bot.koth[2])+highs)
                self.bot.koth = [self.bot.me.id, ccc.shownames(context.message.guild.me), type, specialemoji,
                                 datetime.utcnow()]

            basics.save(bot,"koth")
Example #20
0
 async def start(self):
     await OngoingReactionMenu.start(self)
     # Arrows
     emoji = utility.get_emoji(self.bot, "<:bn_do:328724374498836500>")
     asyncio.ensure_future(self.messages[0].add_reaction(emoji))
     self.adddict[emoji.id] = self.confirm