aboutsummaryrefslogtreecommitdiff
path: root/cogs/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'cogs/utils.py')
-rwxr-xr-xcogs/utils.py253
1 files changed, 100 insertions, 153 deletions
diff --git a/cogs/utils.py b/cogs/utils.py
index 27fd708..bacf5e6 100755
--- a/cogs/utils.py
+++ b/cogs/utils.py
@@ -1,9 +1,7 @@
from discord.ext import commands
from discord.ext import tasks
import discord
-import requests
import json
-import asyncio
import datetime
# forgot to import this and ended up looking mentally unstable
# troll literally pointed out atleast 4 things I did wrong in 3 lines of code
@@ -16,6 +14,7 @@ from selenium.webdriver.chrome.options import Options
#import image as Image
from PIL import Image
from PIL import ImageFilter
+import functools
def set_viewport_size(driver, width, height):
window_size = driver.execute_script("""
@@ -25,16 +24,55 @@ def set_viewport_size(driver, width, height):
driver.set_window_size(*window_size)
async def reportStuff(self, ctx, message):
- channel = self.bot.get_channel(715549209998262322)
+ channel = self.bot.get_channel(int(self.bot.config[str(ctx.message.guild.id)]["report_channel"]))
embed = discord.Embed(
title=f"Report from {ctx.message.author}",
- description=f"{message}",
+ description=f"{message}",
color=ctx.message.author.color, timestamp=ctx.message.created_at)
await channel.send(embed=embed)
await ctx.author.send("Report has been submitted")
+def save_leaderboard():
+ DRIVER = '/usr/lib/chromium-browser/chromedriver'
+ chrome_options = Options()
+ chrome_options.add_argument("--disable-dev-shm-usage")
+ chrome_options.add_argument("--headless")
+ chrome_options.add_argument("--no-sandbox")
+ chrome_options.add_argument("--disable-gpu")
+ #chrome_options.binary_location = ""
+ driver = webdriver.Chrome(DRIVER, chrome_options=chrome_options)
+ set_viewport_size(driver, 1000, 1000)
+ driver.get('https://aninternettroll.github.io/mcbeVerifierLeaderboard/')
+ screenshot = driver.find_element_by_id('table').screenshot('leaderboard.png')
+ driver.quit()
+ #transparency time
+ img = Image.open('leaderboard.png')
+ img = img.convert("RGB")
+ pallette = Image.open("palette.png")
+ pallette = pallette.convert("P")
+ img = img.quantize(colors=256, method=3, kmeans=0, palette=pallette)
+ img = img.convert("RGBA")
+ datas = img.getdata()
+
+ newData = []
+ for item in datas:
+ if item[0] == 255 and item[1] == 255 and item[2] == 255:
+ newData.append((255, 255, 255, 0))
+ else:
+ newData.append(item)
+
+ img.putdata(newData)
+ """
+ img = img.filter(ImageFilter.SHARPEN)
+ img = img.filter(ImageFilter.SHARPEN)
+ img = img.filter(ImageFilter.SHARPEN)
+ """
+ #height, width = img.size
+ #img = img.resize((height*10,width*10), resample=Image.BOX)
+ img.save("leaderboard.png", "PNG")
+
class Utils(commands.Cog):
def __init__(self, bot):
@@ -48,10 +86,12 @@ class Utils(commands.Cog):
@commands.cooldown(1, 25, commands.BucketType.guild)
@commands.command()
async def findseed(self, ctx):
- if ctx.message.channel.id != 684787316489060422:
+ """Test yout luck"""
+ if ctx.message.channel.id != int(self.bot.config[str(ctx.message.guild.id)]["bot_channel"]):
await ctx.message.delete()
+ ctx.command.reset_cooldown(ctx)
return
-
+
# Don't ask
rigged_findseed = {
280428276810383370: 12, # Thomas's User ID
@@ -67,13 +107,13 @@ class Utils(commands.Cog):
randomness = randint(1, 10)
if randomness <= 1:
totalEyes += 1
-
- await ctx.send(f"{ctx.message.author.display_name} -> your seed is a {totalEyes} eye")
+ await ctx.send(f"{discord.utils.escape_mentions(ctx.message.author.display_name)} -> your seed is a {totalEyes} eye")
@findseed.error
async def findseed_handler(self,ctx,error):
if isinstance(error, commands.CommandOnCooldown):
- if ctx.message.channel.id != 684787316489060422:
+ if ctx.message.channel.id != int(self.bot.config[str(ctx.message.guild.id)]["bot_channel"]):
+ ctx.command.reset_cooldown(ctx)
await ctx.message.delete()
return
else:
@@ -82,7 +122,8 @@ class Utils(commands.Cog):
@commands.command()
async def findsleep(self, ctx):
- if ctx.message.channel.id != 684787316489060422:
+ """Test your sleep"""
+ if ctx.message.channel.id != int(self.bot.config[str(ctx.message.guild.id)]["bot_channel"]):
await ctx.message.delete()
return
@@ -98,78 +139,61 @@ class Utils(commands.Cog):
"waaakeee uuuppp!",
"are they dead or asleep? I can't tell.",
"wake up, muffin head",
- "psst... coffeeee \:D"
+ "psst... coffeeee \\:D"
]
-
- # Set up initial message
- msg = f"{ctx.message.author.display_name} -> "
# Optional TODO: Create non-normal distribution
sleepHrs = randint(0, 24)
- # Add sleepHrs with bonus grammar check :D
- if sleepHrs == 1:
- msg += f"your sleep is {sleepHrs} hour long "
- else:
- msg += f"your sleep is {sleepHrs} hours long "
-
# Add extra comment based on number of sleepHrs
if sleepHrs == 0:
- msg += "- nice try \:D"
+ await ctx.send(f"{ctx.message.author.display_name} -> your sleep is 0 hours long - nice try \:D")
elif sleepHrs <= 5:
- msg += f"- {lessSleepMsg[randint(0, len(lessSleepMsg) - 1)]}"
- elif sleepHrs >= 10:
- msg += f"- {moreSleepMsg[randint(0, len(moreSleepMsg) - 1)]}"
-
- await ctx.send(msg)
+ if sleepHrs == 1:
+ s = ''
+ else:
+ s = 's'
+ await ctx.send(f"{ctx.message.author.display_name} -> your sleep is {sleepHrs} hour{s} long - {lessSleepMsg[randint(0, len(lessSleepMsg) - 1)]}")
+ else:
+ await ctx.send(f"{ctx.message.author.display_name} -> your sleep is {sleepHrs} hours long - {moreSleepMsg[randint(0, len(moreSleepMsg) - 1)]}")
+
+ @commands.Cog.listener()
+ async def on_member_join(self, member):
+ def check(msg):
+ return msg.author == member and msg.type != discord.MessageType.new_member
+ msg = await self.bot.wait_for("message", check=check, timeout=300)
+ await msg.channel.send("<:PeepoPog:732172337956257872>")
+
@commands.Cog.listener()
async def on_message(self, message):
- if message.channel.id != 589110766578434078:
+ if not message.guild:
+ return
+ if message.channel.id != int(self.bot.config[str(message.guild.id)]["fair_channel"]):
return
if message.author.bot:
return
badWords = ["fair", "f a i r", "ⓕⓐⓘⓡ", "ⓕ ⓐ ⓘ ⓡ"]
count = 0
-
+
coolKids = [
['Cameron', self.bot.get_user(468262902969663488), datetime.date(2020, 10, 8)],
['Indy', self.bot.get_user(274923326890311691), datetime.date(2020, 9, 10)],
['Kai', self.bot.get_user(199070670221475842), datetime.date(2020, 11, 20)],
['Luca', self.bot.get_user(99457716614885376), datetime.date(2020, 11, 5)],
['Max', self.bot.get_user(543958509243596800), datetime.date(2020, 11, 10)],
+ ['Mistaken', self.bot.get_user(264121998173536256), datetime.date(2020, 7, 6)],
['Murray', self.bot.get_user(400344183333847060), datetime.date(2020, 11, 10)],
+ ['RKREE', self.bot.get_user(395872198323077121), datetime.date(2020, 11, 5)],
# idk if she goes by her irl name but I'm sticking with it for the sake of uniformity
# also idk how to pronounce prakxo
- ['Samantha', self.bot.get_user(226312219787264000), datetime.date(2020, 6, 25)],
+ ['Samantha', self.bot.get_user(226312219787264000), datetime.date(2020, 6, 24)],
['Scott', self.bot.get_user(223937483774230528), datetime.date(2020, 6, 23)],
+ ['Sky', self.bot.get_user(329538915805691905), datetime.date(2020, 6, 24)],
['Thomas', self.bot.get_user(280428276810383370), datetime.date(2020, 9, 29)]
]
-
-
- # Luca plz dont remove the bottom code (just incase the new code doesnt work,
- # and also for me to laugh at how bad my code is)
-
- # brb while I write ugly and inefficient code in my
- # conquest to make Steve the Bot bloated and unworkable
-
- #if datetime.date.today() == datetime.date(2020, 6, 23):
- # await scott.send('Happy Birthday Scott. You\'re a boomer now! :mango:')
- #elif datetime.date.today() == datetime.date(2020, 6, 25):
- # await samantha.send('Happy Birthday Prakxo. You\'re a boomer now! :mango:')
- #elif datetime.date.today() == datetime.date(2020, 5, 28):
- # await thomas.send('Testy Test :mango:')
- #elif datetime.date.today() == datetime.date(2020, 9, 29):
- # await thomas.send('Now you know how the others felt :mango:')
- #elif datetime.date.today() == datetime.date(2020, 10, 8):
- # await cameron.send('Happy Birthday Cameron. You\'re a boomer now! :mango:')
- #elif datetime.date.today() == datetime.date(2020, 11, 10):
- # await murray.send('Happy Birthday Murray. You\'re a boomer now! :mango:')
- #elif datetime.date.today() == datetime.date(2020, 9, 10):
- # await indy.send('Happy Birthday Indy. You\'re a boomer now! :mango:)
-
- # Ignore the above message. I got sick and tired of looking at trash code
-
+
+
for coolKid in coolKids:
if datetime.date.today() == coolKid[2]:
try:
@@ -178,7 +202,7 @@ class Utils(commands.Cog):
self.tries = 1
except:
self.tries +=1
-
+
for word in badWords:
if word in message.content.lower():
count += 1;
@@ -188,6 +212,7 @@ class Utils(commands.Cog):
@commands.cooldown(1, 60, commands.BucketType.member)
@commands.command()
async def report(self, ctx, *, message=None):
+ """Send a message to the super mods about anything"""
if ctx.message.guild != None:
await ctx.message.delete()
if message == None:
@@ -198,45 +223,10 @@ class Utils(commands.Cog):
@commands.cooldown(1, 20, commands.BucketType.member)
@commands.command()
async def leaderboard(self, ctx):
+ """Leaderboard of the people that matter"""
async with ctx.typing():
- DRIVER = '/usr/lib/chromium-browser/chromedriver'
- chrome_options = Options()
- chrome_options.add_argument("--disable-dev-shm-usage")
- chrome_options.add_argument("--headless")
- chrome_options.add_argument("--no-sandbox")
- chrome_options.add_argument("--disable-gpu")
- #chrome_options.binary_location = ""
- driver = webdriver.Chrome(DRIVER, chrome_options=chrome_options)
- set_viewport_size(driver, 1000, 1000)
- driver.get('https://aninternettroll.github.io/mcbeVerifierLeaderboard/')
- screenshot = driver.find_element_by_id('table').screenshot('leaderboard.png')
- driver.quit()
- #transparency time
- img = Image.open('leaderboard.png')
- img = img.convert("RGB")
- pallette = Image.open("palette.png")
- pallette = pallette.convert("P")
- img = img.quantize(colors=256, method=3, kmeans=0, palette=pallette)
- img = img.convert("RGBA")
- datas = img.getdata()
-
- newData = []
- for item in datas:
- if item[0] == 255 and item[1] == 255 and item[2] == 255:
- newData.append((255, 255, 255, 0))
- else:
- newData.append(item)
-
- img.putdata(newData)
- """
- img = img.filter(ImageFilter.SHARPEN)
- img = img.filter(ImageFilter.SHARPEN)
- img = img.filter(ImageFilter.SHARPEN)
- """
- #height, width = img.size
- #img = img.resize((height*10,width*10), resample=Image.BOX)
- img.save("leaderboard.png", "PNG")
-
+ lbFunc = functools.partial(save_leaderboard)
+ await self.bot.loop.run_in_executor(None, lbFunc)
await ctx.send(file=discord.File("leaderboard.png"))
@@ -245,72 +235,29 @@ class Utils(commands.Cog):
if isinstance(error, commands.CommandOnCooldown):
#return
await ctx.send(f"{ctx.message.author.display_name}, you have to wait {round(error.retry_after, 2)} seconds before using this again.")
-
- # Why? Because I can. lel
-
- # celeste guyToday at 6:13 PM
- # @Mango Man that's not how it works
-
- # Mango ManToday at 6:13 PM
- # it looks fine in lightmode
- # wait whats not how what works
-
- # celeste guyToday at 6:13 PM
- # the command
-
- # Mango ManToday at 6:13 PM
- # o
- # how does it work
-
- # celeste guyToday at 6:14 PM
- # Like for a start, nothing is defined
- # use ctx D:
-
- # Mango ManToday at 6:14 PM
- # Do I need to though?
-
- # celeste guyToday at 6:14 PM
- # ctx.guild.members() or something
- # Yes, server is not a thing
- # 2nd, mention is not used like that
- # You still have to send a message
- # And mention in the message
-
- # Mango ManToday at 6:14 PM
- # o
-
- # celeste guyToday at 6:15 PM
- # 3rd, don't forget to import choice from random
-
- # Mango ManToday at 6:15 PM
- # this is why you dont steal code from github
- # I actually feel embarrased over forgetting to import random
-
- # celeste guyToday at 6:15 PM
- # 4th, add ctx in the arguments list, or you'll get an error like "function takes 1 argument but 2 were given"
- # And you will use it to send the message and get the server
- # Also forgetting the import is the least embarrassing thing
- # Since I did remove it
- # And replaced with import randint from random
-
+
+ @commands.cooldown(1, 60, commands.BucketType.guild)
@commands.command()
async def someone(self, ctx):
- blacklist = [536071288859656193]
- if ctx.channel.id != 589110766578434078:
- if ctx.author.id == 395872198323077121:
- await ctx.send("grape is a bitch")
- elif ctx.author.id == 521153476714299402:
- await ctx.send("ZMG is smooth brain")
- elif ctx.author.id == 199070670221475842:
- await ctx.send(f"fuck you {ctx.message.author.mention}")
- elif ctx.author.id in blacklist:
- await ctx.send("not even bothering with a message for you. You're just an edgy sheep")
- else:
- await ctx.send(choice(ctx.guild.members).mention)
+ """Discord's mistake"""
+ if ctx.channel.id != int(self.bot.config[str(ctx.message.guild.id)]["fair_channel"]):
+ await ctx.send(choice(ctx.guild.members).mention)
@commands.command()
async def roll(self, ctx, pool):
+ """Toll the dice"""
await ctx.send(f"You rolled a {randint(0, int(pool))}")
+ @commands.command(aliases=['commands', 'allcommands'])
+ async def listcommands(self, ctx):
+ """List all custom commands"""
+ with open('custom_commands.json', 'r') as f:
+ commands = json.load(f)
+ output = '```List of custom commands:\n'
+ for key in commands:
+ output += f'{key}, '
+ output += '```'
+ await ctx.send(output)
+
def setup(bot):
bot.add_cog(Utils(bot))