Ejemplo n.º 1
0
 async def food(self, ctx):
     try:
         res = await funcs.getRequest(
             "https://foodish-api.herokuapp.com/api/")
         await funcs.sendImage(ctx, res.json()["image"])
     except Exception as ex:
         funcs.printError(ctx, ex)
Ejemplo n.º 2
0
 async def choice(self, ctx, *, items):
     try:
         while items.startswith(";"):
             items = items[1:]
         while items.endswith(";"):
             items = items[:-1]
         while "  " in items:
             items = items.replace("  ", " ")
         while "; ;" in items:
             items = items.replace("; ;", ";")
         while ";;" in items:
             items = items.replace(";;", ";")
         itemslist = items.split(";")
         if "" in itemslist:
             raise Exception(
                 "Invalid input. Please separate the items with `;`.")
         while " " in itemslist:
             itemslist.remove(" ")
         itemslist = [i.strip() for i in itemslist]
         item = choice(itemslist)
         e = Embed(
             title=f"{self.client.user.name} Chooses...",
             description=
             f"Requested by: {ctx.author.mention}\n{funcs.formatting(item)}"
         )
         e.add_field(name="Items ({:,})".format(len(itemslist)),
                     value=", ".join(f"`{i}`" for i in sorted(itemslist)))
     except Exception as ex:
         funcs.printError(ctx, ex)
         e = funcs.errorEmbed(None, str(ex))
     await ctx.reply(embed=e)
Ejemplo n.º 3
0
 async def dog(self, ctx):
     try:
         res = await funcs.getRequest(
             "https://dog.ceo/api/breeds/image/random")
         await funcs.sendImage(ctx, res.json()["message"])
     except Exception as ex:
         funcs.printError(ctx, ex)
Ejemplo n.º 4
0
 async def fidgetspinner(self, ctx):
     if ctx.author.id in self.activeSpinners:
         return await ctx.reply(embed=funcs.errorEmbed(
             None, "Your fidget spinner is still spinning, please wait!"))
     self.activeSpinners.append(ctx.message.author.id)
     try:
         url = choice([
             "https://media.giphy.com/media/cnY70GhrM5nJ6/giphy.gif",
             "https://media.giphy.com/media/cwT3y6UFFseGc/giphy.gif",
             "https://media.giphy.com/media/1Ubrzxvik2puE/giphy.gif",
             "https://files.gamebanana.com/img/ico/sprays/593404c44a588.gif",
             "https://gifimage.net/wp-content/uploads/2017/11/fidget-spinner-gif-transparent-6.gif"
         ])
         await funcs.sendImage(ctx, url, name="spinner.gif",
                               message=f"<:fidgetspinner:675314386784485376> **{ctx.author.name} has spun a fidget"+ \
                                       " spinner. Let's see how long it lasts...** <:fidgetspinner:675314386784485376>")
         randomSeconds = randint(5, 180)
         await sleep(randomSeconds)
         await ctx.send(
             f"<:fidgetspinner:675314386784485376> **{ctx.message.author.name}'s fidget spinner has just stopped " + \
             f"spinning; it lasted {randomSeconds} seconds!** <:fidgetspinner:675314386784485376>"
         )
         self.activeSpinners.remove(ctx.message.author.id)
     except Exception as ex:
         funcs.printError(ctx, ex)
         await ctx.send(embed=funcs.errorEmbed(
             None, "An error occurred. Please try again later."))
         try:
             self.activeSpinners.remove(ctx.message.author.id)
         except ValueError:
             return
Ejemplo n.º 5
0
 async def dadjoke(self, ctx):
     try:
         res = await funcs.getRequest(
             "https://icanhazdadjoke.com/",
             headers={"Accept": "application/json"})
         await ctx.reply(res.json()["joke"])
     except Exception as ex:
         funcs.printError(ctx, ex)
Ejemplo n.º 6
0
 async def cat(self, ctx):
     try:
         res = await funcs.getRequest(
             "https://api.thecatapi.com/v1/images/search")
         image = res.json()[0]["url"]
         await funcs.sendImage(ctx,
                               image,
                               name=image.split("thecatapi.com/images/")[1])
     except Exception as ex:
         funcs.printError(ctx, ex)
Ejemplo n.º 7
0
 async def literalchinese(self, ctx, *, inp):
     res = ""
     try:
         inplist = list(inp.replace(" ", ""))[:10]
         output = Translator().translate(inplist, dest="en")
         for t in output:
             res += f"{t.text} "
         e = Embed(title="Literal Chinese",
                   description=funcs.formatting(res))
     except Exception as ex:
         funcs.printError(ctx, ex)
         e = funcs.errorEmbed(None, "Rate limit reached, try again later.")
     await ctx.reply(embed=e)
Ejemplo n.º 8
0
 async def literalenglish(self, ctx, *, inp):
     res = ""
     try:
         inplist = inp.split()[:10]
         output = Translator().translate(inplist, dest="zh-tw")
         for t in output:
             res += t.text
         e = Embed(title="Literal English",
                   description=funcs.formatting(res))
     except Exception as ex:
         funcs.printError(ctx, ex)
         e = funcs.errorEmbed(None, "Rate limit reached, try again later.")
     await ctx.reply(embed=e)
Ejemplo n.º 9
0
 async def mcserver(self, ctx, *, ipaddress: str = ""):
     ipaddress = ipaddress.casefold().replace(" ", "") or "mc.hypixel.net"
     try:
         res = await funcs.getRequest(
             f"https://api.mcsrvstat.us/2/{ipaddress}",
             headers={"accept": "application/json"})
         data = res.json()
         status = data["online"]
         e = Embed(title="Minecraft Server Status",
                   colour=Colour.green() if status else Colour.red())
         e.add_field(name="Server Address", value=f"`{ipaddress}`")
         e.add_field(name="Online", value=f"`{status}`")
         if status:
             players = data["players"]["online"]
             e.add_field(name="Player Count",
                         value="`{:,}/{:,}`".format(players,
                                                    data['players']['max']))
             if players:
                 try:
                     playerLimit = 25
                     playerList = data["players"]["list"][:playerLimit]
                     listStr = ", ".join(f"`{player}`"
                                         for player in playerList)
                     if len(playerList) != players:
                         listStr += f" *and {players - playerLimit} more...*"
                     e.add_field(name="Players", value=listStr)
                 except:
                     pass
             e.add_field(name="Version", value=f'`{data["version"]}`')
             e.add_field(name="Port", value=f'`{data["port"]}`')
             e.set_thumbnail(
                 url=f"https://eu.mc-api.net/v3/server/favicon/{ipaddress}")
             try:
                 e.add_field(name="Software", value=f'`{data["software"]}`')
             except:
                 pass
             motd = data["motd"]["clean"]
             try:
                 secondLine = f"\n{motd[1].strip().replace('&amp;', '&')}"
             except:
                 secondLine = ""
             e.set_footer(text=motd[0].strip().replace('&amp;', '&') +
                          secondLine)
     except Exception as ex:
         funcs.printError(ctx, ex)
         e = funcs.errorEmbed(None,
                              "Invalid server address or server error?")
     await ctx.reply(embed=e)
Ejemplo n.º 10
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)
Ejemplo n.º 11
0
 async def poll(self, ctx, *, question):
     if len(question) > 200:
         return await ctx.reply(embed=funcs.errorEmbed(None, "Question must be 200 characters or less."))
     messages, answers = [ctx.message], []
     count = 0
     while count < 20:
         messages.append(
             await ctx.send("Enter poll choice, `!undo` to delete previous choice, or `!done` to publish poll.")
         )
         try:
             entry = await self.client.wait_for(
                 "message",
                 check=lambda m: m.author == ctx.author and m.channel == ctx.channel and len(m.content) <= 100,
                 timeout=60
             )
         except TimeoutError:
             break
         messages.append(entry)
         if entry.content.casefold() == "!done":
             break
         if entry.content.casefold() == "!undo":
             if answers:
                 answers.pop()
                 count -= 1
             else:
                 messages.append(
                     await ctx.send(embed=funcs.errorEmbed(None, "No choices."))
                 )
         else:
             answers.append((chr(0x1f1e6 + count), entry.content))
             count += 1
     try:
         await ctx.channel.delete_messages(messages)
     except:
         pass
     if len(answers) < 2:
         return await ctx.send(embed=funcs.errorEmbed(None, "Not enough choices."))
     answer = "\n".join(f"{keycap}: {content}" for keycap, content in answers)
     e = Embed(title=question, description=f"Poll by: {ctx.author.mention}")
     e.add_field(name="Choices", value=answer)
     e.set_footer(text=str(datetime.utcfromtimestamp(int(time()))) + " UTC")
     try:
         poll = await ctx.send(embed=e)
         for emoji, _ in answers:
             await poll.add_reaction(emoji)
     except Exception as ex:
         funcs.printError(ctx, ex)
         return await ctx.send(embed=funcs.errorEmbed(None, "Too many choices?"))
Ejemplo n.º 12
0
 async def gentext(self, ctx, *, text=""):
     try:
         if text:
             await ctx.send("Processing text. Please wait...")
         data = {"text": text}
         res = await funcs.postRequest(
             "https://api.deepai.org/api/text-generator",
             data=data,
             headers={"api-key": config.deepAIKey})
         data = res.json()
         e = Embed(title="Text Generation",
                   description=funcs.formatting(data["output"]))
     except Exception as ex:
         funcs.printError(ctx, ex)
         e = funcs.errorEmbed(None, "Invalid input or server error.")
     await ctx.reply(embed=e)
Ejemplo n.º 13
0
 async def skin(self, ctx, username: str = ""):
     if username == "":
         username = ctx.message.author.name
     try:
         data = await funcs.getRequest(
             f"https://api.mojang.com/users/profiles/minecraft/{username}")
         username = data.json()["name"]
         res = await funcs.getRequest(
             f"https://sessionserver.mojang.com/session/minecraft/profile/{str(data.json()['id'])}"
         )
         data = loads(b64decode(res.json()["properties"][0]["value"]))
         skin = data["textures"]["SKIN"]["url"]
         e = Embed(title="Minecraft User", description=f"**{username}**")
         e.set_image(url=skin)
     except Exception as ex:
         funcs.printError(ctx, ex)
         e = funcs.errorEmbed(None, "Invalid skin or server error.")
     await ctx.reply(embed=e)
Ejemplo n.º 14
0
 async def lovecalc(self, ctx, first: str = "", second: str = ""):
     if not first:
         return await ctx.reply(
             embed=funcs.errorEmbed(None, "Cannot process empty input."))
     second = second or f"<@!{ctx.author.id}>"
     try:
         newlist = sorted([first, second])
         sentence = ""
         for i in newlist:
             sentence += str(i) + " loves "
         sentence = sentence[:-7]
         sentence = sentence.replace(" ", "").casefold()
         intermediate = ""
         while len(sentence):
             intermediate += str(sentence.count(sentence[0]))
             sentence = sentence.replace(sentence[0], "")
         while int(intermediate) > 100:
             tmp = ""
             for i in range(0, int(len(intermediate) / 2)):
                 tmp += str(
                     int(intermediate[i]) + int(intermediate[(i + 1) * -1]))
             if len(intermediate) % 2 > 0:
                 tmp += intermediate[int(len(intermediate) % 2)]
             intermediate = tmp
         emoji = "!** :sparkling_heart:"
         if 49 < int(intermediate) < 80:
             emoji = "!** :heart:"
         if int(intermediate) < 50:
             emoji = "...** :brown_heart:"
         if int(intermediate) < 20:
             emoji = "...** :broken_heart:"
         await ctx.reply("The love percentage between " + \
                        f"**{newlist[0]}** and **{newlist[1]}** is **{intermediate}%{emoji}")
     except Exception as ex:
         funcs.printError(ctx, ex)
         await ctx.reply(embed=funcs.errorEmbed(
             None, "An error occurred. Invalid user?"))
Ejemplo n.º 15
0
 async def wyr(self, ctx):
     try:
         res = await funcs.getRequest("http://either.io/questions/next/1")
         data = res.json()["questions"][0]
         total1 = int(data['option1_total'])
         total2 = int(data['option2_total'])
         total = total1 + total2
         opt1 = data['option_1']
         opt2 = data['option_2']
         info = data['moreinfo']
         e = Embed(
             title="Would You Rather",
             description=
             f"🔵 {opt1 + ('' if opt1.endswith('.') else '.')}\n🔴 {opt2 + ('' if opt1.endswith('.') else '.')}"
         )
         e.add_field(name="Option 1 Votes",
                     value="`{:,} ({}%)`".format(
                         total1,
                         funcs.removeDotZero(round(total1 / total * 100,
                                                   2))))
         e.add_field(name="Option 2 Votes",
                     value="`{:,} ({}%)`".format(
                         total2,
                         funcs.removeDotZero(round(total2 / total * 100,
                                                   2))))
         if info:
             e.set_footer(text=info)
         yes = True
     except Exception as ex:
         funcs.printError(ctx, ex)
         e = funcs.errorEmbed(None, "Server error.")
         yes = False
     msg = await ctx.send(embed=e)
     if yes:
         await msg.add_reaction("🔵")
         await msg.add_reaction("🔴")
Ejemplo n.º 16
0
 async def acmisc(self, ctx, *, item):
     try:
         await ctx.reply(embed=await self.furnitureEmbed(ctx, "misc", item))
     except Exception as ex:
         funcs.printError(ctx, ex)
Ejemplo n.º 17
0
 async def yomama(self, ctx):
     try:
         res = await funcs.getRequest("https://api.yomomma.info/")
         await ctx.reply(res.json()["joke"])
     except Exception as ex:
         funcs.printError(ctx, ex)
Ejemplo n.º 18
0
 async def bird(self, ctx):
     try:
         res = await funcs.getRequest("https://some-random-api.ml/img/birb")
         await funcs.sendImage(ctx, res.json()["link"])
     except Exception as ex:
         funcs.printError(ctx, ex)
Ejemplo n.º 19
0
 async def coffee(self, ctx):
     try:
         await funcs.sendImage(ctx,
                               "https://coffee.alexflipnote.dev/random")
     except Exception as ex:
         funcs.printError(ctx, ex)