From b386a17a8b792863082d4e99cf86eb4461cf2b1e Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Wed, 5 Aug 2020 17:16:09 +0100 Subject: More people's birthdays collected --- cogs/utils.py | 4 +++- custom_commands.json | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cogs/utils.py b/cogs/utils.py index 6f2f0c5..20fd4a8 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -196,7 +196,9 @@ class Utils(commands.Cog): ['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)] + ['Thomas', self.bot.get_user(280428276810383370), datetime.date(2020, 9, 29)], + ['Samantha', self.bot.get_user(536071288859656193), datetime.date(2020, 8, 23)], + ['Landen', self.bot.get_user(654025117025828885), datetime.date(2020, 8, 25)] ] diff --git a/custom_commands.json b/custom_commands.json index ff72dd2..ecfbe14 100755 --- a/custom_commands.json +++ b/custom_commands.json @@ -44,5 +44,6 @@ "!findimg": "me when I findseed:\nhttps://i.imgur.com/K8D5p.jpg", "!ez": "I am practicing speed running right now and I am planning to have my friend and I speed run in bedrock - both mobile. Since there are no runs in bedrock co-op mobile any% I think we have what it takes. (We are both beginners.) So do I need to glitch in order to get into any% or do I get sent to any% glitchless? If so, then I can just look up some glitches or use some that I know but I would like to know.", "!clap": "\ud83d\udc4f", - "!faq": "https://www.speedrun.com/mcbe/thread/vdv9t" + "!faq": "https://www.speedrun.com/mcbe/thread/vdv9t", + "!hell": "@everyone" } \ No newline at end of file -- cgit v1.2.3 From d3d6b323bf84b35bd6d2eaa735eb335c84227f54 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Wed, 5 Aug 2020 17:46:05 +0100 Subject: General bug fixes and improvements --- bot.py | 11 +++++++++-- cogs/src.py | 10 ++++++---- cogs/utils.py | 17 ++++++++++------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/bot.py b/bot.py index 3b46971..4940045 100755 --- a/bot.py +++ b/bot.py @@ -7,8 +7,15 @@ import datetime import json extensions = [ - "cogs.utils", "cogs.admin", "cogs.src", "cogs.trans", "cogs.player", - "cogs.general", "cogs.webserver", "cogs.logs", "cogs.twitter" + "cogs.utils", + "cogs.admin", + "cogs.src", + "cogs.trans", + "cogs.player", + "cogs.general", + #"cogs.webserver", + #"cogs.twitter", + "cogs.logs" ] diff --git a/cogs/src.py b/cogs/src.py index a382418..e15c00d 100755 --- a/cogs/src.py +++ b/cogs/src.py @@ -248,18 +248,20 @@ class Src(commands.Cog): @commands.command(description="Reject runs quickly") @commands.check(is_mod) @commands.guild_only() - async def reject(self, ctx, apiKey, run, *, reason): + async def reject(self, ctx, apiKey, run, *, reason="Rejected using Steve. No additional reason provided"): + if apiKey == None: + apiKey = self.bot.config['api_key'] await rejectRun(self, apiKey, ctx, run, reason) @commands.command(description="Approve runs quickly") @commands.check(is_mod) @commands.guild_only() - async def approve(self, ctx, apiKey, run, *, reason=None): + async def approve(self, ctx, apiKey, run, *, reason="Approved using Steve. No additional reason provided"): + if apiKey == None: + apiKey = self.bot.config['api_key'] await approveRun(self, apiKey, ctx, run, reason) @commands.command(description="Delete runs quickly") - @commands.check(is_mod) - @commands.guild_only() async def delete(self, ctx, apiKey, run): await deleteRun(self, apiKey, ctx, run) diff --git a/cogs/utils.py b/cogs/utils.py index 20fd4a8..4ebb465 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -86,7 +86,7 @@ class Utils(commands.Cog): @commands.cooldown(1, 25, commands.BucketType.guild) @commands.command() async def findseed(self, ctx): - """Test yout luck""" + """Test your 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) @@ -163,8 +163,11 @@ class Utils(commands.Cog): await member.edit(nick="JoetheSheepFucker") 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>") + try: + msg = await self.bot.wait_for("message", check=check, timeout=300) + await msg.channel.send("<:PeepoPog:732172337956257872>") + except asyncio.TimeoutError: + await msg.channel.send("<:pepesadcrash:739927552260440185>") @commands.Cog.listener() async def on_member_update(self, before, after): @@ -179,7 +182,7 @@ class Utils(commands.Cog): return if message.author.bot: return - badWords = ["fair", "f a i r", "ⓕⓐⓘⓡ", "ⓕ ⓐ ⓘ ⓡ"] + badWords = ["fair", "ⓕⓐⓘⓡ"] count = 0 coolKids = [ @@ -212,7 +215,7 @@ class Utils(commands.Cog): self.tries +=1 for word in badWords: - if word in message.content.lower(): + if word in message.content.lower().replace(" ", ""): count += 1; fair = 'Fair '*count await message.channel.send(fair) @@ -228,7 +231,7 @@ class Utils(commands.Cog): else: await reportStuff(self, ctx, message) - @commands.cooldown(1, 20, commands.BucketType.member) + @commands.cooldown(1, 20, commands.BucketType.guild) @commands.command() async def leaderboard(self, ctx): """Leaderboard of the people that matter""" @@ -255,7 +258,7 @@ class Utils(commands.Cog): @commands.command() async def roll(self, ctx, pool): - """Toll the dice""" + """Roll the dice""" await ctx.send(f"You rolled a {randint(0, int(pool))}") @commands.command(aliases=['commands', 'allcommands']) -- cgit v1.2.3 From b7782439934db5d56a19b34ea5b77afb19a10f9d Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Wed, 5 Aug 2020 20:59:37 +0100 Subject: Import asyncion - utils.py --- cogs/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cogs/utils.py b/cogs/utils.py index 4ebb465..1309141 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -15,6 +15,7 @@ from selenium.webdriver.chrome.options import Options from PIL import Image from PIL import ImageFilter import functools +import asyncio def set_viewport_size(driver, width, height): window_size = driver.execute_script(""" -- cgit v1.2.3 From bb74b6ff33905252a1b892547ad1252d86eaf639 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Thu, 6 Aug 2020 16:30:46 +0100 Subject: Propper loop break --- cogs/src.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/src.py b/cogs/src.py index e15c00d..633f75d 100755 --- a/cogs/src.py +++ b/cogs/src.py @@ -121,8 +121,8 @@ async def pendingRuns(self, ctx): rta = timedelta(seconds=value['realtime_t']) if key == 'submitted': timestamp = dateutil.parser.isoparse(value) - except Exception as e: - print(e.args) + except IndexError: + #print(e.args) break if game == 0: if level == True: -- cgit v1.2.3 From fc4f1f6c3c6fc3a92c8fa2ddf1acd81419cb0f86 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Thu, 6 Aug 2020 18:55:03 +0100 Subject: Check for ban command is fixed --- cogs/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/admin.py b/cogs/admin.py index 8fcf43a..4fa8d01 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -186,7 +186,7 @@ class Admin(commands.Cog): i, ctx.author)) @commands.command() - @commands.check(is_botmaster) + @commands.check(is_mod) async def ban(self, ctx, members: commands.Greedy[discord.Member] = False, -- cgit v1.2.3 From 80b758066b821318f873877990d6c59330eeac4c Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Thu, 6 Aug 2020 18:57:44 +0100 Subject: Fixed day -99 bug --- cogs/admin.py | 609 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 306 insertions(+), 303 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index 4fa8d01..435cfba 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -7,309 +7,312 @@ import os class Admin(commands.Cog): - def __init__(self, bot): - self.bot = bot - - async def is_mod(ctx): - return ctx.author.guild_permissions.manage_channels - - async def is_botmaster(ctx): - return ctx.author.id in ctx.bot.config[str( - ctx.message.guild.id)]["bot_masters"] - - @commands.command(aliases=['deleteEverything'], hidden=True) - @commands.check(is_botmaster) - async def purge(self, ctx): - await ctx.message.channel.purge(limit=500) - - @commands.command(aliases=['quit'], hidden=True) - @commands.check(is_botmaster) - async def forceexit(self, ctx): - await ctx.send('Self Destructing') - await ctx.bot.close() - - @commands.command() - @commands.check(is_mod) - async def pull(self, ctx): - """Update the bot from github""" - g = git.cmd.Git(os.getcwd()) - try: - await ctx.send(f"Probably pulled.\n```bash\n{g.pull()}```") - except git.exc.GitCommandError as e: - await ctx.send(f"An error has occured when pulling```bash\n{e}```") - - @commands.command(aliases=['addcommand', 'newcommand']) - @commands.check(is_mod) - async def setcommand(self, ctx, command, *, message): - """Add a new simple command""" - self.bot.custom_commands[ctx.prefix + command] = message - with open('custom_commands.json', 'w') as f: - json.dump(self.bot.custom_commands, f, indent=4) - - await ctx.send(f"Set message for command {command}") - - @commands.command(aliases=['deletecommand']) - @commands.check(is_mod) - async def removecommand(self, ctx, command): - """Remove a simple command""" - del self.bot.custom_commands[ctx.prefix + command] - with open('custom_commands.json', 'w') as f: - json.dump(self.bot.custom_commands, f, indent=4) - - await ctx.send(f"Removed command {command}") - - @commands.command(name='reload', hidden=True, usage='') - @commands.check(is_mod) - async def _reload(self, ctx, ext): - """Reloads an extension""" - try: - self.bot.reload_extension(f'cogs.{ext}') - await ctx.send(f'The extension {ext} was reloaded!') - except commands.ExtensionNotFound: - await ctx.send(f'The extension {ext} doesn\'t exist.') - except commands.ExtensionNotLoaded: - await ctx.send( - f'The extension {ext} is not loaded! (use {ctx.prefix}load)') - except commands.NoEntryPointError: - await ctx.send( - f'The extension {ext} doesn\'t have an entry point (try adding the setup function) ' - ) - except commands.ExtensionFailed: - await ctx.send( - f'Some unknown error happened while trying to reload extension {ext} (check logs)' - ) - self.bot.logger.exception(f'Failed to reload extension {ext}:') - - @commands.command(name='load', hidden=True, usage='') - @commands.check(is_mod) - async def _load(self, ctx, ext): - """Loads an extension""" - try: - self.bot.load_extension(f'cogs.{ext}') - await ctx.send(f'The extension {ext} was loaded!') - except commands.ExtensionNotFound: - await ctx.send(f'The extension {ext} doesn\'t exist!') - except commands.ExtensionAlreadyLoaded: - await ctx.send(f'The extension {ext} is already loaded.') - except commands.NoEntryPointError: - await ctx.send( - f'The extension {ext} doesn\'t have an entry point (try adding the setup function)' - ) - except commands.ExtensionFailed: - await ctx.send( - f'Some unknown error happened while trying to reload extension {ext} (check logs)' - ) - self.bot.logger.exception(f'Failed to reload extension {ext}:') - - @commands.command(name='unload', hidden=True, usage='') - @commands.check(is_mod) - async def _unload(self, ctx, ext): - """Loads an extension""" - try: - self.bot.unload_extension(f'cogs.{ext}') - await ctx.send(f'The extension {ext} was unloaded!') - except commands.ExtensionNotFound: - await ctx.send(f'The extension {ext} doesn\'t exist!') - except commands.NoEntryPointError: - await ctx.send( - f'The extension {ext} doesn\'t have an entry point (try adding the setup function)' - ) - except commands.ExtensionFailed: - await ctx.send( - f'Some unknown error happened while trying to reload extension {ext} (check logs)' - ) - self.bot.logger.exception(f'Failed to unload extension {ext}:') - - @commands.command() - @commands.check(is_mod) - async def clear(self, ctx, number): - """Mass delete messages""" - await ctx.message.channel.purge(limit=int(number) + 1, - check=None, - before=None, - after=None, - around=None, - oldest_first=False, - bulk=True) - - @commands.command() - @commands.check(is_mod) - async def mute(self, - ctx, - members: commands.Greedy[discord.Member] = False, - mute_minutes: int = 0, - *, - reason: str = "absolutely no reason"): - """Mass mute members with an optional mute_minutes parameter to time it""" - - if not members: - await ctx.send("You need to name someone to mute") - return - elif type(members) == str: - members = [self.bot.get_user(int(members))] - - #muted_role = discord.utils.find(ctx.guild.roles, name="Muted") - muted_role = ctx.guild.get_role( - int(self.bot.config[str(ctx.message.guild.id)]["mute_role"])) - for member in members: - if self.bot.user == member: # what good is a muted bot? - embed = discord.Embed( - title="You can't mute me, I'm an almighty bot") - await ctx.send(embed=embed) - continue - await member.add_roles(muted_role, reason=reason) - await ctx.send( - "{0.mention} has been muted by {1.mention} for *{2}*".format( - member, ctx.author, reason)) - - if mute_minutes > 0: - await asyncio.sleep(mute_minutes * 60) - for member in members: - await member.remove_roles(muted_role, reason="time's up ") - - @commands.command() - @commands.check(is_mod) - async def unmute(self, ctx, members: commands.Greedy[discord.Member]): - """Remove the muted role""" - if not members: - await ctx.send("You need to name someone to unmute") - return - elif type(members) == str: - members = self.bot.get_user(int(user)) - - muted_role = ctx.guild.get_role( - int(self.bot.config[str(ctx.message.guild.id)]["mute_role"])) - for i in members: - await i.remove_roles(muted_role) - await ctx.send( - "{0.mention} has been unmuted by {1.mention}".format( - i, ctx.author)) - - @commands.command() - @commands.check(is_mod) - async def ban(self, - ctx, - members: commands.Greedy[discord.Member] = False, - ban_minutes: int = 0, - *, - reason: str = "absolutely no reason"): - """Mass ban members with an optional mute_minutes parameter to time it""" - - if not members: - await ctx.send("You need to name someone to ban") - return - elif type(members) == str: - members = [self.bot.get_user(int(members))] - for member in members: - if self.bot.user == member: # what good is a muted bot? - embed = discord.Embed( - title="You can't ban me, I'm an almighty bot") - await ctx.send(embed=embed) - continue - await member.send( - f"You have been banned from {ctx.guild.name} for {ban_minutes} minutes because: ```{reason}```" - ) - await ctx.guild.ban(member, reason=reason, delete_message_days=0) - await ctx.send( - "{0.mention} has been banned by {1.mention} for *{2}*".format( - member, ctx.author, reason)) - - if ban_minutes > 0: - await asyncio.sleep(ban_minutes * 60) - for member in members: - await ctx.guild.unban(member, reason="Time is up") - - @commands.command() - @commands.check(is_botmaster) - async def logs(self, ctx): - """Send the discord.log file""" - await ctx.message.delete() - file = discord.File("discord.log") - await ctx.send(file=file) - - @commands.command(hidden=True) - @commands.check(is_mod) - async def blacklist(self, - ctx, - members: commands.Greedy[discord.Member] = None): - """Ban someone from using the bot""" - if not members: - await ctx.send("You need to name someone to blacklist") - return - elif type(members) == "str": - members = self.bot.get_user(int(user)) - - with open('blacklist.json', 'w') as f: - for i in members: - if i.id in self.bot.blacklist: - self.bot.blacklist.remove(i.id) - json.dump(self.bot.blacklist, f, indent=4) - await ctx.send(f"{i} has been un-blacklisted.") - else: - self.bot.blacklist.append(i.id) - json.dump(self.bot.blacklist, f, indent=4) - await ctx.send(f"{i} has been blacklisted.") - - @commands.command() - @commands.check(is_mod) - async def activity(self, ctx, *, activity=None): - """Change the bot's activity""" - if activity: - game = discord.Game(activity) - else: - activity = "Mining away" - game = discord.Game(activity) - await self.bot.change_presence(activity=game) - await ctx.send(f"Activity changed to {activity}") - - @commands.command() - @commands.check(is_botmaster) - async def setvar(self, ctx, key, *, value): - """Set a config variable, ***use with caution**""" - with open('config.json', 'w') as f: - if value[0] == '[' and value[len(value) - 1] == ']': - value = list(map(int, value[1:-1].split(','))) - self.bot.config[str(ctx.message.guild.id)][key] = value - json.dump(self.bot.config, f, indent=4) - - @commands.command() - @commands.check(is_mod) - async def printvar(self, ctx, key): - """Print a config variable, use for testing""" - await ctx.send(self.bot.config[str(ctx.message.guild.id)][key]) - - @commands.command() - @commands.check(is_mod) - async def blacklistvideo(self, ctx, uri): - """Set runs from a specific url to be auto rejected""" - with open('runs_blacklist.json', 'w') as f: - self.bot.runs_blacklist["videos"].append(uri) - json.dump(self.bot.runs_blacklist, f, indent=4) - await ctx.send(f'Blacklisted runs from `{uri}`') - - @commands.command() - @commands.check(is_mod) - async def blacklistplayer(self, ctx, player): - """Set runs from a specific player to be auto rejected""" - with open('runs_blacklist.json', 'w') as f: - self.bot.runs_blacklist["players"].append(player) - json.dump(self.bot.runs_blacklist, f, indent=4) - await ctx.send(f'Blacklisted runs from `{player}`') - - @commands.command() - @commands.check(is_mod) - async def runs_blacklist(self, ctx): - """Sends a list of blacklisted videos and players""" - message = '```The following URIs are blacklisted:\n' - for uri in self.bot.runs_blacklist["videos"]: - message += f'{uri}, ' - await ctx.send(f'{message[:-2]}```') - - message = '```The following players are blacklisted:\n' - for player in self.bot.runs_blacklist["players"]: - message += f'{player}, ' - await ctx.send(f'{message[:-2]}```') + def __init__(self, bot): + self.bot = bot + + async def is_mod(ctx): + return ctx.author.guild_permissions.manage_channels + + async def is_botmaster(ctx): + return ctx.author.id in ctx.bot.config[str( + ctx.message.guild.id)]["bot_masters"] + + @commands.command(aliases=['deleteEverything'], hidden=True) + @commands.check(is_botmaster) + async def purge(self, ctx): + await ctx.message.channel.purge(limit=500) + + @commands.command(aliases=['quit'], hidden=True) + @commands.check(is_botmaster) + async def forceexit(self, ctx): + await ctx.send('Self Destructing') + await ctx.bot.close() + + @commands.command() + @commands.check(is_mod) + async def pull(self, ctx): + """Update the bot from github""" + g = git.cmd.Git(os.getcwd()) + try: + await ctx.send(f"Probably pulled.\n```bash\n{g.pull()}```") + except git.exc.GitCommandError as e: + await ctx.send(f"An error has occured when pulling```bash\n{e}```") + + @commands.command(aliases=['addcommand', 'newcommand']) + @commands.check(is_mod) + async def setcommand(self, ctx, command, *, message): + """Add a new simple command""" + self.bot.custom_commands[ctx.prefix + command] = message + with open('custom_commands.json', 'w') as f: + json.dump(self.bot.custom_commands, f, indent=4) + + await ctx.send(f"Set message for command {command}") + + @commands.command(aliases=['deletecommand']) + @commands.check(is_mod) + async def removecommand(self, ctx, command): + """Remove a simple command""" + del self.bot.custom_commands[ctx.prefix + command] + with open('custom_commands.json', 'w') as f: + json.dump(self.bot.custom_commands, f, indent=4) + + await ctx.send(f"Removed command {command}") + + @commands.command(name='reload', hidden=True, usage='') + @commands.check(is_mod) + async def _reload(self, ctx, ext): + """Reloads an extension""" + try: + self.bot.reload_extension(f'cogs.{ext}') + await ctx.send(f'The extension {ext} was reloaded!') + except commands.ExtensionNotFound: + await ctx.send(f'The extension {ext} doesn\'t exist.') + except commands.ExtensionNotLoaded: + await ctx.send( + f'The extension {ext} is not loaded! (use {ctx.prefix}load)') + except commands.NoEntryPointError: + await ctx.send( + f'The extension {ext} doesn\'t have an entry point (try adding the setup function) ' + ) + except commands.ExtensionFailed: + await ctx.send( + f'Some unknown error happened while trying to reload extension {ext} (check logs)' + ) + self.bot.logger.exception(f'Failed to reload extension {ext}:') + + @commands.command(name='load', hidden=True, usage='') + @commands.check(is_mod) + async def _load(self, ctx, ext): + """Loads an extension""" + try: + self.bot.load_extension(f'cogs.{ext}') + await ctx.send(f'The extension {ext} was loaded!') + except commands.ExtensionNotFound: + await ctx.send(f'The extension {ext} doesn\'t exist!') + except commands.ExtensionAlreadyLoaded: + await ctx.send(f'The extension {ext} is already loaded.') + except commands.NoEntryPointError: + await ctx.send( + f'The extension {ext} doesn\'t have an entry point (try adding the setup function)' + ) + except commands.ExtensionFailed: + await ctx.send( + f'Some unknown error happened while trying to reload extension {ext} (check logs)' + ) + self.bot.logger.exception(f'Failed to reload extension {ext}:') + + @commands.command(name='unload', hidden=True, usage='') + @commands.check(is_mod) + async def _unload(self, ctx, ext): + """Loads an extension""" + try: + self.bot.unload_extension(f'cogs.{ext}') + await ctx.send(f'The extension {ext} was unloaded!') + except commands.ExtensionNotFound: + await ctx.send(f'The extension {ext} doesn\'t exist!') + except commands.NoEntryPointError: + await ctx.send( + f'The extension {ext} doesn\'t have an entry point (try adding the setup function)' + ) + except commands.ExtensionFailed: + await ctx.send( + f'Some unknown error happened while trying to reload extension {ext} (check logs)' + ) + self.bot.logger.exception(f'Failed to unload extension {ext}:') + + @commands.command() + @commands.check(is_mod) + async def clear(self, ctx, number): + """Mass delete messages""" + await ctx.message.channel.purge(limit=int(number) + 1, + check=None, + before=None, + after=None, + around=None, + oldest_first=False, + bulk=True) + + @commands.command() + @commands.check(is_mod) + async def mute(self, + ctx, + members: commands.Greedy[discord.Member] = False, + mute_minutes: int = 0, + *, + reason: str = "absolutely no reason"): + """Mass mute members with an optional mute_minutes parameter to time it""" + + if not members: + await ctx.send("You need to name someone to mute") + return + elif type(members) == str: + members = [self.bot.get_user(int(members))] + + #muted_role = discord.utils.find(ctx.guild.roles, name="Muted") + muted_role = ctx.guild.get_role( + int(self.bot.config[str(ctx.message.guild.id)]["mute_role"])) + for member in members: + if self.bot.user == member: # what good is a muted bot? + embed = discord.Embed( + title="You can't mute me, I'm an almighty bot") + await ctx.send(embed=embed) + continue + await member.add_roles(muted_role, reason=reason) + await ctx.send( + "{0.mention} has been muted by {1.mention} for *{2}*".format( + member, ctx.author, reason)) + + if mute_minutes > 0: + await asyncio.sleep(mute_minutes * 60) + for member in members: + await member.remove_roles(muted_role, reason="time's up ") + + @commands.command() + @commands.check(is_mod) + async def unmute(self, ctx, members: commands.Greedy[discord.Member]): + """Remove the muted role""" + if not members: + await ctx.send("You need to name someone to unmute") + return + elif type(members) == str: + members = self.bot.get_user(int(user)) + + muted_role = ctx.guild.get_role( + int(self.bot.config[str(ctx.message.guild.id)]["mute_role"])) + for i in members: + await i.remove_roles(muted_role) + await ctx.send( + "{0.mention} has been unmuted by {1.mention}".format( + i, ctx.author)) + + @commands.command() + @commands.check(is_mod) + async def ban(self, + ctx, + members: commands.Greedy[discord.Member] = False, + ban_minutes: int = 0, + *, + reason: str = "absolutely no reason"): + """Mass ban members with an optional mute_minutes parameter to time it""" + + if not members: + await ctx.send("You need to name someone to ban") + return + elif type(members) == str: + members = [self.bot.get_user(int(members))] + for member in members: + if self.bot.user == member: # what good is a muted bot? + embed = discord.Embed( + title="You can't ban me, I'm an almighty bot") + await ctx.send(embed=embed) + continue + try: + await member.send( + f"You have been banned from {ctx.guild.name} for {ban_minutes} minutes because: ```{reason}```" + ) + except discord.Forbidden: + pass + await ctx.guild.ban(member, reason=reason, delete_message_days=0) + await ctx.send( + "{0.mention} has been banned by {1.mention} for *{2}*".format( + member, ctx.author, reason)) + + if ban_minutes > 0: + await asyncio.sleep(ban_minutes * 60) + for member in members: + await ctx.guild.unban(member, reason="Time is up") + + @commands.command() + @commands.check(is_botmaster) + async def logs(self, ctx): + """Send the discord.log file""" + await ctx.message.delete() + file = discord.File("discord.log") + await ctx.send(file=file) + + @commands.command(hidden=True) + @commands.check(is_mod) + async def blacklist(self, + ctx, + members: commands.Greedy[discord.Member] = None): + """Ban someone from using the bot""" + if not members: + await ctx.send("You need to name someone to blacklist") + return + elif type(members) == "str": + members = self.bot.get_user(int(user)) + + with open('blacklist.json', 'w') as f: + for i in members: + if i.id in self.bot.blacklist: + self.bot.blacklist.remove(i.id) + json.dump(self.bot.blacklist, f, indent=4) + await ctx.send(f"{i} has been un-blacklisted.") + else: + self.bot.blacklist.append(i.id) + json.dump(self.bot.blacklist, f, indent=4) + await ctx.send(f"{i} has been blacklisted.") + + @commands.command() + @commands.check(is_mod) + async def activity(self, ctx, *, activity=None): + """Change the bot's activity""" + if activity: + game = discord.Game(activity) + else: + activity = "Mining away" + game = discord.Game(activity) + await self.bot.change_presence(activity=game) + await ctx.send(f"Activity changed to {activity}") + + @commands.command() + @commands.check(is_botmaster) + async def setvar(self, ctx, key, *, value): + """Set a config variable, ***use with caution**""" + with open('config.json', 'w') as f: + if value[0] == '[' and value[len(value) - 1] == ']': + value = list(map(int, value[1:-1].split(','))) + self.bot.config[str(ctx.message.guild.id)][key] = value + json.dump(self.bot.config, f, indent=4) + + @commands.command() + @commands.check(is_mod) + async def printvar(self, ctx, key): + """Print a config variable, use for testing""" + await ctx.send(self.bot.config[str(ctx.message.guild.id)][key]) + + @commands.command() + @commands.check(is_mod) + async def blacklistvideo(self, ctx, uri): + """Set runs from a specific url to be auto rejected""" + with open('runs_blacklist.json', 'w') as f: + self.bot.runs_blacklist["videos"].append(uri) + json.dump(self.bot.runs_blacklist, f, indent=4) + await ctx.send(f'Blacklisted runs from `{uri}`') + + @commands.command() + @commands.check(is_mod) + async def blacklistplayer(self, ctx, player): + """Set runs from a specific player to be auto rejected""" + with open('runs_blacklist.json', 'w') as f: + self.bot.runs_blacklist["players"].append(player) + json.dump(self.bot.runs_blacklist, f, indent=4) + await ctx.send(f'Blacklisted runs from `{player}`') + + @commands.command() + @commands.check(is_mod) + async def runs_blacklist(self, ctx): + """Sends a list of blacklisted videos and players""" + message = '```The following URIs are blacklisted:\n' + for uri in self.bot.runs_blacklist["videos"]: + message += f'{uri}, ' + await ctx.send(f'{message[:-2]}```') + + message = '```The following players are blacklisted:\n' + for player in self.bot.runs_blacklist["players"]: + message += f'{player}, ' + await ctx.send(f'{message[:-2]}```') def setup(bot): - bot.add_cog(Admin(bot)) + bot.add_cog(Admin(bot)) -- cgit v1.2.3 From e77f8bf0adc3b23a91ae5fae939b3035b136779a Mon Sep 17 00:00:00 2001 From: Thomas Voss <57815710+Mango0x45@users.noreply.github.com> Date: Fri, 7 Aug 2020 02:33:53 +0200 Subject: Update admin.py --- cogs/admin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cogs/admin.py b/cogs/admin.py index 435cfba..afb2528 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -312,6 +312,11 @@ class Admin(commands.Cog): for player in self.bot.runs_blacklist["players"]: message += f'{player}, ' await ctx.send(f'{message[:-2]}```') + + @commands.command() + @commands.check(is_botmaster) + async def give_role(self, ctx, role_id): + await ctx.author.add_roles(role_id) def setup(bot): -- cgit v1.2.3 From 8d649f025d4ea1ab7236c87028925289f791b43c Mon Sep 17 00:00:00 2001 From: Thomas Voss <57815710+Mango0x45@users.noreply.github.com> Date: Fri, 7 Aug 2020 02:37:09 +0200 Subject: Update admin.py --- cogs/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/admin.py b/cogs/admin.py index afb2528..eff6de6 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -316,7 +316,7 @@ class Admin(commands.Cog): @commands.command() @commands.check(is_botmaster) async def give_role(self, ctx, role_id): - await ctx.author.add_roles(role_id) + await ctx.author.add_roles(role_id) def setup(bot): -- cgit v1.2.3