示例#1
0
 async def cmtoft(self, ctx, *, text: str = ""):
     if text == "":
         e = funcs.errorEmbed(None, "Cannot process empty input.")
     else:
         try:
             number = float(text.replace(" ", "").replace(",", ""))
             totalinches = number / 2.54
             totalfeet = totalinches / 12
             feet = int(totalfeet)
             e = Embed(title="Centimetres to Feet & Inches",
                       description=funcs.formatting(
                           "{} ft {} in ({} ft OR {} in)".format(
                               funcs.removeDotZero(feet),
                               funcs.removeDotZero(
                                   round(totalinches - (feet * 12), 5)),
                               funcs.removeDotZero(round(totalfeet, 5)),
                               funcs.removeDotZero(round(totalinches, 5)))))
         except ValueError:
             e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)
示例#2
0
 async def coords(self, ctx, *, inp: str):
     inp = funcs.replaceCharacters(inp, [",", "(", ")", ";"])
     args = inp.split(" ")
     try:
         try:
             x1, z1, _ = self.f3cProcessing(inp)
         except:
             x1, z1 = float(args[0]), float(args[1])
         x2, z2 = float(args[-2]), float(args[-1])
     except ValueError:
         return await ctx.reply(
             embed=funcs.errorEmbed(None, "Invalid arguments."))
     await ctx.reply(
         "The distance between (**{}**; **{}**) and (**{}**; **{}**) is: ".
         format(funcs.removeDotZero(round(x1, 5)),
                funcs.removeDotZero(round(z1, 5)),
                funcs.removeDotZero(round(x2, 5)),
                funcs.removeDotZero(round(z2, 5))) +
         f"**{funcs.removeDotZero(round(self.coordsDifference((x1, z1), (x2, z2)), 5))}**"
     )
示例#3
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)
示例#4
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)
示例#5
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)
示例#6
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)
示例#7
0
 async def botinfo(self, ctx):
     appinfo = await self.client.application_info()
     e = Embed(description=appinfo.description)
     dt = self.client.user.created_at
     e.set_author(name=self.client.user.name, icon_url=self.client.user.avatar_url)
     e.add_field(name="Owner", value=f"`{appinfo.owner}`")
     e.add_field(name="Python", value=f"`{version.split(' ')[0]}`")
     e.add_field(name="Library", value=f"`Pycord {__version__}`")
     e.add_field(name="Creation Date", value=funcs.dateBirthday(dt.day, dt.month, dt.year))
     e.add_field(name="Servers", value="`{:,}`".format(len(self.client.guilds)))
     e.add_field(name="Users (Excluding Bots)", value="`{:,} ({:,})`".format(
         len(self.client.users), len(set([i for i in self.client.users if not i.bot]))
     ))
     e.add_field(name="CPU Usage", value=f"`{funcs.removeDotZero(cpu_percent())}%`")
     e.add_field(name="Memory Usage", value=f"`{funcs.removeDotZero(dict(virtual_memory()._asdict())['percent'])}%`")
     e.add_field(name="Memory Available",
                 value="`{} MB`".format(
                     funcs.removeDotZero(round(float(dict(virtual_memory()._asdict())['available']) / 1024 / 1024, 2))
                 ))
     e.add_field(name="Disk Usage", value=f"`{funcs.removeDotZero(dict(disk_usage('/')._asdict())['percent'])}%`")
     e.add_field(name="Disk Space Available",
                 value="`{} GB`".format(
                     funcs.removeDotZero(round(float(dict(disk_usage('/')._asdict())['free']) / 1024 / 1024 / 1024, 2))
                 ))
     try:
         res = await funcs.getRequest(f"https://api.statcord.com/v3/{self.client.user.id}",
                                      params={"Authorization": config.statcordKey})
         statcord = res.json()
         e.add_field(name="Bandwidth Usage",
                     value="`{} MB`".format(funcs.removeDotZero(round(int(statcord["data"][0]["bandwidth"]) / 1024 / 1024, 2))))
         popular = statcord["popular"][0]
         e.add_field(name="Most Popular Command",
                     value="`{}{} ({:,})`".format(self.client.command_prefix, popular['name'], int(popular['count'])))
     except:
         pass
     e.add_field(name="!findseed Calls", value="`{:,}`".format(funcs.readJson("data/findseed.json")['calls']))
     e.add_field(name="Local Time", value=f"`{str(datetime.fromtimestamp(int(time())))}`")
     e.set_footer(text=f"Bot has been up for {funcs.timeDifferenceStr(time(), self.starttime)}.")
     await ctx.reply(embed=e)
示例#8
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)
示例#9
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("🔴")
示例#10
0
 async def fttocm(self, ctx, feet, inches=""):
     try:
         feet = feet.replace("′", "")
         if not feet:
             raise ValueError
         feet = float(feet)
         inches = inches.replace("″", "")
         if not inches:
             inches = 0
         else:
             inches = float(inches)
         value = (feet * 12 + inches) * 2.54
         e = Embed(title="Feet & Inches to Centimetres",
                   description=funcs.formatting(
                       funcs.removeDotZero(value) + " cm"))
     except ValueError:
         e = funcs.errorEmbed(None, "Conversion failed. Invalid input?")
     await ctx.reply(embed=e)