Example #1
0
 async def texttobrainfuck(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             old = 0
             output = ""
             for character in text:
                 ordd = ord(character)
                 if old == ordd:
                     output += "."
                     continue
                 deviation = ordd - old
                 root = int((abs(deviation))**(1 / 2))
                 rest = abs(deviation) - (root**2)
                 mult = root, rest
                 if 0 < deviation:
                     output += "{}.".format("+" * deviation) if deviation < 6 \
                         else ">{}[<{}>-]<{}.".format("+" * mult[0], "+" * mult[0], "+" * mult[1])
                 else:
                     output += "{}.".format("-" * abs(deviation)) if deviation > -6 \
                         else ">{}[<{}>-]<{}.".format("+" * mult[0], "-" * mult[0], "-" * mult[1])
                 old = ordd
             e = Embed(title="Text to Brainfuck",
                       description=funcs.formatting(output))
         except Exception:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #2
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
Example #3
0
 async def morsetotext(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             text += " "
             output = ""
             ctext = ""
             spaces = 0
             for char in text:
                 if char != " ":
                     if char != "-" and char != ".":
                         if char == "·":
                             char = "."
                         else:
                             continue
                     spaces = 0
                     ctext += char
                 else:
                     spaces += 1
                     if spaces == 2:
                         output += " "
                     else:
                         output += list(self.morsecode.keys())[list(
                             self.morsecode.values()).index(ctext)]
                         ctext = ""
             e = Embed(title="Text to Morse Code",
                       description=funcs.formatting(output))
         except Exception:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #4
0
 async def acvillager(self, ctx, *, villager):
     try:
         found, villagerdata = False, None
         for villagerID in list(self.villagers):
             villagerdata = self.villagers[villagerID]
             if villagerdata["name"]["name-USen"].casefold().replace(" ", "_") \
                     == villager.casefold().replace(" ", "_").replace("‘", "'").replace("’", "'")\
                     .replace("etoile", "étoile").replace("renee", "renée"):
                 found = True
                 break
         if not found:
             return await ctx.reply(embed=funcs.errorEmbed(
                 None, "Not found, please check your spelling."))
         e = Embed(description='"' + villagerdata["saying"] + '"')
         e.set_author(name=villagerdata["name"]["name-USen"].title(),
                      icon_url=villagerdata["icon_uri"].replace(
                          "https", "http"))
         e.set_image(url=villagerdata["image_uri"].replace("https", "http"))
         e.set_thumbnail(url=AC_LOGO)
         e.add_field(
             name="Personality",
             value="`{}`".format(
                 f'{villagerdata["personality"].replace("Uchi", "Sisterly")} ({villagerdata["subtype"]})'
             ))
         bd = villagerdata['birthday-string']
         bdm, bdd = bd[:-2].split(" ")
         now = datetime.now()
         e.add_field(name="Birthday",
                     value=f"`{bd} ({funcs.dateToZodiac(bd, ac=True)})`" + \
                           f"{' :birthday:' if int(bdd) == now.day and int(funcs.monthNameToNumber(bdm)) == now.month else ''}")
         e.add_field(name="Species", value=f"`{villagerdata['species']}`")
         e.add_field(name="Gender", value=f"`{villagerdata['gender']}`")
         e.add_field(name="Hobby", value=f"`{villagerdata['hobby']}`")
         e.add_field(name="Initial Phrase",
                     value='`"{}"`'.format(villagerdata["catch-phrase"]))
         try:
             if villagerdata["sanrio"]:
                 e.set_footer(
                     text=
                     "Note: This is a Sanrio villager and cannot be obtained via NMT islands."
                 )
         except:
             i = 0
             for villagerID in list(self.villagers):
                 newvillagerdata = self.villagers[villagerID]
                 if newvillagerdata["species"] == villagerdata["species"]:
                     try:
                         if newvillagerdata["sanrio"]:
                             continue
                     except:
                         i += 1
             prob = len(self.species) * i
             e.add_field(inline=False,
                         name="NMT Probability",
                         value="`1 in {:,}`".format(prob))
         e.add_field(name="Vacation Theme",
                     value=f'`"{villagerdata["paradise_theme"]}"`')
     except Exception as ex:
         e = funcs.errorEmbed(None, f"An error occurred - {ex}")
     await ctx.reply(embed=e)
Example #5
0
 async def acvbd(self, ctx, month: str = "", day: str = ""):
     try:
         now = datetime.now()
         if not month:
             month = month or now.month
         try:
             month = funcs.monthNumberToName(int(month))
         except:
             month = funcs.monthNumberToName(funcs.monthNameToNumber(month))
         vbds = []
         if day:
             try:
                 day = int(day)
             except:
                 day = int(day[:-2])
             date = f"{month} {str(day)}"
             properdate = None
             for i in list(self.villagers):
                 data = self.villagers[i]
                 if data["birthday-string"][:-2] == date:
                     vbds.append(data["name"]["name-USen"].title())
                     if not properdate:
                         properdate = data["birthday-string"]
             if vbds:
                 e = Embed(title=properdate + " Birthdays",
                           description=", ".join(f"`{j}`"
                                                 for j in sorted(vbds)))
                 e.set_thumbnail(url=AC_LOGO)
             else:
                 e = funcs.errorEmbed(None, "No villagers found.")
         else:
             sign1 = funcs.dateToZodiac(month + " 1", ac=True)
             sign2 = funcs.dateToZodiac(month + " 28", ac=True)
             for i in list(self.villagers):
                 data = self.villagers[i]
                 if data["birthday-string"].split(" ")[0] == month:
                     vbds.append(data)
             vbds = sorted(
                 vbds,
                 key=lambda k: int(k["birthday-string"].split(" ")[1][:-2]))
             vbds1 = self.bdList(sign1, vbds, month, now)
             vbds2 = self.bdList(sign2, vbds, month, now)
             e = Embed(title=month + " Birthdays")
             e.add_field(
                 name=sign1,
                 value=", ".join(
                     f"`{j.replace(BD_KEY, '')}`{' :birthday:' if j.endswith(BD_KEY) else ''}"
                     for j in vbds1))
             e.add_field(
                 name=sign2,
                 value=", ".join(
                     f"`{j.replace(BD_KEY, '')}`{' :birthday:' if j.endswith(BD_KEY) else ''}"
                     for j in vbds2))
             e.set_thumbnail(url=AC_LOGO)
     except Exception:
         e = funcs.errorEmbed(None, "Invalid input.")
     await ctx.reply(embed=e)
Example #6
0
 async def unloadcog(self, ctx, *, cog: str = ""):
     if cog == "":
         return await ctx.reply(
             embed=funcs.errorEmbed(None, "Cannot process empty input."))
     try:
         funcs.unloadCog(self.client, cog)
         await ctx.reply(":ok_hand:")
     except Exception as ex:
         await ctx.reply(embed=funcs.errorEmbed(None, str(ex)))
Example #7
0
 async def hextotext(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             e = Embed(title="Hexadecimal to Text",
                       description=funcs.formatting(
                           bytes.fromhex(text).decode("utf-8")))
         except Exception:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #8
0
 async def texttohex(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             e = Embed(title="Text to Hexadecimal",
                       description=funcs.formatting(
                           text.encode('utf-8').hex()))
         except Exception:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #9
0
 async def texttobinary(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             e = Embed(title="Text to Binary",
                       description=funcs.formatting(
                           str("".join(f"{ord(i):08b}" for i in text))))
         except Exception:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #10
0
 async def hextobinary(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             number = int(text.replace(" ", ""), 16)
             e = Embed(title="Hexadecimal to Binary",
                       description=funcs.formatting(
                           bin(int(number)).replace("0b", "")))
         except Exception:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #11
0
 async def hextodecimal(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             hexnumber = text.replace(" ", "")
             e = Embed(title="Hexadecimal to Decimal",
                       description=funcs.formatting(
                           funcs.removeDotZero(int(hexnumber, 16))))
         except ValueError:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #12
0
 async def leaveserver(self, ctx, *, serverID=None):
     if not serverID:
         return await ctx.reply(
             embed=funcs.errorEmbed(None, "Empty input."))
     try:
         server = self.client.get_guild(int(serverID))
         if server:
             await ctx.reply(":ok_hand:")
             return await server.leave()
         await ctx.reply(embed=funcs.errorEmbed(None, "Unknown server."))
     except Exception as ex:
         await ctx.reply(embed=funcs.errorEmbed(None, str(ex)))
Example #13
0
 async def binarytohex(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             text = text.replace(" ", "")
             hstr = "%0*X" % ((len(text) + 3) // 4, int(text, 2))
             e = Embed(title="Binary to Hexadecimal",
                       description=funcs.formatting(hstr))
         except Exception:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #14
0
 async def decimaltohex(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             number = int(text.replace(" ", "").replace(",", ""))
             e = Embed(title="Decimal to Hexadecimal",
                       description=funcs.formatting(
                           hex(number).split("x")[-1]))
         except ValueError:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #15
0
 async def kgtolbs(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             number = float(text.replace(" ", "").replace(",", ""))
             value = round(number * 2.2046226218, 5)
             e = Embed(title="Kilograms to Pounds",
                       description=funcs.formatting(
                           funcs.removeDotZero(value) + " lbs"))
         except ValueError:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #16
0
 async def pearlbarter(self, ctx, trades: str = "2"):
     try:
         n = int(trades)
         if not 2 <= n <= BARTER_LIMIT:
             return await ctx.reply(embed=funcs.errorEmbed(
                 None, f"Value must be between 2 and {BARTER_LIMIT}."))
     except ValueError:
         return await ctx.reply(
             embed=funcs.errorEmbed(None, "Invalid input."))
     x = 1 - (403 / 423) ** n - n * (20 / 423) * ((403 / 423) ** (n - 1)) - (2 / 5) * (n * (n - 1) / 2) \
         * ((403 / 423) ** (n - 2)) * ((20 / 423) ** 2)
     await ctx.reply(f"**[1.16.1]** The probability of getting 12 or more ender pearls" + \
                     f" with {n} gold ingots is:\n\n`{round(x * 100, 5)}%` (1 in {round(1 / x, 5)})")
Example #17
0
 async def ftc(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             number = float(text.replace(" ", "").replace(",", ""))
             value = round((number - 32) * 5 / 9, 5)
             e = Embed(title="Fahrenheit to Celsius",
                       description=funcs.formatting(
                           funcs.removeDotZero(value) + "°C"))
         except ValueError:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #18
0
 async def milestokm(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             number = float(text.replace(" ", "").replace(",", ""))
             value = round(number * 1.609344, 5)
             e = Embed(title="Miles to Kilometres",
                       description=funcs.formatting(
                           funcs.removeDotZero(value) + " km"))
         except ValueError:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #19
0
 async def bartersim(self, ctx, goldingots: str = "1"):
     try:
         try:
             goldingots = int(goldingots)
         except:
             goldingots = int(goldingots[:-1]) * 9
         if not 0 < goldingots < 10001:
             return await ctx.reply(embed=funcs.errorEmbed(
                 None, f"Value must be between 1 and 10,000."))
     except ValueError:
         return await ctx.reply(
             embed=funcs.errorEmbed(None, "Invalid input."))
     trades = {}
     string, glowdust, cryobby = 0, 0, 0
     for _ in range(goldingots):
         trade = choice(self.loottable)
         if trade["id"] not in list(trades.keys()):
             trades[trade["id"]] = {}
             trades[trade["id"]]["item"] = trade["item"]
             n = choice(trade["quantity"])
             trades[trade["id"]]["quantity"] = n
             trades[trade["id"]]["trades"] = 1
         else:
             n = choice(trade["quantity"])
             trades[trade["id"]]["quantity"] += n
             trades[trade["id"]]["trades"] += 1
         if trade["id"] == 13:
             string += n
         elif trade["id"] == 10:
             glowdust += n
         elif trade["id"] == 19:
             cryobby += n
     res = "You bartered {:,} gold ingot{} for:\n\n".format(
         goldingots, "" if goldingots == 1 else "s")
     for i in sorted(trades):
         t = trades[i]
         res += "{}{:,} x {} ({:,} trade{})\n".format(
             "*** " if i in [7, 8, 10, 12, 13, 18, 19] else "    ",
             t["quantity"], t["item"], t["trades"],
             "" if t["trades"] == 1 else "s")
     anchors = self.chargeableAnchors(glowdust, cryobby)
     beds = string // 12
     explosives = anchors + beds
     if explosives:
         res += "\nExplosives you can craft ({:,}):\n\n".format(explosives)
         if beds:
             res += "    {:,} x Bed\n".format(beds)
         if anchors:
             res += "    {:,} x Respawn Anchor (w/ enough glowstone to power)".format(
                 anchors)
     await ctx.reply(funcs.formatting(res))
Example #20
0
 async def brainfucktotext(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             interpreter = BrainfuckInterpreter(text)
             while interpreter.available():
                 interpreter.step()
             e = Embed(title="Brainfuck to Text",
                       description=funcs.formatting(
                           interpreter.getOutput().read()))
         except Exception as ex:
             e = funcs.errorEmbed(None, str(ex))
     await ctx.reply(embed=e)
Example #21
0
 async def binarytotext(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             text = text.replace(" ", "")
             e = Embed(
                 title="Binary to Text",
                 description=funcs.formatting("".join(chr(int(text[i * 8:i * 8 + 8], 2)) \
                     for i in range(len(text) // 8)))
             )
         except Exception:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #22
0
 async def dtd(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             number = float(text.replace(" ", "").replace(",", ""))
             number = 0 if number == 360 else number
             if not 0 <= number < 360:
                 raise ValueError
             e = Embed(title="Degrees to Cardinal Direction",
                       description=funcs.formatting(
                           funcs.degreesToDirection(number)))
         except ValueError:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #23
0
 async def ctf(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             number = float(text.replace(" ", "").replace(",", ""))
             e = Embed(
                 title="Celsius to Fahrenheit",
                 description=funcs.formatting(
                     funcs.removeDotZero(
                         round(funcs.celsiusToFahrenheit(number), 5)) +
                     "°F"))
         except ValueError:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
Example #24
0
 async def hash(self, ctx, algo=None, *, msg=""):
     algorithms = [
         "md5", "blake2b", "blake2s", "sha1", "sha224", "sha256", "sha384",
         "sha512", "sha", "md"
     ]
     if not algo:
         e = funcs.errorEmbed(None, "Please select a hashing algorithm.")
     else:
         algo = algo.casefold().replace("-", "").replace("_", "").strip()
         if algo not in algorithms:
             e = funcs.errorEmbed(
                 "Invalid algorithm!",
                 "Valid options:\n\n`MD5`, `BLAKE2b`, `BLAKE2s`, " + \
                 "`SHA1`, `SHA224`, `SHA256`, `SHA384`, `SHA512`"
             )
         else:
             if algo.startswith("md"):
                 algo = "MD5"
                 output = str(hashlib.md5(msg.encode("utf-8")).hexdigest())
             elif algo == "blake2b":
                 algo = "BLAKE2b"
                 output = str(
                     hashlib.blake2b(msg.encode("utf-8")).hexdigest())
             elif algo == "blake2s":
                 algo = "BLAKE2s"
                 output = str(
                     hashlib.blake2s(msg.encode("utf-8")).hexdigest())
             elif algo == "sha1" or algo == "sha":
                 algo = "SHA1"
                 output = str(hashlib.sha1(msg.encode("utf-8")).hexdigest())
             elif algo == "sha224":
                 algo = "SHA224"
                 output = str(
                     hashlib.sha224(msg.encode("utf-8")).hexdigest())
             elif algo == "sha256":
                 algo = "SHA256"
                 output = str(
                     hashlib.sha256(msg.encode("utf-8")).hexdigest())
             elif algo == "sha384":
                 algo = "SHA384"
                 output = str(
                     hashlib.sha384(msg.encode("utf-8")).hexdigest())
             else:
                 algo = "SHA512"
                 output = str(
                     hashlib.sha512(msg.encode("utf-8")).hexdigest())
             e = Embed(title=algo, description=funcs.formatting(output))
     await ctx.reply(embed=e)
Example #25
0
 async def botdisguise(self, ctx, *, stealth: str = ""):
     if self.botDisguise:
         return
     await ctx.reply("Please enter channel ID, or `cancel` to cancel." + \
                    f"{' Stealth mode enabled (you cannot send messages).' if stealth else ''}")
     try:
         msg = await self.client.wait_for(
             "message",
             check=lambda m: m.channel == ctx.channel and m.author == ctx.
             author,
             timeout=30)
         content = msg.content
         if content.casefold().startswith(
             ("c", self.client.command_prefix)):
             return await msg.reply("Cancelling.")
         channelID = int(content)
         self.destChannel = self.client.get_channel(channelID)
         if not self.destChannel:
             self.destChannel = self.client.get_user(channelID)
             if not self.destChannel:
                 return await msg.reply(embed=funcs.errorEmbed(
                     None, "Invalid channel. Cancelling."))
         self.botDisguise = True
         self.originChannel = ctx.channel
         self.client.loop.create_task(self.awaitBDStop(ctx))
         await msg.reply(f"You are now in bot disguise mode! Channel: #{self.destChannel.name} " + \
                        f"({self.destChannel.guild.name}). Type `!q` to quit.")
         while self.botDisguise:
             try:
                 msg = await self.client.wait_for(
                     "message",
                     check=lambda m: m.channel == ctx.channel and m.author
                     == ctx.author,
                     timeout=1)
             except TimeoutError:
                 continue
             if not msg.content.casefold().startswith(
                 ("!q", self.client.command_prefix)) and not stealth:
                 try:
                     await self.destChannel.send(f"{msg.content}" + \
                                                 f"{msg.attachments[0].url if msg.attachments else ''}")
                 except Exception as ex:
                     await ctx.send(embed=funcs.errorEmbed(None, str(ex)))
     except TimeoutError:
         return await ctx.send("Cancelling.")
     except ValueError:
         return await ctx.send(
             embed=funcs.errorEmbed(None, "Invalid channel. Cancelling."))
Example #26
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?"))
Example #27
0
 async def help(self, ctx, *cmd):
     if not cmd:
         e = funcs.commandsListEmbed(self.client)
     else:
         try:
             prefix = self.client.command_prefix
             command = self.client.get_command(cmd[0].replace(prefix, ""))
             cog = command.cog_name
             if funcs.commandIsOwnerOnly(command) and ctx.author != (await self.client.application_info()).owner \
                     or cog == "Easter Eggs" and not await funcs.easterEggsPredicate(ctx):
                 raise Exception()
             name = command.name
             usage = command.usage
             aliases = sorted(command.aliases)
             e = Embed(title=f"{prefix}{name}", description=command.description)
             if usage:
                 e.set_footer(text="Command usage: <> = Required; [] = Optional")
                 e.add_field(name="Usage", value=f"```{prefix}{name} {usage}```")
             if aliases:
                 e.add_field(
                     name="Aliases", value=", ".join(f"`{prefix}{alias}`" for alias in aliases)
                 )
             e.add_field(name="Category", value=f"`{cog}`")
         except Exception:
             e = funcs.errorEmbed(None, "Unknown command.")
     await ctx.reply(embed=e)
Example #28
0
 async def userinfo(self, ctx, *, userID=None):
     try:
         if not userID:
             userID = str(ctx.author.id)
         else:
             if userID.startswith("<@!") and userID.endswith(">"):
                 userID = userID[3:-1]
             userID = userID.replace(" ", "")
         u = self.client.get_user(int(userID))
         dt = u.created_at
         e = Embed(description=u.mention if u != self.client.user else "That's me!")
         e.set_author(name=str(u), icon_url=u.avatar_url)
         e.add_field(name="Is Bot", value=f"`{str(u.bot)}`")
         e.add_field(name="User ID", value=f"`{u.id}`")
         e.add_field(name="Creation Date", value=funcs.dateBirthday(dt.day, dt.month, dt.year))
         if ctx.guild:
             try:
                 member = await ctx.guild.fetch_member(userID)
                 dt2 = member.joined_at
                 e.add_field(name="Joined Server On", value=funcs.dateBirthday(dt2.day, dt2.month, dt2.year))
                 if member.nick:
                     e.add_field(name="Nickname", value=f"`{member.nick}`")
                 if member.activity:
                     e.add_field(name="Activity", value=f"`{member.activity}`")
                 e.add_field(name="Roles ({:,})".format(len(member.roles)),
                             value="".join(f"{i.mention}, " for i in member.roles)[:800].rsplit(", ", 1)[0])
             except:
                 pass
     except:
         e = funcs.errorEmbed(None, "Unknown user.")
     await ctx.reply(embed=e)
Example #29
0
 async def unblacklistuser(self, ctx, *, userID=None):
     if not userID:
         return await ctx.reply(
             embed=funcs.errorEmbed(None, "Empty input."))
     try:
         userID = int(userID)
         data = funcs.readJson("data/blacklist.json")
         userList = list(data["users"])
         if userID in userList:
             userList.remove(userID)
             data["users"] = userList
             funcs.dumpJson("data/blacklist.json", data)
             return await ctx.reply("Removed.")
         await ctx.reply(embed=funcs.errorEmbed(None, "Not in blacklist."))
     except ValueError:
         await ctx.reply(embed=funcs.errorEmbed(None, "Invalid input."))
Example #30
0
 async def acsea(self, ctx, *, sea):
     try:
         seadata = self.findData(self.sea, sea)
         northmonths = seadata["availability"]["month-northern"] if seadata["availability"]["month-northern"] != "" \
                       else "All Year"
         southmonths = seadata["availability"]["month-southern"] if seadata["availability"]["month-southern"] != "" \
                       else "All Year"
         time = seadata["availability"][
             "time"] if seadata["availability"]["time"] != "" else "All Day"
         e = Embed(description=seadata["museum-phrase"])
         e.set_footer(text='"{}"'.format(seadata["catch-phrase"]))
         e.set_author(name=seadata["name"]["name-USen"].title().replace(
             "'S", "'s"),
                      icon_url=seadata["icon_uri"].replace("https", "http"))
         e.add_field(name="Shadow", value=f"`{seadata['shadow']}`")
         e.add_field(name="Speed", value=f"`{seadata['speed']}`")
         e.add_field(name="Northern Months", value=f"`{northmonths}`")
         e.add_field(name="Southern Months", value=f"`{southmonths}`")
         e.add_field(name="Time", value=f"`{time}`")
         e.add_field(name="Sell Price",
                     value="`{:,}`".format(seadata["price"]))
         e.set_image(url=seadata["image_uri"].replace("https", "http"))
         e.set_thumbnail(url=AC_LOGO)
     except Exception as ex:
         e = funcs.errorEmbed(None, str(ex))
     await ctx.reply(embed=e)