예제 #1
0
 async def speedrunwr(self, ctx):
     await ctx.send("Getting speedrun.com data. Please wait...")
     try:
         e = Embed(description="https://www.speedrun.com/mc")
         e.set_author(
             name="Minecraft Speedrun World Records - Solo Any% Glitchless",
             icon_url=
             "https://cdn.discordapp.com/attachments/771698457391136798/842103816761114624/mc.png"
         )
         urls = [
             "klrzpjo1&var-wl33kewl=gq7zo9p1",
             "klrzpjo1&var-wl33kewl=21go6e6q",
             "klrzpjo1&var-wl33kewl=4qye4731",
             "21d4zvp1&var-wl33kewl=gq7zo9p1",
             "21d4zvp1&var-wl33kewl=21go6e6q",
             "21d4zvp1&var-wl33kewl=4qye4731"
         ]
         categories = [
             "Set Seed Glitchless (Pre-1.9)",
             "Set Seed Glitchless (1.9-1.15)",
             "Set Seed Glitchless (1.16+)",
             "Random Seed Glitchless (Pre-1.9)",
             "Random Seed Glitchless (1.9-1.15)",
             "Random Seed Glitchless (1.16+)"
         ]
         count = 0
         for category in urls:
             res = await funcs.getRequest(
                 "https://www.speedrun.com/api/v1/leaderboards/j1npme6p/category/mkeyl926?var-r8rg67rn="
                 + category)
             wrdata = res.json()["data"]["runs"][0]["run"]
             igt = wrdata["times"]["ingame_t"]
             res = await funcs.getRequest(wrdata["players"][0]["uri"])
             runner = res.json()["data"]["names"]["international"]
             h, m, s, ms = funcs.timeDifferenceStr(igt, 0, noStr=True)
             e.add_field(name=categories[count], inline=False,
                         value=f"`{h if h != 0 else ''}{'h ' if h != 0 else ''}{m}m {s}s " + \
                         f"{ms if ms != 0 else ''}{'ms ' if ms != 0 else ''}({runner})`")
             count += 1
         e.set_footer(
             text="Click the link above for more speedrun categories.",
             icon_url=
             "https://cdn.discordapp.com/attachments/771698457391136798/842103813585240124/src.png"
         )
     except Exception as ex:
         funcs.printError(ctx, ex)
         e = funcs.errorEmbed(None, "Possible server error.")
     await ctx.reply(embed=e)
예제 #2
0
 async def findseed(self, ctx):
     eyes = self.randomEyes()
     data = funcs.readJson("data/findseed.json")
     odds = self.eyedata[str(eyes)]["percent"]
     onein = self.eyedata[str(eyes)]["onein"]
     update = False
     if eyes >= data["highest"]["number"]:
         data["highest"]["found"] -= data["highest"][
             "found"] - 1 if eyes > data["highest"]["number"] else -1
         data["highest"]["number"] = eyes
         data["highest"]["time"] = int(time())
         update = True
     highest = data["highest"]["number"]
     highestTime = data["highest"]["time"]
     highestTotal = data["highest"]["found"]
     data["calls"] += 1
     calls = data["calls"]
     funcs.dumpJson("data/findseed.json", data)
     file = File(
         f"{funcs.getPath()}/assets/minecraft/portal_frame_images/{eyes}eye.png",
         filename="portal.png")
     foundTime = "just now"
     if not update:
         timestr = funcs.timeDifferenceStr(time(), highestTime)
         timestr_0 = int(timestr.split(" ")[0])
         if timestr_0 > 2:
             foundTime = f"{timestr_0} days"
         else:
             foundTime = timestr
     e = Embed(title=f"{self.client.command_prefix}findseed",
               description=f"Requested by: {ctx.message.author.mention}")
     e.add_field(name="Your Eyes", value=f"`{eyes}`")
     e.add_field(name="Probability", value=f"`{odds}% (1 in {onein})`")
     e.add_field(name="Most Eyes Found", inline=False,
                 value=f"`{highest} (last found {foundTime}{' ago' if not update else ''}" + \
                       f", found {'{:,}'.format(highestTotal)} time{'' if highestTotal == 1 else 's'})`")
     e.set_footer(
         text=
         f"The command has been called {'{:,}'.format(calls)} time{'' if calls == 1 else 's'}. !eyeodds"
     )
     e.set_image(url="attachment://portal.png")
     await ctx.reply(embed=e, file=file)
예제 #3
0
 def getTime(self):
     _, m, s, _ = timeDifferenceStr(time(), self.__startTime, noStr=True)
     return m, s
예제 #4
0
 async def telephone(self, ctx):
     if ctx.channel in self.phoneWaitingChannels:
         return await ctx.reply(":telephone: Cancelling phone call.")
     if ctx.channel in self.phoneCallChannels:
         return await ctx.reply(embed=funcs.errorEmbed(
             None, "A phone call is already in progress in this channel."))
     self.phoneWaitingChannels.append(ctx.channel)
     await ctx.reply(
         ":telephone_receiver: Waiting for another party to pick up the phone..."
     )
     if len(self.phoneWaitingChannels) == 1:
         sleepTime = 0
         while len(self.phoneWaitingChannels) == 1 and sleepTime < 120:
             if len(self.phoneWaitingChannels) == 1 and sleepTime >= 120:
                 self.phoneWaitingChannels.remove(ctx.channel)
                 return await ctx.send(
                     ":telephone: Seems like no one is answering; cancelling phone call."
                 )
             await sleep(0.25)
             sleepTime += 1
     if len(self.phoneWaitingChannels) == 2:
         otherParty = self.phoneWaitingChannels[
             1 if not self.phoneWaitingChannels.index(ctx.channel) else 0]
         await sleep(1)
         self.phoneWaitingChannels.remove(ctx.channel)
         self.phoneCallChannels.append(ctx.channel)
         resetTime = 0
         startCall = time()
         hangup = False
         await ctx.send(
             ":telephone_receiver: Someone has picked up the phone, say hello! " + \
             "Note that not all messages will be sent. Type `!hangup` to hang up."
         )
         while resetTime < 30 and not hangup and otherParty in self.phoneCallChannels:
             try:
                 msg = await self.client.wait_for(
                     "message",
                     timeout=1,
                     check=lambda m: m.channel == ctx.channel and m.author
                     != self.client.user)
                 if msg.content.casefold() == "!hangup":
                     relay = ":telephone: The other party has hung up the phone."
                     await msg.reply(
                         ":telephone: You have hung up the phone.")
                     hangup = True
                 else:
                     relay = f"**{msg.author}** » {msg.content}" + \
                             f"{msg.attachments[0].url if msg.attachments else ''}"
                 await otherParty.send(relay[:2000])
                 resetTime = 0
             except TimeoutError:
                 resetTime += 1
                 if resetTime == 30:
                     await ctx.send(
                         ":telephone: You have been idling for too long. Hanging up the phone..."
                     )
                     await otherParty.send(
                         ":telephone: The other party has hung up the phone."
                     )
         _, m, s, _ = funcs.timeDifferenceStr(time(), startCall, noStr=True)
         self.phoneCallChannels.remove(ctx.channel)
         return await ctx.send(
             "`Elapsed time: {:,} minute{} and {} second{}.`".format(
                 m, "" if m == 1 else "s", s, "" if s == 1 else "s"))
     self.phoneWaitingChannels.remove(ctx.channel)
     await ctx.send(
         ":telephone: Seems like no one is answering; cancelling phone call."
     )