From c13e9c3846b8653deadb5fe6bb8ae8701c52e5fe Mon Sep 17 00:00:00 2001 From: mango0x45 Date: Tue, 9 Jun 2020 23:56:01 +0200 Subject: Added listcommands() --- cogs/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cogs/utils.py b/cogs/utils.py index 27fd708..5492c14 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -312,5 +312,15 @@ class Utils(commands.Cog): async def roll(self, ctx, pool): await ctx.send(f"You rolled a {randint(0, int(pool))}") + @commands.command(aliases=['commands', 'allcommands']) + async def listcommands(self, ctx): + 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)) -- cgit v1.2.3 From b889beaa39fb60adb81c422fc9ccc30b3ebd8293 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Thu, 11 Jun 2020 21:22:49 +0200 Subject: minor fixes and !serverinfo --- .gitignore | 0 .vscode/settings.json | 0 bot.py | 0 cogs/admin.py | 0 cogs/general.py | 38 ++++++++++++++++++++++++++++++++++---- cogs/help.py | 0 cogs/logs.py | 6 +++++- cogs/player.py | 0 cogs/src.py | 0 cogs/trans.py | 0 cogs/utils.py | 10 +++++----- custom_commands.json | 6 +++--- main.py | 0 palette.png | Bin 14 files changed, 47 insertions(+), 13 deletions(-) mode change 100755 => 100644 .gitignore mode change 100755 => 100644 .vscode/settings.json mode change 100755 => 100644 bot.py mode change 100755 => 100644 cogs/admin.py mode change 100755 => 100644 cogs/general.py mode change 100755 => 100644 cogs/help.py mode change 100755 => 100644 cogs/logs.py mode change 100755 => 100644 cogs/player.py mode change 100755 => 100644 cogs/src.py mode change 100755 => 100644 cogs/trans.py mode change 100755 => 100644 cogs/utils.py mode change 100755 => 100644 custom_commands.json mode change 100755 => 100644 main.py mode change 100755 => 100644 palette.png diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/.vscode/settings.json b/.vscode/settings.json old mode 100755 new mode 100644 diff --git a/bot.py b/bot.py old mode 100755 new mode 100644 diff --git a/cogs/admin.py b/cogs/admin.py old mode 100755 new mode 100644 diff --git a/cogs/general.py b/cogs/general.py old mode 100755 new mode 100644 index ff60bb7..ccc4b28 --- a/cogs/general.py +++ b/cogs/general.py @@ -20,8 +20,6 @@ class General(commands.Cog): if not user: user = ctx.message.author - elif type(user)=="str": - user = self.bot.get_user(int(user)) # Very very shit """ @@ -38,8 +36,12 @@ class General(commands.Cog): for i in user.roles: output += i.mention + if user.color.value == 0: + color = 16777210 + else: + color = user.color - embed=discord.Embed(title=user.name, description=user.mention, color=user.color, timestamp=ctx.message.created_at) + embed=discord.Embed(title=user.name, description=user.mention, color=color, timestamp=ctx.message.created_at) #embed.set_thumbnail(url="attachment://temp.webp") embed.set_thumbnail(url=user.avatar_url) embed.set_image(url="attachment://temp.png") @@ -54,7 +56,7 @@ class General(commands.Cog): #os.remove("temp.png") @commands.command() - async def coop(self, ctx, user: discord.Member=None): + async def coop(self, ctx, *, user: discord.Member=None): if not user: user = ctx.message.author elif type(user)=="str": @@ -69,5 +71,33 @@ class General(commands.Cog): await user.add_roles(coop_role) await ctx.send("You are now in the coop gang") + @commands.command() + async def serverinfo(self, ctx, guild=None): + if not guild: + guild = ctx.message.guild + else: + print(type(guild)) + guild = self.bot.get_guild(int(guild)) + + if guild.owner.color.value == 0: + color = 16777210 + else: + color = guild.owner.color + + emojiList = " " + for i in guild.emojis: + emojiList += str(i) + " " + + embed=discord.Embed(title=guild.name, description=guild.description, color=color, timestamp=ctx.message.created_at) + #embed.set_thumbnail(url="attachment://temp.webp") + embed.set_thumbnail(url=guild.icon_url) + embed.set_image(url=guild.splash_url) + embed.add_field(name="Created on", value=guild.created_at.date(), inline=True) + embed.add_field(name="Members", value=guild.member_count, inline=True) + embed.add_field(name="Emojis", value=emojiList, inline=True) + embed.add_field(name="Owner", value=guild.owner.mention, inline=True) + embed.set_footer(text=f"ID: {guild.id}") + await ctx.send(embed=embed) + def setup(bot): bot.add_cog(General(bot)) diff --git a/cogs/help.py b/cogs/help.py old mode 100755 new mode 100644 diff --git a/cogs/logs.py b/cogs/logs.py old mode 100755 new mode 100644 index ea3870a..c6f18b5 --- a/cogs/logs.py +++ b/cogs/logs.py @@ -10,10 +10,14 @@ class Logs(commands.Cog): async def on_message_delete(self, message): if message.guild.id != 574267523869179904: return + if message.author.color.value == 0: + color = 16777210 + else: + color = message.author.color channel = self.bot.get_channel(718187032869994686) embed = discord.Embed( title='Deleted Message', - color=message.author.color, + color=message, timestamp=message.created_at ) embed.add_field( diff --git a/cogs/player.py b/cogs/player.py old mode 100755 new mode 100644 diff --git a/cogs/src.py b/cogs/src.py old mode 100755 new mode 100644 diff --git a/cogs/trans.py b/cogs/trans.py old mode 100755 new mode 100644 diff --git a/cogs/utils.py b/cogs/utils.py old mode 100755 new mode 100644 index 5492c14..c708e54 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -67,8 +67,8 @@ 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") + discname = ctx.message.author.name.replace("@", "@ ") + await ctx.send(f"{discname} -> your seed is a {totalEyes} eye") @findseed.error async def findseed_handler(self,ctx,error): @@ -98,11 +98,11 @@ 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} -> " + msg = f"{ctx.message.author.name} -> " # Optional TODO: Create non-normal distribution sleepHrs = randint(0, 24) @@ -115,7 +115,7 @@ class Utils(commands.Cog): # Add extra comment based on number of sleepHrs if sleepHrs == 0: - msg += "- nice try \:D" + msg += "- nice try \\:D" elif sleepHrs <= 5: msg += f"- {lessSleepMsg[randint(0, len(lessSleepMsg) - 1)]}" elif sleepHrs >= 10: diff --git a/custom_commands.json b/custom_commands.json old mode 100755 new mode 100644 index c87825f..6ed04ce --- a/custom_commands.json +++ b/custom_commands.json @@ -20,7 +20,6 @@ "/swipe": "not an alt", "!HereWeGo": "10 in a Row!", "/Make": "Troll Supermod", - "!h": "<@!199070670221475842> no swearing in this christian discord server", "/boards": "https://www.speedrun.com/mcbe", "/ban": "shut up", "/pending": "this annoys me", @@ -30,8 +29,9 @@ "!lenny": "( \u0361\u00b0 \u035c\u0296 \u0361\u00b0)", "!hwg": "10 iar", "!GlasgowRangers": "You Let Your Club Die!", - "!murray": "the irishest of the Irish", "!e\ud83c\udd71\ufe0fic": "HEY GUYS ITS SHIGAME45", "!testy": "test", - "!toxicitypass": "```TOXICITY PASS\n\nTHE HOLDER OF THIS PASS HAS PERMISSION FROM THE HEAVENS ABOVE TO DO AND SAY WHATEVER THE HELL THEY WANT\nTHEY ARE ALLOWED TO BE AS TOXIC AS THEY WILL WITHOUT REPERCUSSIONS\n\nPASS OWNER: Duck W aka Weexy aka Indy Kambeitz```" + "!toxicitypass": "```TOXICITY PASS\n\nTHE HOLDER OF THIS PASS HAS PERMISSION FROM THE HEAVENS ABOVE TO DO AND SAY WHATEVER THE HELL THEY WANT\nTHEY ARE ALLOWED TO BE AS TOXIC AS THEY WILL WITHOUT REPERCUSSIONS\n\nPASS OWNER: Duck W aka Weexy aka Indy Kambeitz```", + "!welcome": "Welcome! <:mango:715738087627685908>", + "!learntoread": "When two players are tied on the leaderboards **ONLY ONE FUCKER WILL BE VISIBLE**" } \ No newline at end of file diff --git a/main.py b/main.py old mode 100755 new mode 100644 diff --git a/palette.png b/palette.png old mode 100755 new mode 100644 -- cgit v1.2.3 From c87ade2e08b0117bd5a0db5611ce47287fbfb6de Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Sun, 14 Jun 2020 12:09:39 +0200 Subject: Better logging --- bot.py | 1 + cogs/admin.py | 2 +- cogs/general.py | 23 +++++------------------ cogs/logs.py | 5 ++++- cogs/src.py | 3 ++- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/bot.py b/bot.py index 2721110..ccd8d22 100644 --- a/bot.py +++ b/bot.py @@ -36,6 +36,7 @@ class BedrockBot(commands.Bot): def __init__(self): super().__init__(command_prefix=get_prefix, case_insensitive=True) self.logger = logging.getLogger('discord') + self.messageBlacklist = [] with open('custom_commands.json', 'r') as f: self.custom_commands = json.load(f) diff --git a/cogs/admin.py b/cogs/admin.py index 3cb7ff8..d722390 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -24,7 +24,7 @@ class Admin(commands.Cog): @commands.check(is_mod) async def forceexit(self, ctx, password): if password == "abort": - ctx.message.delete() + await ctx.message.delete() exit() @commands.command() diff --git a/cogs/general.py b/cogs/general.py index ccc4b28..2e25410 100644 --- a/cogs/general.py +++ b/cogs/general.py @@ -21,20 +21,9 @@ class General(commands.Cog): if not user: user = ctx.message.author - # Very very shit - """ - await ctx.send(str(user.avatar_url)) - request.urlretrieve(str(user.avatar_url), "temp.webp") - #filename = wget.download(user.avatar_url, out="temp.webp") - image = Image.open("temp.webp").convert("RGB") - image.save("temp.png", "PNG") - - f = discord.File("temp.png", filename="temp.png") - #await messagable.send(file=f, embed=e) - """ output = "" for i in user.roles: - output += i.mention + output += i.mention + " " if user.color.value == 0: color = 16777210 @@ -43,8 +32,7 @@ class General(commands.Cog): embed=discord.Embed(title=user.name, description=user.mention, color=color, timestamp=ctx.message.created_at) #embed.set_thumbnail(url="attachment://temp.webp") - embed.set_thumbnail(url=user.avatar_url) - embed.set_image(url="attachment://temp.png") + embed.set_thumbnail(url=user.avatar_url_as(format="png")) embed.add_field(name="Nickname", value=user.display_name, inline=False) embed.add_field(name="Joined on", value=user.joined_at.date(), inline=True) embed.add_field(name="Status", value=user.status, inline=True) @@ -59,7 +47,7 @@ class General(commands.Cog): async def coop(self, ctx, *, user: discord.Member=None): if not user: user = ctx.message.author - elif type(user)=="str": + else: user = self.bot.get_user(int(user)) coop_role = ctx.guild.get_role(694261282861219952) @@ -89,9 +77,8 @@ class General(commands.Cog): emojiList += str(i) + " " embed=discord.Embed(title=guild.name, description=guild.description, color=color, timestamp=ctx.message.created_at) - #embed.set_thumbnail(url="attachment://temp.webp") - embed.set_thumbnail(url=guild.icon_url) - embed.set_image(url=guild.splash_url) + embed.set_thumbnail(url=guild.icon_url_as(format="png")) + embed.set_image(url=guild.splash_url_as(format="png")) embed.add_field(name="Created on", value=guild.created_at.date(), inline=True) embed.add_field(name="Members", value=guild.member_count, inline=True) embed.add_field(name="Emojis", value=emojiList, inline=True) diff --git a/cogs/logs.py b/cogs/logs.py index c6f18b5..d6889eb 100644 --- a/cogs/logs.py +++ b/cogs/logs.py @@ -8,6 +8,9 @@ class Logs(commands.Cog): @commands.Cog.listener() async def on_message_delete(self, message): + if (message.id in self.bot.messageBlacklist): + self.bot.messageBlacklist.remove(message.id) + return if message.guild.id != 574267523869179904: return if message.author.color.value == 0: @@ -17,7 +20,7 @@ class Logs(commands.Cog): channel = self.bot.get_channel(718187032869994686) embed = discord.Embed( title='Deleted Message', - color=message, + color=color, timestamp=message.created_at ) embed.add_field( diff --git a/cogs/src.py b/cogs/src.py index 96bf53c..f0619d4 100644 --- a/cogs/src.py +++ b/cogs/src.py @@ -208,7 +208,7 @@ class Src(commands.Cog): @commands.guild_only() async def pending(self, ctx): async with ctx.typing(): - await clear(self) + await self.bot.get_channel(699713639866957905).purge() await pendingRuns(self, ctx) @commands.command(description="Reject runs quickly") @@ -231,6 +231,7 @@ class Src(commands.Cog): @commands.command() async def verify(self, ctx, apiKey=None, userID=None): + self.bot.messageBlacklist.append(ctx.message.id) #if apiKey == None: # await ctx.send(f"Please try again this command by getting an apiKey from https://www.speedrun.com/api/auth then do `{ctx.prefix}verify ` in my DMs or anywhere in this server. \nBe careful who you share this key with. To learn more check out https://github.com/speedruncomorg/api/blob/master/authentication.md") # return -- cgit v1.2.3 From 931d4706d20e3a14ac0bc93b8f22917f04506a01 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Wed, 17 Jun 2020 18:50:13 +0200 Subject: De-hardcoded utils, general and logs. The problem left is src. --- .gitignore | 2 +- bot.py | 7 +++++-- cogs/admin.py | 27 +++++++++++++++++++++++++-- cogs/general.py | 2 +- cogs/logs.py | 4 ++-- cogs/utils.py | 17 ++++++++--------- custom_commands.json | 6 ++++-- 7 files changed, 46 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index e63e2cc..e40241a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ __pycache__ -config.py +config.json discord.log api_keys.json .vscode/ diff --git a/bot.py b/bot.py index ccd8d22..533b99d 100644 --- a/bot.py +++ b/bot.py @@ -3,7 +3,6 @@ import discord import logging import datetime -import config import json extensions = [ @@ -44,6 +43,10 @@ class BedrockBot(commands.Bot): for extension in extensions: self.load_extension(extension) + with open('config.json', 'r') as f: + self.config = json.load(f) + config = self.config + async def on_ready(self): self.uptime = datetime.datetime.utcnow() @@ -78,4 +81,4 @@ class BedrockBot(commands.Bot): return def run(self): - super().run(config.token, reconnect=True) + super().run(self.config["token"], reconnect=True) diff --git a/cogs/admin.py b/cogs/admin.py index d722390..13cb75b 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -134,7 +134,7 @@ class Admin(commands.Cog): members = self.bot.get_user(int(user)) #muted_role = discord.utils.find(ctx.guild.roles, name="Muted") - muted_role = ctx.guild.get_role(707707894694412371) + muted_role = ctx.guild.get_role(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") @@ -157,7 +157,7 @@ class Admin(commands.Cog): elif type(members)=="str": members = self.bot.get_user(int(user)) - muted_role = ctx.guild.get_role(707707894694412371) + muted_role = ctx.guild.get_role(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)) @@ -190,6 +190,29 @@ class Admin(commands.Cog): json.dump(self.bot.blacklist, f, indent=4) await ctx.send(f"{i} has been blacklisted.") + @commands.check(is_mod) + @commands.command() + async def activity(self, ctx,*, activity=None): + 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.check(is_mod) + @commands.command() + async def setvar(self, ctx, key, *, value): + with open('config.json', 'w') as f: + self.bot.config[str(ctx.message.guild.id)][key] = value + json.dump(self.bot.config, f, indent=4) + + @commands.check(is_mod) + @commands.command() + async def printvar(self, ctx, key): + await ctx.send(self.bot.config[str(ctx.message.guild.id)][key]) + def setup(bot): bot.add_cog(Admin(bot)) diff --git a/cogs/general.py b/cogs/general.py index 2e25410..0847cd4 100644 --- a/cogs/general.py +++ b/cogs/general.py @@ -50,7 +50,7 @@ class General(commands.Cog): else: user = self.bot.get_user(int(user)) - coop_role = ctx.guild.get_role(694261282861219952) + coop_role = ctx.guild.get_role(int(self.bot.config[str(ctx.message.guild.id)]["coop_roleID"])) if coop_role in user.roles: await user.remove_roles(coop_role) diff --git a/cogs/logs.py b/cogs/logs.py index d6889eb..8230ccc 100644 --- a/cogs/logs.py +++ b/cogs/logs.py @@ -17,7 +17,7 @@ class Logs(commands.Cog): color = 16777210 else: color = message.author.color - channel = self.bot.get_channel(718187032869994686) + channel = self.bot.get_channel(int(self.bot.config[str(message.guild.id)]["logs_channel"])) embed = discord.Embed( title='Deleted Message', color=color, @@ -34,7 +34,7 @@ class Logs(commands.Cog): async def on_message_edit(self, before, after): if after.guild.id != 574267523869179904: return - channel = self.bot.get_channel(718187032869994686) + channel = self.bot.get_channel(int(self.bot.config[str(before.guild.id)]["logs_channel"])) if before.author.color.value == 0: color = 16777210 else: diff --git a/cogs/utils.py b/cogs/utils.py index c708e54..1deab42 100644 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -25,7 +25,7 @@ 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(self.bot.config[str(ctx.message.guild.id)]["report_channel"]) embed = discord.Embed( title=f"Report from {ctx.message.author}", @@ -48,7 +48,7 @@ class Utils(commands.Cog): @commands.cooldown(1, 25, commands.BucketType.guild) @commands.command() async def findseed(self, ctx): - if ctx.message.channel.id != 684787316489060422: + if ctx.message.channel.id != int(self.bot.config[str(ctx.message.guild.id)]["bot_channel"]): await ctx.message.delete() return @@ -67,13 +67,12 @@ class Utils(commands.Cog): randomness = randint(1, 10) if randomness <= 1: totalEyes += 1 - discname = ctx.message.author.name.replace("@", "@ ") - await ctx.send(f"{discname} -> 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"]): await ctx.message.delete() return else: @@ -82,7 +81,7 @@ class Utils(commands.Cog): @commands.command() async def findsleep(self, ctx): - if ctx.message.channel.id != 684787316489060422: + if ctx.message.channel.id != int(self.bot.config[str(ctx.message.guild.id)]["bot_channel"]): await ctx.message.delete() return @@ -102,7 +101,7 @@ class Utils(commands.Cog): ] # Set up initial message - msg = f"{ctx.message.author.name} -> " + msg = f"{discord.utils.escape_mentions(ctx.message.author.display_name)} -> " # Optional TODO: Create non-normal distribution sleepHrs = randint(0, 24) @@ -125,7 +124,7 @@ class Utils(commands.Cog): @commands.Cog.listener() async def on_message(self, message): - if message.channel.id != 589110766578434078: + if message.channel.id != int(self.bot.config[str(message.guild.id)]["fair_channel"]): return if message.author.bot: return @@ -296,7 +295,7 @@ class Utils(commands.Cog): @commands.command() async def someone(self, ctx): blacklist = [536071288859656193] - if ctx.channel.id != 589110766578434078: + if ctx.channel.id != int(self.bot.config[str(ctx.message.guild.id)]["fair_channel"]): if ctx.author.id == 395872198323077121: await ctx.send("grape is a bitch") elif ctx.author.id == 521153476714299402: diff --git a/custom_commands.json b/custom_commands.json index 6ed04ce..3ea311b 100644 --- a/custom_commands.json +++ b/custom_commands.json @@ -1,5 +1,4 @@ { - "!sr.c": "https://www.speedrun.com/mcbe", "/Troll": "is Super at his job", "/src": "https://www.speedrun.com/mcbe", "!Walk-On-through-the-Wind": "Walk On through the rain", @@ -33,5 +32,8 @@ "!testy": "test", "!toxicitypass": "```TOXICITY PASS\n\nTHE HOLDER OF THIS PASS HAS PERMISSION FROM THE HEAVENS ABOVE TO DO AND SAY WHATEVER THE HELL THEY WANT\nTHEY ARE ALLOWED TO BE AS TOXIC AS THEY WILL WITHOUT REPERCUSSIONS\n\nPASS OWNER: Duck W aka Weexy aka Indy Kambeitz```", "!welcome": "Welcome! <:mango:715738087627685908>", - "!learntoread": "When two players are tied on the leaderboards **ONLY ONE FUCKER WILL BE VISIBLE**" + "!learntoread": "When two players are tied on the leaderboards **ONLY ONE FUCKER WILL BE VISIBLE**", + "!src": "https://www.speedrun.com/mcbe", + "!mobiledupe": "1) place item to dupe in the crafting grid\n2) keep pressed until the green bar thing appears\nclick any \"Impossible\" craft (red ones)\n3)press the item to dupe (that is in your hotbar now -> it should have moved there since you pressed the impossible craft)\n4)your item should be duped", + "!source": "https://github.com/AnInternetTroll/mcbeDiscordBot" } \ No newline at end of file -- cgit v1.2.3 From c2974768028af1cf9973c77835e614f8ab1835de Mon Sep 17 00:00:00 2001 From: Skycloudd <51929172+Skycloudd@users.noreply.github.com> Date: Sat, 20 Jun 2020 22:04:13 +0200 Subject: fixed TypeError in on_message_edit When an embed gets loaded, discord sends out the message edited event, and because of that it gets weird. so you just check if the content of the message actually changed, and that should fix it. --- cogs/logs.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cogs/logs.py b/cogs/logs.py index 8230ccc..c1b3a49 100644 --- a/cogs/logs.py +++ b/cogs/logs.py @@ -32,6 +32,9 @@ class Logs(commands.Cog): @commands.Cog.listener() async def on_message_edit(self, before, after): + if before.content == after.content: + return + if after.guild.id != 574267523869179904: return channel = self.bot.get_channel(int(self.bot.config[str(before.guild.id)]["logs_channel"])) -- cgit v1.2.3 From 452cc8c997a47e95415a54b7130e70b37ee23266 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Sun, 21 Jun 2020 13:05:46 +0100 Subject: modified: cogs/logs.py --- .gitignore | 0 .vscode/settings.json | 0 bot.py | 0 cogs/admin.py | 0 cogs/general.py | 0 cogs/help.py | 0 cogs/logs.py | 0 cogs/player.py | 0 cogs/src.py | 0 cogs/trans.py | 0 cogs/utils.py | 0 custom_commands.json | 0 main.py | 0 palette.png | Bin 14 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .vscode/settings.json mode change 100644 => 100755 bot.py mode change 100644 => 100755 cogs/admin.py mode change 100644 => 100755 cogs/general.py mode change 100644 => 100755 cogs/help.py mode change 100644 => 100755 cogs/logs.py mode change 100644 => 100755 cogs/player.py mode change 100644 => 100755 cogs/src.py mode change 100644 => 100755 cogs/trans.py mode change 100644 => 100755 cogs/utils.py mode change 100644 => 100755 custom_commands.json mode change 100644 => 100755 main.py mode change 100644 => 100755 palette.png diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.vscode/settings.json b/.vscode/settings.json old mode 100644 new mode 100755 diff --git a/bot.py b/bot.py old mode 100644 new mode 100755 diff --git a/cogs/admin.py b/cogs/admin.py old mode 100644 new mode 100755 diff --git a/cogs/general.py b/cogs/general.py old mode 100644 new mode 100755 diff --git a/cogs/help.py b/cogs/help.py old mode 100644 new mode 100755 diff --git a/cogs/logs.py b/cogs/logs.py old mode 100644 new mode 100755 diff --git a/cogs/player.py b/cogs/player.py old mode 100644 new mode 100755 diff --git a/cogs/src.py b/cogs/src.py old mode 100644 new mode 100755 diff --git a/cogs/trans.py b/cogs/trans.py old mode 100644 new mode 100755 diff --git a/cogs/utils.py b/cogs/utils.py old mode 100644 new mode 100755 diff --git a/custom_commands.json b/custom_commands.json old mode 100644 new mode 100755 diff --git a/main.py b/main.py old mode 100644 new mode 100755 diff --git a/palette.png b/palette.png old mode 100644 new mode 100755 -- cgit v1.2.3 From f3980a879c78acf924772e35e2aa79903c6007af Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Sun, 21 Jun 2020 16:23:46 +0100 Subject: Fixed mute command --- cogs/admin.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index 13cb75b..1fb424e 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -130,11 +130,11 @@ class Admin(commands.Cog): if not members: await ctx.send("You need to name someone to mute") return - elif type(members)=="str": - members = self.bot.get_user(int(user)) + 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(self.bot.config[str(ctx.message.guild.id)]["mute_role"]) + 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") @@ -154,10 +154,10 @@ class Admin(commands.Cog): if not members: await ctx.send("You need to name someone to unmute") return - elif type(members)=="str": + elif type(members)==str: members = self.bot.get_user(int(user)) - muted_role = ctx.guild.get_role(self.bot.config[str(ctx.message.guild.id)]["mute_role"]) + 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)) -- cgit v1.2.3 From f8c516caf74dc316a99bffaf3749fa5fc2ee34c4 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Sun, 21 Jun 2020 22:36:55 +0200 Subject: Made findsleep more efficient --- cogs/utils.py | 74 +++++++++++++++++++++++++++-------------------------------- 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/cogs/utils.py b/cogs/utils.py index 1deab42..a1f1b7e 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -29,7 +29,7 @@ async def reportStuff(self, ctx, message): 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) @@ -51,7 +51,7 @@ class Utils(commands.Cog): if ctx.message.channel.id != int(self.bot.config[str(ctx.message.guild.id)]["bot_channel"]): await ctx.message.delete() return - + # Don't ask rigged_findseed = { 280428276810383370: 12, # Thomas's User ID @@ -99,28 +99,21 @@ class Utils(commands.Cog): "wake up, muffin head", "psst... coffeeee \\:D" ] - - # Set up initial message - msg = f"{discord.utils.escape_mentions(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" - 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 == 0: + await ctx.send(f"{ctx.message.author.display_name} -> your sleep is 0 hours long - nice try \:D") + elif sleepHrs <= 5: + if sleepHrs == 1: + s = 's' + else: + s = '' + await ctx.send(f"{ctx.message.author.display_name} -> your sleep is {sleepHrs} hour{s} long - {lessSleepMsg[randint(0, len(lessSleepMsg) - 1)]}") + else sleepHrs >= 10: + 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_message(self, message): @@ -130,13 +123,14 @@ class Utils(commands.Cog): 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)], # 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 @@ -144,14 +138,14 @@ class Utils(commands.Cog): ['Scott', self.bot.get_user(223937483774230528), datetime.date(2020, 6, 23)], ['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): @@ -166,9 +160,9 @@ class Utils(commands.Cog): # 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: @@ -177,7 +171,7 @@ class Utils(commands.Cog): self.tries = 1 except: self.tries +=1 - + for word in badWords: if word in message.content.lower(): count += 1; @@ -244,54 +238,54 @@ 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.command() async def someone(self, ctx): blacklist = [536071288859656193] -- cgit v1.2.3 From 61bdd05ad6637ed5875136d346e6d79e0c53b292 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Sun, 21 Jun 2020 22:40:18 +0200 Subject: tabs pls --- cogs/utils.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cogs/utils.py b/cogs/utils.py index a1f1b7e..05c7317 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -104,16 +104,16 @@ class Utils(commands.Cog): sleepHrs = randint(0, 24) # Add extra comment based on number of sleepHrs - if sleepHrs == 0: - await ctx.send(f"{ctx.message.author.display_name} -> your sleep is 0 hours long - nice try \:D") - elif sleepHrs <= 5: - if sleepHrs == 1: - s = 's' - else: - s = '' - await ctx.send(f"{ctx.message.author.display_name} -> your sleep is {sleepHrs} hour{s} long - {lessSleepMsg[randint(0, len(lessSleepMsg) - 1)]}") - else sleepHrs >= 10: - await ctx.send(f"{ctx.message.author.display_name} -> your sleep is {sleepHrs} hours long - {moreSleepMsg[randint(0, len(moreSleepMsg) - 1)]}") + if sleepHrs == 0: + await ctx.send(f"{ctx.message.author.display_name} -> your sleep is 0 hours long - nice try \:D") + elif sleepHrs <= 5: + if sleepHrs == 1: + s = 's' + else: + s = '' + await ctx.send(f"{ctx.message.author.display_name} -> your sleep is {sleepHrs} hour{s} long - {lessSleepMsg[randint(0, len(lessSleepMsg) - 1)]}") + else sleepHrs >= 10: + 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_message(self, message): @@ -130,7 +130,7 @@ class Utils(commands.Cog): ['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)], + ['Mistaken', self.bot.get_user(264121998173536256), datetime.date(2020, 7, 6)], ['Murray', self.bot.get_user(400344183333847060), datetime.date(2020, 11, 10)], # 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 -- cgit v1.2.3 From 2b03c10d2fe20d6269903755a726eb9ded34c60e Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Sun, 21 Jun 2020 22:43:23 +0200 Subject: fixed the dumb --- cogs/utils.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cogs/utils.py b/cogs/utils.py index 05c7317..f0e3572 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -104,16 +104,16 @@ class Utils(commands.Cog): sleepHrs = randint(0, 24) # Add extra comment based on number of sleepHrs - if sleepHrs == 0: - await ctx.send(f"{ctx.message.author.display_name} -> your sleep is 0 hours long - nice try \:D") - elif sleepHrs <= 5: - if sleepHrs == 1: - s = 's' - else: - s = '' - await ctx.send(f"{ctx.message.author.display_name} -> your sleep is {sleepHrs} hour{s} long - {lessSleepMsg[randint(0, len(lessSleepMsg) - 1)]}") - else sleepHrs >= 10: - await ctx.send(f"{ctx.message.author.display_name} -> your sleep is {sleepHrs} hours long - {moreSleepMsg[randint(0, len(moreSleepMsg) - 1)]}") + if sleepHrs == 0: + await ctx.send(f"{ctx.message.author.display_name} -> your sleep is 0 hours long - nice try \:D") + elif sleepHrs <= 5: + if sleepHrs == 1: + s = 's' + else: + 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_message(self, message): -- cgit v1.2.3 From 7b98566622e79ff19d6181c0a7065e19b94d8552 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Tue, 23 Jun 2020 18:45:15 +0200 Subject: added sky to utils --- cogs/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cogs/utils.py b/cogs/utils.py index f0e3572..057d7d9 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -130,12 +130,13 @@ class Utils(commands.Cog): ['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)], + ['Mistaken', self.bot.get_user(264121998173536256), datetime.date(2020, 7, 6)], ['Murray', self.bot.get_user(400344183333847060), datetime.date(2020, 11, 10)], # 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)] ] -- cgit v1.2.3 From 3c6471ad50372df8de50f19f7ff67676149dfd9f Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Tue, 23 Jun 2020 18:53:14 +0200 Subject: i dont remember what I did to this file but apparantly its not the same --- cogs/utils.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/cogs/utils.py b/cogs/utils.py index 057d7d9..f45a5e7 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -141,29 +141,6 @@ class Utils(commands.Cog): ] - # 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: -- cgit v1.2.3 From fafb376f68d00ef9021ab62670697065833f68df Mon Sep 17 00:00:00 2001 From: Thomas Voss <57815710+Mango0x45@users.noreply.github.com> Date: Wed, 24 Jun 2020 09:25:38 +0200 Subject: Update utils.py --- cogs/utils.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cogs/utils.py b/cogs/utils.py index f45a5e7..90498e6 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -143,12 +143,7 @@ class Utils(commands.Cog): for coolKid in coolKids: if datetime.date.today() == coolKid[2]: - try: - for i in range(self.tries): - await coolKid[1].send(f'Happy Birthday {coolKid[0]}! You\'re a boomer now! :mango:') - self.tries = 1 - except: - self.tries +=1 + await coolKid[1].send(f'Happy Birthday {coolKid[0]}! You\'re a boomer now! :mango:') for word in badWords: if word in message.content.lower(): -- cgit v1.2.3 From d6003027fdee8ff2cfa13c6bb90cc2dd627ef7ea Mon Sep 17 00:00:00 2001 From: Thomas Voss <57815710+Mango0x45@users.noreply.github.com> Date: Wed, 24 Jun 2020 09:29:19 +0200 Subject: Update utils.py --- cogs/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cogs/utils.py b/cogs/utils.py index 90498e6..f45a5e7 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -143,7 +143,12 @@ class Utils(commands.Cog): for coolKid in coolKids: if datetime.date.today() == coolKid[2]: - await coolKid[1].send(f'Happy Birthday {coolKid[0]}! You\'re a boomer now! :mango:') + try: + for i in range(self.tries): + await coolKid[1].send(f'Happy Birthday {coolKid[0]}! You\'re a boomer now! :mango:') + self.tries = 1 + except: + self.tries +=1 for word in badWords: if word in message.content.lower(): -- cgit v1.2.3 From 36615c6185d158739040a93fd5ab73ddb5b65687 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Wed, 24 Jun 2020 08:31:08 +0100 Subject: modified: cogs/utils.py --- cogs/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cogs/utils.py b/cogs/utils.py index f0e3572..a95e0a6 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -50,6 +50,7 @@ class Utils(commands.Cog): async def findseed(self, ctx): 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 @@ -73,6 +74,7 @@ class Utils(commands.Cog): async def findseed_handler(self,ctx,error): if isinstance(error, commands.CommandOnCooldown): 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: -- cgit v1.2.3 From 1e40b69dc9523f2bb7092f034e452c14e0ac777f Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Wed, 24 Jun 2020 09:45:14 +0200 Subject: Updated the secret --- cogs/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cogs/utils.py b/cogs/utils.py index e20c2c7..10c6195 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -134,6 +134,7 @@ class Utils(commands.Cog): ['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, 24)], -- cgit v1.2.3 From ec297f3e8e944a522eeda33e0f797ed98b55ab20 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Wed, 24 Jun 2020 20:26:29 +0200 Subject: Cleaned up @someone --- cogs/utils.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/cogs/utils.py b/cogs/utils.py index 10c6195..cbcf973 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -267,20 +267,10 @@ class Utils(commands.Cog): # Since I did remove it # And replaced with import randint from random - @commands.command() - async def someone(self, ctx): - blacklist = [536071288859656193] - if ctx.channel.id != int(self.bot.config[str(ctx.message.guild.id)]["fair_channel"]): - 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) + @commands.command() + async def someone(self, ctx): + 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): -- cgit v1.2.3 From 114dee26597b561161d7c005e1789ff06f6ce989 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Wed, 24 Jun 2020 19:49:54 +0100 Subject: modified: cogs/utils.py --- cogs/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/utils.py b/cogs/utils.py index 10c6195..931e54a 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -25,7 +25,7 @@ def set_viewport_size(driver, width, height): driver.set_window_size(*window_size) async def reportStuff(self, ctx, message): - channel = self.bot.get_channel(self.bot.config[str(ctx.message.guild.id)]["report_channel"]) + 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}", -- cgit v1.2.3 From bd7f8454785c8c014637e9d685a5b876615b90ba Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 00:39:04 +0200 Subject: fixed faulty logic --- cogs/utils.py | 51 ++------------------------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/cogs/utils.py b/cogs/utils.py index cbcf973..2d3ffbe 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -110,9 +110,9 @@ class Utils(commands.Cog): await ctx.send(f"{ctx.message.author.display_name} -> your sleep is 0 hours long - nice try \:D") elif sleepHrs <= 5: if sleepHrs == 1: - s = 's' - else: 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)]}") @@ -220,53 +220,6 @@ class Utils(commands.Cog): #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.command() async def someone(self, ctx): if ctx.channel.id != int(self.bot.config[str(ctx.message.guild.id)]["fair_channel"]): -- cgit v1.2.3 From 72611a078b4b7164ebd19334070243b4c35d000c Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 00:41:11 +0200 Subject: idk some spacing thing --- cogs/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/utils.py b/cogs/utils.py index 2d3ffbe..5d96d49 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -112,8 +112,8 @@ class Utils(commands.Cog): 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)]}") + 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)]}") -- cgit v1.2.3 From d8e9800ce11cbc4dae5129a1ebf4ba3f808bee18 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 00:43:57 +0200 Subject: vim sucks with spacing --- cogs/utils.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cogs/utils.py b/cogs/utils.py index 5d96d49..fd1554b 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -107,13 +107,13 @@ class Utils(commands.Cog): # Add extra comment based on number of sleepHrs if sleepHrs == 0: - await ctx.send(f"{ctx.message.author.display_name} -> your sleep is 0 hours long - nice try \:D") + await ctx.send(f"{ctx.message.author.display_name} -> your sleep is 0 hours long - nice try \:D") elif sleepHrs <= 5: 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)]}") + 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)]}") @@ -134,12 +134,12 @@ class Utils(commands.Cog): ['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)], + ['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, 24)], ['Scott', self.bot.get_user(223937483774230528), datetime.date(2020, 6, 23)], - ['Sky', self.bot.get_user(329538915805691905), datetime.date(2020, 6, 24)], + ['Sky', self.bot.get_user(329538915805691905), datetime.date(2020, 6, 24)], ['Thomas', self.bot.get_user(280428276810383370), datetime.date(2020, 9, 29)] ] @@ -220,10 +220,10 @@ class Utils(commands.Cog): #return await ctx.send(f"{ctx.message.author.display_name}, you have to wait {round(error.retry_after, 2)} seconds before using this again.") - @commands.command() - async def someone(self, ctx): - 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 someone(self, ctx): + 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): -- cgit v1.2.3 From 7077496c9a7bee48692787515e93b98d61229598 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 09:29:28 +0200 Subject: fixed spacing --- cogs/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cogs/utils.py b/cogs/utils.py index fd1554b..c02ebda 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -220,10 +220,10 @@ class Utils(commands.Cog): #return await ctx.send(f"{ctx.message.author.display_name}, you have to wait {round(error.retry_after, 2)} seconds before using this again.") - @commands.command() - async def someone(self, ctx): - 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 someone(self, ctx): + 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): -- cgit v1.2.3 From 3c7c0f5aaaebcc207611de3b638bdbfe189decb3 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 09:37:34 +0200 Subject: removed some useless spaces --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 9f713bf..13bc0f0 100755 --- a/main.py +++ b/main.py @@ -29,9 +29,9 @@ def run_bot(): bot.run() if __name__ == "__main__": - + init_colorama(autoreset=True) setup_logging() - + run_bot() -- cgit v1.2.3 From dc18a6097c4cf19a22c1dc20bb18a29b89773db5 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 09:38:10 +0200 Subject: increased efficiency by using an or statement --- bot.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 533b99d..d67dc3c 100755 --- a/bot.py +++ b/bot.py @@ -63,9 +63,7 @@ class BedrockBot(commands.Bot): async def on_message(self, message): - if message.author.bot: - return - if message.author.id in self.blacklist: + if message.author.bot or message.author.id in self.blacklist: return await self.process_commands(message) -- cgit v1.2.3 From 4e2ee83356af6b50d06f990930dea16f6c19a9b1 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 09:39:08 +0200 Subject: removed a space --- custom_commands.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_commands.json b/custom_commands.json index 3ea311b..736cda3 100755 --- a/custom_commands.json +++ b/custom_commands.json @@ -36,4 +36,4 @@ "!src": "https://www.speedrun.com/mcbe", "!mobiledupe": "1) place item to dupe in the crafting grid\n2) keep pressed until the green bar thing appears\nclick any \"Impossible\" craft (red ones)\n3)press the item to dupe (that is in your hotbar now -> it should have moved there since you pressed the impossible craft)\n4)your item should be duped", "!source": "https://github.com/AnInternetTroll/mcbeDiscordBot" -} \ No newline at end of file +} -- cgit v1.2.3 From 1c1c6ac503758c30f478d44e05c0a458ccad6e4c Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 10:55:36 +0200 Subject: removed useless spaces --- cogs/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/admin.py b/cogs/admin.py index 1fb424e..14bd45e 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -12,7 +12,7 @@ class Admin(commands.Cog): async def is_mod(ctx): return ctx.author.guild_permissions.manage_channels - + @commands.command(aliases=['deleteEverything'], hidden=True) @commands.check(is_mod) async def purge(self, ctx, password): -- cgit v1.2.3 From 0cc41cc4778315ca7512588eec29a48cb314f20c Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 12:53:01 +0200 Subject: Removed passwords and added a bot master whitelist --- cogs/admin.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index 14bd45e..491180f 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -15,15 +15,15 @@ class Admin(commands.Cog): @commands.command(aliases=['deleteEverything'], hidden=True) @commands.check(is_mod) - async def purge(self, ctx, password): - if password == "MaxCantBeTrusted": + async def purge(self, ctx): + if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: async for msg in ctx.channel.history(): await msg.delete() @commands.command(aliases=['quit'], hidden=True) @commands.check(is_mod) - async def forceexit(self, ctx, password): - if password == "abort": + async def forceexit(self, ctx): + if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: await ctx.message.delete() exit() @@ -50,8 +50,8 @@ class Admin(commands.Cog): json.dump(self.bot.custom_commands, f, indent=4) await ctx.send(f"Removed command {command}") - - + + @commands.check(is_mod) @commands.command(name='reload', hidden=True, usage='') async def _reload(self, ctx, ext): @@ -68,7 +68,7 @@ class Admin(commands.Cog): 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.check(is_mod) @commands.command(name='load', hidden=True, usage='') async def _load(self, ctx, ext): -- cgit v1.2.3 From d4d2a2a0d9815baca24051f51397e5ed268f2ff5 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 13:03:04 +0200 Subject: tabs pls --- cogs/admin.py | 392 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 196 insertions(+), 196 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index 491180f..2cb2782 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -7,212 +7,212 @@ import git import os class Admin(commands.Cog): - def __init__(self, bot): - self.bot = bot + def __init__(self, bot): + self.bot = bot - async def is_mod(ctx): - return ctx.author.guild_permissions.manage_channels + async def is_mod(ctx): + return ctx.author.guild_permissions.manage_channels @commands.command(aliases=['deleteEverything'], hidden=True) @commands.check(is_mod) async def purge(self, ctx): - if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: - async for msg in ctx.channel.history(): - await msg.delete() - - @commands.command(aliases=['quit'], hidden=True) - @commands.check(is_mod) - async def forceexit(self, ctx): if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: - await ctx.message.delete() - exit() - - @commands.command() - @commands.check(is_mod) - async def pull(self, ctx): - g = git.cmd.Git(os.getcwd()) - await ctx.send(f"Probably pulled.\n```bash\n{g.pull()}```") - - @commands.command(aliases=['addcommand', 'newcommand']) - @commands.check(is_mod) - async def setcommand(self, ctx, command, *, message): - 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): - 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.check(is_mod) - @commands.command(name='reload', hidden=True, usage='') - 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 realoaded!') # Oceanlight told me too - 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.check(is_mod) - @commands.command(name='load', hidden=True, usage='') - 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.check(is_mod) - @commands.command(name='unload', hidden=True, usage='') - 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 connect(self, ctx): - await ctx.author.voice.channel.connect() - await ctx.send(f"Joined channel {ctx.author.voice.channel.name}") - - @commands.command() - @commands.check(is_mod) - async def disconnect(self, ctx): - await ctx.voice_client.disconnect() - await ctx.send(f"Left channel {ctx.author.voice.channel.name}") - """ - - @commands.command() - @commands.check(is_mod) - async def clear(self, ctx, number): - await ctx.message.channel.purge(limit=int(number)+1, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True) - - @commands.check(is_mod) - @commands.command() - 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.check(is_mod) - @commands.command() - async def unmute(self, ctx, members: commands.Greedy[discord.Member]): - 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 logs(self, ctx, *, password): - if password == "beep boop": - await ctx.message.delete() - file = discord.File("discord.log") - await ctx.send(file=file) + async for msg in ctx.channel.history(): + await msg.delete() - @commands.command(aliases=['ban'], hidden=True) - @commands.check(is_mod) - async def blacklist(self, ctx, members: commands.Greedy[discord.Member]=None): - 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.") + @commands.command(aliases=['quit'], hidden=True) + @commands.check(is_mod) + async def forceexit(self, ctx): + if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: + await ctx.message.delete() + exit() + + @commands.command() + @commands.check(is_mod) + async def pull(self, ctx): + g = git.cmd.Git(os.getcwd()) + await ctx.send(f"Probably pulled.\n```bash\n{g.pull()}```") + + @commands.command(aliases=['addcommand', 'newcommand']) + @commands.check(is_mod) + async def setcommand(self, ctx, command, *, message): + 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): + 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.check(is_mod) + @commands.command(name='reload', hidden=True, usage='') + 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 realoaded!') # Oceanlight told me too + 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.check(is_mod) + @commands.command(name='load', hidden=True, usage='') + 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.check(is_mod) + @commands.command(name='unload', hidden=True, usage='') + 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 connect(self, ctx): + await ctx.author.voice.channel.connect() + await ctx.send(f"Joined channel {ctx.author.voice.channel.name}") + + @commands.command() + @commands.check(is_mod) + async def disconnect(self, ctx): + await ctx.voice_client.disconnect() + await ctx.send(f"Left channel {ctx.author.voice.channel.name}") + """ + + @commands.command() + @commands.check(is_mod) + async def clear(self, ctx, number): + await ctx.message.channel.purge(limit=int(number)+1, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True) + + @commands.check(is_mod) + @commands.command() + 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.check(is_mod) + @commands.command() + async def unmute(self, ctx, members: commands.Greedy[discord.Member]): + 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 logs(self, ctx, *, password): + if password == "beep boop": + await ctx.message.delete() + file = discord.File("discord.log") + await ctx.send(file=file) + + @commands.command(aliases=['ban'], hidden=True) + @commands.check(is_mod) + async def blacklist(self, ctx, members: commands.Greedy[discord.Member]=None): + 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.check(is_mod) + @commands.command() + async def activity(self, ctx,*, activity=None): + if activity: + game = discord.Game(activity) else: - self.bot.blacklist.append(i.id) - json.dump(self.bot.blacklist, f, indent=4) - await ctx.send(f"{i} has been blacklisted.") + activity = "Mining away" + game = discord.Game(activity) + await self.bot.change_presence(activity=game) + await ctx.send(f"Activity changed to {activity}") - @commands.check(is_mod) - @commands.command() - async def activity(self, ctx,*, activity=None): - 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.check(is_mod) - @commands.command() - async def setvar(self, ctx, key, *, value): - with open('config.json', 'w') as f: - self.bot.config[str(ctx.message.guild.id)][key] = value - json.dump(self.bot.config, f, indent=4) + @commands.check(is_mod) + @commands.command() + async def setvar(self, ctx, key, *, value): + with open('config.json', 'w') as f: + self.bot.config[str(ctx.message.guild.id)][key] = value + json.dump(self.bot.config, f, indent=4) - @commands.check(is_mod) - @commands.command() - async def printvar(self, ctx, key): - await ctx.send(self.bot.config[str(ctx.message.guild.id)][key]) + @commands.check(is_mod) + @commands.command() + async def printvar(self, ctx, key): + await ctx.send(self.bot.config[str(ctx.message.guild.id)][key]) def setup(bot): - bot.add_cog(Admin(bot)) + bot.add_cog(Admin(bot)) -- cgit v1.2.3 From 04ad96bfad2dff3dc2a1a878e677d55cb6a8b07f Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 13:09:06 +0200 Subject: pls fix --- cogs/admin.py | 390 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 195 insertions(+), 195 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index 2cb2782..e03ce7d 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -7,212 +7,212 @@ import git import os class Admin(commands.Cog): - def __init__(self, bot): - self.bot = bot + def __init__(self, bot): + self.bot = bot - async def is_mod(ctx): - return ctx.author.guild_permissions.manage_channels + async def is_mod(ctx): + return ctx.author.guild_permissions.manage_channels @commands.command(aliases=['deleteEverything'], hidden=True) @commands.check(is_mod) async def purge(self, ctx): if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: - async for msg in ctx.channel.history(): + async for msg in ctx.channel.history(): await msg.delete() - @commands.command(aliases=['quit'], hidden=True) - @commands.check(is_mod) - async def forceexit(self, ctx): - if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: - await ctx.message.delete() - exit() - - @commands.command() - @commands.check(is_mod) - async def pull(self, ctx): - g = git.cmd.Git(os.getcwd()) - await ctx.send(f"Probably pulled.\n```bash\n{g.pull()}```") - - @commands.command(aliases=['addcommand', 'newcommand']) - @commands.check(is_mod) - async def setcommand(self, ctx, command, *, message): - 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): - 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.check(is_mod) - @commands.command(name='reload', hidden=True, usage='') - 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 realoaded!') # Oceanlight told me too - 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.check(is_mod) - @commands.command(name='load', hidden=True, usage='') - 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.check(is_mod) - @commands.command(name='unload', hidden=True, usage='') - 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 connect(self, ctx): - await ctx.author.voice.channel.connect() - await ctx.send(f"Joined channel {ctx.author.voice.channel.name}") - - @commands.command() - @commands.check(is_mod) - async def disconnect(self, ctx): - await ctx.voice_client.disconnect() - await ctx.send(f"Left channel {ctx.author.voice.channel.name}") - """ - - @commands.command() - @commands.check(is_mod) - async def clear(self, ctx, number): - await ctx.message.channel.purge(limit=int(number)+1, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True) - - @commands.check(is_mod) - @commands.command() - 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.check(is_mod) - @commands.command() - async def unmute(self, ctx, members: commands.Greedy[discord.Member]): - 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 logs(self, ctx, *, password): - if password == "beep boop": - await ctx.message.delete() - file = discord.File("discord.log") - await ctx.send(file=file) - - @commands.command(aliases=['ban'], hidden=True) - @commands.check(is_mod) - async def blacklist(self, ctx, members: commands.Greedy[discord.Member]=None): - 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.check(is_mod) - @commands.command() - async def activity(self, ctx,*, activity=None): - if activity: - game = discord.Game(activity) + @commands.command(aliases=['quit'], hidden=True) + @commands.check(is_mod) + async def forceexit(self, ctx): + if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: + await ctx.message.delete() + exit() + + @commands.command() + @commands.check(is_mod) + async def pull(self, ctx): + g = git.cmd.Git(os.getcwd()) + await ctx.send(f"Probably pulled.\n```bash\n{g.pull()}```") + + @commands.command(aliases=['addcommand', 'newcommand']) + @commands.check(is_mod) + async def setcommand(self, ctx, command, *, message): + 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): + 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.check(is_mod) + @commands.command(name='reload', hidden=True, usage='') + 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 realoaded!') # Oceanlight told me too + 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.check(is_mod) + @commands.command(name='load', hidden=True, usage='') + 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.check(is_mod) + @commands.command(name='unload', hidden=True, usage='') + 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 connect(self, ctx): + await ctx.author.voice.channel.connect() + await ctx.send(f"Joined channel {ctx.author.voice.channel.name}") + + @commands.command() + @commands.check(is_mod) + async def disconnect(self, ctx): + await ctx.voice_client.disconnect() + await ctx.send(f"Left channel {ctx.author.voice.channel.name}") + """ + + @commands.command() + @commands.check(is_mod) + async def clear(self, ctx, number): + await ctx.message.channel.purge(limit=int(number)+1, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True) + + @commands.check(is_mod) + @commands.command() + 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.check(is_mod) + @commands.command() + async def unmute(self, ctx, members: commands.Greedy[discord.Member]): + 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 logs(self, ctx, *, password): + if password == "beep boop": + await ctx.message.delete() + file = discord.File("discord.log") + await ctx.send(file=file) + + @commands.command(aliases=['ban'], hidden=True) + @commands.check(is_mod) + async def blacklist(self, ctx, members: commands.Greedy[discord.Member]=None): + 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: - activity = "Mining away" - game = discord.Game(activity) - await self.bot.change_presence(activity=game) - await ctx.send(f"Activity changed to {activity}") + self.bot.blacklist.append(i.id) + json.dump(self.bot.blacklist, f, indent=4) + await ctx.send(f"{i} has been blacklisted.") - @commands.check(is_mod) - @commands.command() - async def setvar(self, ctx, key, *, value): - with open('config.json', 'w') as f: - self.bot.config[str(ctx.message.guild.id)][key] = value - json.dump(self.bot.config, f, indent=4) + @commands.check(is_mod) + @commands.command() + async def activity(self, ctx,*, activity=None): + 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.check(is_mod) + @commands.command() + async def setvar(self, ctx, key, *, value): + with open('config.json', 'w') as f: + self.bot.config[str(ctx.message.guild.id)][key] = value + json.dump(self.bot.config, f, indent=4) - @commands.check(is_mod) - @commands.command() - async def printvar(self, ctx, key): - await ctx.send(self.bot.config[str(ctx.message.guild.id)][key]) + @commands.check(is_mod) + @commands.command() + async def printvar(self, ctx, key): + await ctx.send(self.bot.config[str(ctx.message.guild.id)][key]) def setup(bot): - bot.add_cog(Admin(bot)) + bot.add_cog(Admin(bot)) -- cgit v1.2.3 From a987a1405bad5c4e813c9b847d06ef62e1a13eae Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 13:35:53 +0200 Subject: set_var now supports lists --- cogs/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cogs/admin.py b/cogs/admin.py index e03ce7d..1623f49 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -51,7 +51,6 @@ class Admin(commands.Cog): await ctx.send(f"Removed command {command}") - @commands.check(is_mod) @commands.command(name='reload', hidden=True, usage='') async def _reload(self, ctx, ext): @@ -205,6 +204,8 @@ class Admin(commands.Cog): @commands.command() async def setvar(self, ctx, key, *, value): 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) -- cgit v1.2.3 From e4fe80b7b01d0c55f43427a0c1526123521999ef Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 13:52:58 +0200 Subject: Updated readme --- readme.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index f85b95e..71001e7 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,28 @@ # Minecraft Bedrock Discord Bot ## How to -Make a file called `config.py` and add a `token="DiscordToken"` variable in there. +Make a file called `config.json` and add +```json +{ + "token": "your_bot_token" +} +``` + Launch the bot with `python3 main.py` and you're ready to go. Unless dependencies. Dependencies are google cloud and discord. +Install the dependencies with `python -m pip install -r requirements.txt` + +A few "dangerous" commands such as `!purge` are restriced to `bot_masters`, to add a bot master add it to `config.json`. Example: +```json +{ + "token": "your_bot_token", + "bot_masters": 280428276810383370 +} +``` +You can also use lists, for example: `"bot_masters": [280428276810383370, 99457716614885376]` + +Once you add yourself as a botmaster, you will be able to edit the config via discord with the command `!setvar ` +`!setvar` also supports lists which can be added like so: `!setvar [, ]` + This bot was built as a fork of [celesteBot](https://github.com/CelesteClassic/celestebot), so a lot of code is recycled. Feel free to make a pull request or use the code here. -- cgit v1.2.3 From 91b46dd095d5c55ae8f71b54f4da027933098e18 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 13:55:03 +0200 Subject: Updated readme --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 71001e7..3260466 100644 --- a/readme.md +++ b/readme.md @@ -21,8 +21,8 @@ A few "dangerous" commands such as `!purge` are restriced to `bot_masters`, to a ``` You can also use lists, for example: `"bot_masters": [280428276810383370, 99457716614885376]` -Once you add yourself as a botmaster, you will be able to edit the config via discord with the command `!setvar ` +Once you add yourself as a botmaster, you will be able to edit the config via discord with the command `!setvar ` `!setvar` also supports lists which can be added like so: `!setvar [, ]` -This bot was built as a fork of [celesteBot](https://github.com/CelesteClassic/celestebot), so a lot of code is recycled. +This bot was built as a fork of [celesteBot](https://github.com/CelesteClassic/celestebot), so a lot of code is recycled. Feel free to make a pull request or use the code here. -- cgit v1.2.3 From 5b2e87ce8119309632d808517863bb068891684a Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 13:57:01 +0200 Subject: Updated readme --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 3260466..f1c839b 100644 --- a/readme.md +++ b/readme.md @@ -16,12 +16,12 @@ A few "dangerous" commands such as `!purge` are restriced to `bot_masters`, to a ```json { "token": "your_bot_token", - "bot_masters": 280428276810383370 + "bot_masters": } ``` You can also use lists, for example: `"bot_masters": [280428276810383370, 99457716614885376]` -Once you add yourself as a botmaster, you will be able to edit the config via discord with the command `!setvar ` +A user added as a botmaster will be able to edit the config via discord with the command `!setvar ` `!setvar` also supports lists which can be added like so: `!setvar [, ]` This bot was built as a fork of [celesteBot](https://github.com/CelesteClassic/celestebot), so a lot of code is recycled. -- cgit v1.2.3 From 00a1875afdec3f602479736a4a87b117ba83da4e Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 15:42:57 +0200 Subject: restricted setvar to bot_masters --- cogs/admin.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index 1623f49..9fbc6e1 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -57,7 +57,7 @@ class Admin(commands.Cog): """Reloads an extension""" try: self.bot.reload_extension(f'cogs.{ext}') - await ctx.send(f'The extension {ext} was realoaded!') # Oceanlight told me too + 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: @@ -203,11 +203,12 @@ class Admin(commands.Cog): @commands.check(is_mod) @commands.command() async def setvar(self, ctx, key, *, value): - 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) + if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: + 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.check(is_mod) @commands.command() -- cgit v1.2.3 From 303dea6f3fc16dfd2f7ca71718dbd84e85658669 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Thu, 25 Jun 2020 15:49:47 +0200 Subject: cleaned up code --- cogs/admin.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index 9fbc6e1..83f667d 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -13,19 +13,20 @@ class Admin(commands.Cog): async def is_mod(ctx): return ctx.author.guild_permissions.manage_channels + async def is_botmaster(ctx): + return ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"] + @commands.command(aliases=['deleteEverything'], hidden=True) - @commands.check(is_mod) + @commands.check(is_botmaster) async def purge(self, ctx): - if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: - async for msg in ctx.channel.history(): - await msg.delete() + async for msg in ctx.channel.history(): + await msg.delete() @commands.command(aliases=['quit'], hidden=True) - @commands.check(is_mod) + @commands.check(is_botmaster) async def forceexit(self, ctx): - if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: - await ctx.message.delete() - exit() + await ctx.message.delete() + exit() @commands.command() @commands.check(is_mod) @@ -189,8 +190,8 @@ class Admin(commands.Cog): json.dump(self.bot.blacklist, f, indent=4) await ctx.send(f"{i} has been blacklisted.") - @commands.check(is_mod) @commands.command() + @commands.check(is_mod) async def activity(self, ctx,*, activity=None): if activity: game = discord.Game(activity) @@ -200,18 +201,17 @@ class Admin(commands.Cog): await self.bot.change_presence(activity=game) await ctx.send(f"Activity changed to {activity}") - @commands.check(is_mod) @commands.command() + @commands.check(is_botmaster) async def setvar(self, ctx, key, *, value): - if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: - 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) + 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.check(is_mod) @commands.command() + @commands.check(is_mod) async def printvar(self, ctx, key): await ctx.send(self.bot.config[str(ctx.message.guild.id)][key]) -- cgit v1.2.3 From 34ab35efecbcfd7eedd47c016fc669ee7f6be6dd Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Fri, 26 Jun 2020 13:33:48 +0200 Subject: pls work --- cogs/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 cogs/admin.py diff --git a/cogs/admin.py b/cogs/admin.py old mode 100755 new mode 100644 index 83f667d..fa243bf --- a/cogs/admin.py +++ b/cogs/admin.py @@ -13,7 +13,7 @@ class Admin(commands.Cog): async def is_mod(ctx): return ctx.author.guild_permissions.manage_channels - async def is_botmaster(ctx): + async def is_botmaster(self, ctx): return ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"] @commands.command(aliases=['deleteEverything'], hidden=True) -- cgit v1.2.3 From a03418e080fb837899021783b7cf8e2c63cf7880 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Fri, 26 Jun 2020 13:45:11 +0200 Subject: Fixed stuff, and removed password on logs --- cogs/admin.py | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index fa243bf..489d59a 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -13,20 +13,17 @@ class Admin(commands.Cog): async def is_mod(ctx): return ctx.author.guild_permissions.manage_channels - async def is_botmaster(self, ctx): - return ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"] - @commands.command(aliases=['deleteEverything'], hidden=True) - @commands.check(is_botmaster) async def purge(self, ctx): - async for msg in ctx.channel.history(): - await msg.delete() + if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: + async for msg in ctx.channel.history(): + await msg.delete() @commands.command(aliases=['quit'], hidden=True) - @commands.check(is_botmaster) async def forceexit(self, ctx): - await ctx.message.delete() - exit() + if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: + await ctx.send('Self Destructing') + exit() @commands.command() @commands.check(is_mod) @@ -163,9 +160,8 @@ class Admin(commands.Cog): await ctx.send("{0.mention} has been unmuted by {1.mention}".format(i, ctx.author)) @commands.command() - @commands.check(is_mod) - async def logs(self, ctx, *, password): - if password == "beep boop": + async def logs(self, ctx, *): + if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_master"]: await ctx.message.delete() file = discord.File("discord.log") await ctx.send(file=file) @@ -192,7 +188,7 @@ class Admin(commands.Cog): @commands.command() @commands.check(is_mod) - async def activity(self, ctx,*, activity=None): + async def activity(self, ctx, *, activity=None): if activity: game = discord.Game(activity) else: @@ -202,13 +198,13 @@ class Admin(commands.Cog): await ctx.send(f"Activity changed to {activity}") @commands.command() - @commands.check(is_botmaster) async def setvar(self, ctx, key, *, value): - 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) + if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: + 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) -- cgit v1.2.3 From 9f6603da1fad08eb987ee1afaf22d099af43cdd6 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Fri, 26 Jun 2020 13:50:12 +0200 Subject: Quick test --- cogs/admin.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index 489d59a..3fd159a 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -13,6 +13,9 @@ class Admin(commands.Cog): 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) async def purge(self, ctx): if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: @@ -160,11 +163,11 @@ class Admin(commands.Cog): await ctx.send("{0.mention} has been unmuted by {1.mention}".format(i, ctx.author)) @commands.command() + @commands.check(is_botmaster) async def logs(self, ctx, *): - if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_master"]: - await ctx.message.delete() - file = discord.File("discord.log") - await ctx.send(file=file) + await ctx.message.delete() + file = discord.File("discord.log") + await ctx.send(file=file) @commands.command(aliases=['ban'], hidden=True) @commands.check(is_mod) -- cgit v1.2.3 From a649b9bd937bf0f9f7c9cd2dad856d85a35fd340 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Fri, 26 Jun 2020 13:59:27 +0200 Subject: Fixed is_botmaster check --- cogs/admin.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index 3fd159a..67ffa4c 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -17,16 +17,16 @@ class Admin(commands.Cog): 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): - if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: - async for msg in ctx.channel.history(): - await msg.delete() + async for msg in ctx.channel.history(): + await msg.delete() @commands.command(aliases=['quit'], hidden=True) + @commands.check(is_botmaster) async def forceexit(self, ctx): - if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: - await ctx.send('Self Destructing') - exit() + await ctx.send('Self Destructing') + exit() @commands.command() @commands.check(is_mod) @@ -52,8 +52,8 @@ class Admin(commands.Cog): await ctx.send(f"Removed command {command}") - @commands.check(is_mod) @commands.command(name='reload', hidden=True, usage='') + @commands.check(is_mod) async def _reload(self, ctx, ext): """Reloads an extension""" try: @@ -69,8 +69,8 @@ class Admin(commands.Cog): 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.check(is_mod) @commands.command(name='load', hidden=True, usage='') + @commands.check(is_mod) async def _load(self, ctx, ext): """Loads an extension""" try: @@ -86,8 +86,8 @@ class Admin(commands.Cog): 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.check(is_mod) @commands.command(name='unload', hidden=True, usage='') + @commands.check(is_mod) async def _unload(self, ctx, ext): """Loads an extension""" try: @@ -120,8 +120,8 @@ class Admin(commands.Cog): async def clear(self, ctx, number): await ctx.message.channel.purge(limit=int(number)+1, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True) - @commands.check(is_mod) @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"): @@ -148,8 +148,8 @@ class Admin(commands.Cog): for member in members: await member.remove_roles(muted_role, reason = "time's up ") - @commands.check(is_mod) @commands.command() + @commands.check(is_mod) async def unmute(self, ctx, members: commands.Greedy[discord.Member]): if not members: await ctx.send("You need to name someone to unmute") @@ -164,7 +164,7 @@ class Admin(commands.Cog): @commands.command() @commands.check(is_botmaster) - async def logs(self, ctx, *): + async def logs(self, ctx): await ctx.message.delete() file = discord.File("discord.log") await ctx.send(file=file) @@ -201,13 +201,13 @@ class Admin(commands.Cog): await ctx.send(f"Activity changed to {activity}") @commands.command() + @commands.check(is_botmaster) async def setvar(self, ctx, key, *, value): - if ctx.author.id in self.bot.config[str(ctx.message.guild.id)]["bot_masters"]: - 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) + 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) -- cgit v1.2.3 From dcfc891b717abd0cbb0e8b1348ec7459c7ff150b Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Fri, 26 Jun 2020 20:54:42 +0200 Subject: Added basic compiler --- .gitignore | 0 .vscode/settings.json | 0 bot.py | 3 +- cogs/compiler.py | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ cogs/general.py | 0 cogs/help.py | 0 cogs/logs.py | 0 cogs/player.py | 0 cogs/src.py | 0 cogs/trans.py | 0 cogs/utils.py | 0 custom_commands.json | 0 main.py | 0 palette.png | Bin 14 files changed, 80 insertions(+), 1 deletion(-) mode change 100755 => 100644 .gitignore mode change 100755 => 100644 .vscode/settings.json mode change 100755 => 100644 bot.py create mode 100644 cogs/compiler.py mode change 100755 => 100644 cogs/general.py mode change 100755 => 100644 cogs/help.py mode change 100755 => 100644 cogs/logs.py mode change 100755 => 100644 cogs/player.py mode change 100755 => 100644 cogs/src.py mode change 100755 => 100644 cogs/trans.py mode change 100755 => 100644 cogs/utils.py mode change 100755 => 100644 custom_commands.json mode change 100755 => 100644 main.py mode change 100755 => 100644 palette.png diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/.vscode/settings.json b/.vscode/settings.json old mode 100755 new mode 100644 diff --git a/bot.py b/bot.py old mode 100755 new mode 100644 index d67dc3c..6c0720d --- a/bot.py +++ b/bot.py @@ -13,7 +13,8 @@ extensions = [ "cogs.trans", "cogs.player", "cogs.general", - "cogs.logs" + "cogs.logs", + "cogs.compiler" ] diff --git a/cogs/compiler.py b/cogs/compiler.py new file mode 100644 index 0000000..3046349 --- /dev/null +++ b/cogs/compiler.py @@ -0,0 +1,78 @@ +from discord.ext import commands +import discord +import requests +import json + +class Compiler(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.command() + async def compile(self, ctx, language=None, *, code=None): + """ + listRequest = requests.get("https://wandbox.org/api/list.json") + compilerList = json.loads(listRequest.text) + + for i in compilerList: + if i["language"] == language: + compiler = i["name"] + print(compiler) + """ + compilers = { + "python":"cpython-3.8.0", + "c":"gcc-head-c", + "javascript":"nodejs-head", + "typescript":"typescript-3.5.1", + "c#":"dotnetcore-head", + "bash": "bash", + "vim-script": "vim-head", + "cpp": "gcc-head", + "swift": "swift-5.0.1", + "php": "php-head", + "coffeescript": "coffeescript-head", + "go": "go-head", + "java": "openjdk-head", + "ruby": "ruby-head", + "rust": "rust-head", + "sql": "sqlite-head", + "perl": "perl-head", + "lua": "lua-5.3.4" + } + if not language: + await ctx.send(f"```json\n{json.dumps(compilers, indent=4)}```") + if not code: + await ctx.send("No code found") + return + try: + compiler = compilers[language] + except KeyError: + await ctx.send("Language not found") + return + body = { + "compiler": compiler, + "code": code, + "save": True + } + head = { + "Content-Type":"application/json" + } + async with ctx.typing(): + r = requests.post("https://wandbox.org/api/compile.json", headers=head, data=json.dumps(body)) + try: + response = json.loads(r.text) + #await ctx.send(f"```json\n{json.dumps(response, indent=4)}```") + print(f"```json\n{json.dumps(response, indent=4)}```") + except json.decoder.JSONDecodeError: + await ctx.send(f"```json\n{r.text}```") + + try: + embed=discord.Embed(title="Compiled code") + embed.add_field(name="Output", value=f'```{response["program_message"]}```', inline=False) + embed.add_field(name="Exit code", value=response["status"], inline=True) + embed.add_field(name="Link", value=f"[Permalink]({response['url']})", inline=True) + await ctx.send(embed=embed) + except KeyError: + await ctx.send(f"```json\n{json.dumps(response, indent=4)}```") + +def setup(bot): + bot.add_cog(Compiler(bot)) \ No newline at end of file diff --git a/cogs/general.py b/cogs/general.py old mode 100755 new mode 100644 diff --git a/cogs/help.py b/cogs/help.py old mode 100755 new mode 100644 diff --git a/cogs/logs.py b/cogs/logs.py old mode 100755 new mode 100644 diff --git a/cogs/player.py b/cogs/player.py old mode 100755 new mode 100644 diff --git a/cogs/src.py b/cogs/src.py old mode 100755 new mode 100644 diff --git a/cogs/trans.py b/cogs/trans.py old mode 100755 new mode 100644 diff --git a/cogs/utils.py b/cogs/utils.py old mode 100755 new mode 100644 diff --git a/custom_commands.json b/custom_commands.json old mode 100755 new mode 100644 diff --git a/main.py b/main.py old mode 100755 new mode 100644 diff --git a/palette.png b/palette.png old mode 100755 new mode 100644 -- cgit v1.2.3 From 6368eb4cadde12083d085ea5b65be752e1e1dd15 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Sat, 27 Jun 2020 14:58:25 +0200 Subject: Fixed translation mentions --- cogs/src.py | 10 ++++++---- cogs/trans.py | 3 ++- custom_commands.json | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cogs/src.py b/cogs/src.py index f0619d4..ff31cfb 100644 --- a/cogs/src.py +++ b/cogs/src.py @@ -208,7 +208,7 @@ class Src(commands.Cog): @commands.guild_only() async def pending(self, ctx): async with ctx.typing(): - await self.bot.get_channel(699713639866957905).purge() + await self.bot.get_channel(699713639866957905).purge(limit=500) await pendingRuns(self, ctx) @commands.command(description="Reject runs quickly") @@ -232,9 +232,11 @@ class Src(commands.Cog): @commands.command() async def verify(self, ctx, apiKey=None, userID=None): self.bot.messageBlacklist.append(ctx.message.id) - #if apiKey == None: - # await ctx.send(f"Please try again this command by getting an apiKey from https://www.speedrun.com/api/auth then do `{ctx.prefix}verify ` in my DMs or anywhere in this server. \nBe careful who you share this key with. To learn more check out https://github.com/speedruncomorg/api/blob/master/authentication.md") - # return + if apiKey == None: + data = json.loads(Path('./api_keys.json').read_text()) + if not str(ctx.author.id) in data: + await ctx.send(f"Please try again this command by getting an apiKey from https://www.speedrun.com/api/auth then do `{ctx.prefix}verify ` in my DMs or anywhere in this server. \nBe careful who you share this key with. To learn more check out https://github.com/speedruncomorg/api/blob/master/authentication.md") + return if ctx.guild != None: await ctx.message.delete() async with ctx.typing(): diff --git a/cogs/trans.py b/cogs/trans.py index 2c6ed71..9c5d307 100644 --- a/cogs/trans.py +++ b/cogs/trans.py @@ -20,6 +20,7 @@ async def translateMsg(text, target="en"): result['translatedText'] = result['translatedText'].replace("'", "'") result['translatedText'] = result['translatedText'].replace(""", '"') result['translatedText'] = result['translatedText'].replace("<@! ", "<@!") + result['translatedText'] = result['translatedText'].replace("<@ ", "<@") result['translatedText'] = result['translatedText'].replace("<# ", "<#") return result; @@ -28,7 +29,7 @@ class Trans(commands.Cog): def __init__(self, bot): self.bot = bot - @commands.command(help="Translate text in english (using google translate)", brief="Translate to english") + @commands.command(help="Translate text in english (using google translate)", brief="Translate to english", aliases=["翻译", "脑热", "动漫"]) async def translate(self, ctx, *, message): response = await translateMsg(message) embed=discord.Embed(title="Translation",description=f"{ctx.message.author.mention} says:", timestamp=ctx.message.created_at, color=0x4d9aff) diff --git a/custom_commands.json b/custom_commands.json index 736cda3..f0a3d4b 100644 --- a/custom_commands.json +++ b/custom_commands.json @@ -33,7 +33,7 @@ "!toxicitypass": "```TOXICITY PASS\n\nTHE HOLDER OF THIS PASS HAS PERMISSION FROM THE HEAVENS ABOVE TO DO AND SAY WHATEVER THE HELL THEY WANT\nTHEY ARE ALLOWED TO BE AS TOXIC AS THEY WILL WITHOUT REPERCUSSIONS\n\nPASS OWNER: Duck W aka Weexy aka Indy Kambeitz```", "!welcome": "Welcome! <:mango:715738087627685908>", "!learntoread": "When two players are tied on the leaderboards **ONLY ONE FUCKER WILL BE VISIBLE**", - "!src": "https://www.speedrun.com/mcbe", "!mobiledupe": "1) place item to dupe in the crafting grid\n2) keep pressed until the green bar thing appears\nclick any \"Impossible\" craft (red ones)\n3)press the item to dupe (that is in your hotbar now -> it should have moved there since you pressed the impossible craft)\n4)your item should be duped", - "!source": "https://github.com/AnInternetTroll/mcbeDiscordBot" -} + "!source": "https://github.com/AnInternetTroll/mcbeDiscordBot", + "!sr.c": "https://www.speedrun.com/mcbe" +} \ No newline at end of file -- cgit v1.2.3 From 772b8c13413314a5cf00c77b990b464fec0a96af Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Sat, 27 Jun 2020 15:07:10 +0200 Subject: Added elixir as a language --- cogs/compiler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cogs/compiler.py b/cogs/compiler.py index 3046349..3bc6bef 100644 --- a/cogs/compiler.py +++ b/cogs/compiler.py @@ -36,6 +36,7 @@ class Compiler(commands.Cog): "rust": "rust-head", "sql": "sqlite-head", "perl": "perl-head", + "elixir": "elixir-head", "lua": "lua-5.3.4" } if not language: @@ -44,7 +45,7 @@ class Compiler(commands.Cog): await ctx.send("No code found") return try: - compiler = compilers[language] + compiler = compilers[language.lower()] except KeyError: await ctx.send("Language not found") return -- cgit v1.2.3 From 6ecf2a48cb4b54ea95385bdf12b070d932dced3c Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Sat, 27 Jun 2020 15:08:32 +0200 Subject: Listed compiler languages in order --- cogs/compiler.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cogs/compiler.py b/cogs/compiler.py index 3046349..6fa5ec1 100644 --- a/cogs/compiler.py +++ b/cogs/compiler.py @@ -12,31 +12,31 @@ class Compiler(commands.Cog): """ listRequest = requests.get("https://wandbox.org/api/list.json") compilerList = json.loads(listRequest.text) - + for i in compilerList: if i["language"] == language: compiler = i["name"] print(compiler) """ compilers = { - "python":"cpython-3.8.0", + "bash": "bash", "c":"gcc-head-c", - "javascript":"nodejs-head", - "typescript":"typescript-3.5.1", "c#":"dotnetcore-head", - "bash": "bash", - "vim-script": "vim-head", - "cpp": "gcc-head", - "swift": "swift-5.0.1", - "php": "php-head", "coffeescript": "coffeescript-head", + "cpp": "gcc-head", "go": "go-head", "java": "openjdk-head", + "javascript":"nodejs-head", + "lua": "lua-5.3.4" + "perl": "perl-head", + "php": "php-head", + "python":"cpython-3.8.0", "ruby": "ruby-head", "rust": "rust-head", "sql": "sqlite-head", - "perl": "perl-head", - "lua": "lua-5.3.4" + "swift": "swift-5.0.1", + "typescript":"typescript-3.5.1", + "vim-script": "vim-head", } if not language: await ctx.send(f"```json\n{json.dumps(compilers, indent=4)}```") @@ -75,4 +75,4 @@ class Compiler(commands.Cog): await ctx.send(f"```json\n{json.dumps(response, indent=4)}```") def setup(bot): - bot.add_cog(Compiler(bot)) \ No newline at end of file + bot.add_cog(Compiler(bot)) -- cgit v1.2.3 From 515a9ea33cd79349658029bfabc158a2e42aefae Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Sat, 27 Jun 2020 15:13:16 +0200 Subject: fixed a comma --- cogs/compiler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/compiler.py b/cogs/compiler.py index 0339a4e..b595992 100644 --- a/cogs/compiler.py +++ b/cogs/compiler.py @@ -28,7 +28,7 @@ class Compiler(commands.Cog): "go": "go-head", "java": "openjdk-head", "javascript":"nodejs-head", - "lua": "lua-5.3.4" + "lua": "lua-5.3.4", "perl": "perl-head", "php": "php-head", "python":"cpython-3.8.0", @@ -37,7 +37,7 @@ class Compiler(commands.Cog): "sql": "sqlite-head", "swift": "swift-5.0.1", "typescript":"typescript-3.5.1", - "vim-script": "vim-head", + "vim-script": "vim-head" } if not language: await ctx.send(f"```json\n{json.dumps(compilers, indent=4)}```") -- cgit v1.2.3 From 5eb37689ae2aac9d0a6aa10d72f14609d12dc985 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Sat, 27 Jun 2020 14:16:19 +0100 Subject: modified: cogs/admin.py modified: cogs/compiler.py --- .gitignore | 0 .vscode/settings.json | 0 bot.py | 0 cogs/admin.py | 5 ++++- cogs/compiler.py | 0 cogs/general.py | 0 cogs/help.py | 0 cogs/logs.py | 0 cogs/player.py | 0 cogs/src.py | 0 cogs/trans.py | 0 cogs/utils.py | 0 custom_commands.json | 0 main.py | 0 palette.png | Bin 15 files changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .vscode/settings.json mode change 100644 => 100755 bot.py mode change 100644 => 100755 cogs/compiler.py mode change 100644 => 100755 cogs/general.py mode change 100644 => 100755 cogs/help.py mode change 100644 => 100755 cogs/logs.py mode change 100644 => 100755 cogs/player.py mode change 100644 => 100755 cogs/src.py mode change 100644 => 100755 cogs/trans.py mode change 100644 => 100755 cogs/utils.py mode change 100644 => 100755 custom_commands.json mode change 100644 => 100755 main.py mode change 100644 => 100755 palette.png diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.vscode/settings.json b/.vscode/settings.json old mode 100644 new mode 100755 diff --git a/bot.py b/bot.py old mode 100644 new mode 100755 diff --git a/cogs/admin.py b/cogs/admin.py index 67ffa4c..6c15e5e 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -32,7 +32,10 @@ class Admin(commands.Cog): @commands.check(is_mod) async def pull(self, ctx): g = git.cmd.Git(os.getcwd()) - await ctx.send(f"Probably pulled.\n```bash\n{g.pull()}```") + 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) diff --git a/cogs/compiler.py b/cogs/compiler.py old mode 100644 new mode 100755 diff --git a/cogs/general.py b/cogs/general.py old mode 100644 new mode 100755 diff --git a/cogs/help.py b/cogs/help.py old mode 100644 new mode 100755 diff --git a/cogs/logs.py b/cogs/logs.py old mode 100644 new mode 100755 diff --git a/cogs/player.py b/cogs/player.py old mode 100644 new mode 100755 diff --git a/cogs/src.py b/cogs/src.py old mode 100644 new mode 100755 diff --git a/cogs/trans.py b/cogs/trans.py old mode 100644 new mode 100755 diff --git a/cogs/utils.py b/cogs/utils.py old mode 100644 new mode 100755 diff --git a/custom_commands.json b/custom_commands.json old mode 100644 new mode 100755 diff --git a/main.py b/main.py old mode 100644 new mode 100755 diff --git a/palette.png b/palette.png old mode 100644 new mode 100755 -- cgit v1.2.3 From 0ce35754c516d3e332230cbc2eb8dd83d1a13249 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Sat, 27 Jun 2020 17:55:10 +0200 Subject: un-hardcoded pendingRuns() and removed clear() --- cogs/src.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/cogs/src.py b/cogs/src.py index ff31cfb..df40678 100644 --- a/cogs/src.py +++ b/cogs/src.py @@ -63,11 +63,6 @@ async def deleteRun(self, apiKey, ctx, run): await ctx.send("Something went wrong") await ctx.message.author.send(f"```json\n{json.dumps(json.loads(r.text),indent=4)}```") -async def clear(self): - async for msg in self.bot.get_channel(699713639866957905).history(): - await msg.delete() - - async def pendingRuns(self, ctx): mcbe_runs = 0 mcbeil_runs = 0 @@ -124,11 +119,11 @@ async def pendingRuns(self, ctx): mcbece_runs += 1 embed = discord.Embed( title=leaderboard, url=link, description=f"{categoryName} in `{str(rta).replace('000','')}` by **{player}**", color=16711680+i*60, timestamp=timestamp) - await self.bot.get_channel(699713639866957905).send(embed=embed) + await self.bot.get_channel(self.bot.config[str(ctx.message.guild.id)]["pending_channel"]).send(embed=embed) runs = runs2 gameID = gameID2 embed_stats = discord.Embed(title='Pending Run Stats', description=f"Full Game Runs: {mcbe_runs}\nIndividual Level Runs: {mcbeil_runs}\nCategory Extension Runs: {mcbece_runs}", color=16711680 + i * 60) - await self.bot.get_channel(699713639866957905).send(embed=embed_stats) + await self.bot.get_channel(self.bot.config[str(ctx.message.guild.id)]["pending_channel"]).send(embed=embed_stats) async def verifyNew(self, apiKey=None, userID=None): @@ -176,7 +171,7 @@ async def verifyNew(self, apiKey=None, userID=None): wrCounter = False runnerCounter = False - + for i in pbs["data"]: if i["place"] == 1: if i["run"]["game"] == "yd4ovvg1" or i["run"]["game"] == "v1po7r76": @@ -208,7 +203,7 @@ class Src(commands.Cog): @commands.guild_only() async def pending(self, ctx): async with ctx.typing(): - await self.bot.get_channel(699713639866957905).purge(limit=500) + await self.bot.get_channel(self.bot.config[str(ctx.message.guild.id)]["pending_channel"]).purge(limit=500) await pendingRuns(self, ctx) @commands.command(description="Reject runs quickly") -- cgit v1.2.3 From a95aa4d46bf7850c21a8fba94eca3ae9ee21d7c8 Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Sat, 27 Jun 2020 17:55:41 +0200 Subject: Made purge() use .purge --- cogs/admin.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index 67ffa4c..e77dc66 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -19,8 +19,7 @@ class Admin(commands.Cog): @commands.command(aliases=['deleteEverything'], hidden=True) @commands.check(is_botmaster) async def purge(self, ctx): - async for msg in ctx.channel.history(): - await msg.delete() + await ctx.message.channel.purge() @commands.command(aliases=['quit'], hidden=True) @commands.check(is_botmaster) -- cgit v1.2.3 From aa42efaa4dd03b2a53547ef0d68029c7e9f41fce Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Sat, 27 Jun 2020 18:00:39 +0200 Subject: Set purge limit to 500 --- cogs/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/admin.py b/cogs/admin.py index e77dc66..3af681d 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -19,7 +19,7 @@ class Admin(commands.Cog): @commands.command(aliases=['deleteEverything'], hidden=True) @commands.check(is_botmaster) async def purge(self, ctx): - await ctx.message.channel.purge() + await ctx.message.channel.purge(limit=500) @commands.command(aliases=['quit'], hidden=True) @commands.check(is_botmaster) -- cgit v1.2.3 From 4e3700629dc878ca7f895ee2badd686e3862121f Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Sat, 27 Jun 2020 18:01:07 +0200 Subject: TODO: Make ID's ints D: --- cogs/src.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cogs/src.py b/cogs/src.py index df40678..bf776e7 100644 --- a/cogs/src.py +++ b/cogs/src.py @@ -119,11 +119,11 @@ async def pendingRuns(self, ctx): mcbece_runs += 1 embed = discord.Embed( title=leaderboard, url=link, description=f"{categoryName} in `{str(rta).replace('000','')}` by **{player}**", color=16711680+i*60, timestamp=timestamp) - await self.bot.get_channel(self.bot.config[str(ctx.message.guild.id)]["pending_channel"]).send(embed=embed) + await self.bot.get_channel(int(self.bot.config[str(ctx.message.guild.id)]["pending_channel"])).send(embed=embed) runs = runs2 gameID = gameID2 embed_stats = discord.Embed(title='Pending Run Stats', description=f"Full Game Runs: {mcbe_runs}\nIndividual Level Runs: {mcbeil_runs}\nCategory Extension Runs: {mcbece_runs}", color=16711680 + i * 60) - await self.bot.get_channel(self.bot.config[str(ctx.message.guild.id)]["pending_channel"]).send(embed=embed_stats) + await self.bot.get_channel(int(self.bot.config[str(ctx.message.guild.id)]["pending_channel"])).send(embed=embed_stats) async def verifyNew(self, apiKey=None, userID=None): @@ -203,7 +203,7 @@ class Src(commands.Cog): @commands.guild_only() async def pending(self, ctx): async with ctx.typing(): - await self.bot.get_channel(self.bot.config[str(ctx.message.guild.id)]["pending_channel"]).purge(limit=500) + await self.bot.get_channel(int(self.bot.config[str(ctx.message.guild.id)]["pending_channel"])).purge(limit=500) await pendingRuns(self, ctx) @commands.command(description="Reject runs quickly") -- cgit v1.2.3 From ba4272f2a15376b3df4880c97a7bfa7f445eb0c4 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Sun, 28 Jun 2020 22:19:06 +0100 Subject: Cooldown of 60 sec to @someone --- cogs/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cogs/utils.py b/cogs/utils.py index 68567f0..6227e0a 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -220,6 +220,7 @@ class Utils(commands.Cog): #return await ctx.send(f"{ctx.message.author.display_name}, you have to wait {round(error.retry_after, 2)} seconds before using this again.") + @commands.cooldown(1, 60, commands.BucketType.guild) @commands.command() async def someone(self, ctx): if ctx.channel.id != int(self.bot.config[str(ctx.message.guild.id)]["fair_channel"]): -- cgit v1.2.3 From 1e2c28b9d7467f5c08466b770e1d61d67d197065 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Mon, 29 Jun 2020 13:13:57 +0100 Subject: Added xboxuser command --- cogs/general.py | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/cogs/general.py b/cogs/general.py index 0847cd4..9fc8f5c 100755 --- a/cogs/general.py +++ b/cogs/general.py @@ -1,6 +1,8 @@ from discord.ext import commands import discord import datetime +import requests +import json def dump(obj): output = "" @@ -86,5 +88,67 @@ class General(commands.Cog): embed.set_footer(text=f"ID: {guild.id}") await ctx.send(embed=embed) + @commands.command() + async def xboxUser(self, ctx, *, gamertag=None): + if not gamertag: + await ctx.send("You need to specify a gamer, gamer") + return + + r = requests.get(f"https://xbl-api.prouser123.me/profile/gamertag/{gamertag}") + gamer = json.loads(r.text) + + try: + await ctx.send(f"{gamer['error']}: {gamer['message']}") + return + except KeyError: + pass + + for i in gamer["profileUsers"][0]["settings"]: + if i["id"] == "GameDisplayName": + gameName = i["value"] + continue + if i["id"] == "AppDisplayPicRaw": + picUrl = i["value"] + continue + if i["id"] == "Gamerscore": + Gamerscore = i["value"]+"<:gamerscore:727131234534424586>" + continue + if i["id"] == "AccountTier": + accountTier = i["value"] + continue + if i["id"] == "XboxOneRep": + reputation = i["value"] + continue + if i["id"] == "PreferredColor": + color = int(json.loads(requests.get(i["value"]).text)["primaryColor"], 16) + continue + if i["id"] == "Location": + location = i["value"] + continue + if i["id"] == "Bio": + #if len(i["value"]) == 0: + # Bio = "Unknown" + #else: + Bio = i["value"] + continue + if i["id"] == "Watermarks": + Watermarks = i["value"] + continue + if i["id"] == "RealName": + RealName = i["value"] + continue + + + embed=discord.Embed(title=gameName, description=Bio, color=color, timestamp=ctx.message.created_at) + embed.set_thumbnail(url=picUrl) + embed.add_field(name="Gamerscore", value=Gamerscore, inline=True) + if len(location) != 0: + embed.add_field(name="Location", value=location, inline=True) + if len(Watermarks) != 0: + embed.add_field(name="Watermarks", value=Watermarks, inline=True) + embed.add_field(name="Account Tier", value=accountTier, inline=True) + embed.add_field(name="Reputation", value=reputation, inline=True) + await ctx.send(embed=embed) + def setup(bot): bot.add_cog(General(bot)) -- cgit v1.2.3 From ac8580d300a00e874366a465bd8e1e56e90f15fa Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Mon, 29 Jun 2020 14:25:24 +0100 Subject: Added xboxpresence command --- cogs/general.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/cogs/general.py b/cogs/general.py index 9fc8f5c..57bf044 100755 --- a/cogs/general.py +++ b/cogs/general.py @@ -3,6 +3,7 @@ import discord import datetime import requests import json +import dateutil.parser def dump(obj): output = "" @@ -150,5 +151,41 @@ class General(commands.Cog): embed.add_field(name="Reputation", value=reputation, inline=True) await ctx.send(embed=embed) + @commands.command() + async def xboxpresence(self, ctx, *, gamertag=None): + if not gamertag: + await ctx.send("You need to specify a gamer, gamer") + return + + r = requests.get(f"https://xbl-api.prouser123.me/presence/gamertag/{gamertag}") + gamer = json.loads(r.text) + + try: + await ctx.send(f"{gamer['error']}: {gamer['message']}") + return + except KeyError: + pass + + state = gamer["state"] + + try: + game = json.loads(requests.get(f"https://xbl-api.prouser123.me/titleinfo/{gamer['lastSeen']['titleId']}").text) + gameName = game["titles"][0]["name"] + gamePic = game["titles"][0]["images"][4]["url"] + timestamp = dateutil.parser.isoparse(gamer["lastSeen"]["timestamp"]) + lastSeen = True + except Exception as e: + print(e) + lastSeen = False + + if lastSeen: + embed=discord.Embed(title=gamer["gamertag"], description=state, timestamp=timestamp) + embed.set_thumbnail(url=gamePic) + embed.add_field(name="Game", value=gameName, inline=True) + await ctx.send(embed=embed) + else: + embed=discord.Embed(title=gamer["gamertag"], description=state, timestamp=ctx.message.created_at) + await ctx.send(embed=embed) + def setup(bot): bot.add_cog(General(bot)) -- cgit v1.2.3 From e593aa26927db20ce21b7dcf6ec499dad232f01d Mon Sep 17 00:00:00 2001 From: Luca Matei Pintilie Date: Thu, 2 Jul 2020 23:09:10 +0200 Subject: New player.py cog --- cogs/player.py | 455 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 377 insertions(+), 78 deletions(-) diff --git a/cogs/player.py b/cogs/player.py index 5c046a7..7013e6d 100755 --- a/cogs/player.py +++ b/cogs/player.py @@ -1,18 +1,38 @@ -import asyncio +""" +Please understand Music bots are complex, and that even this basic example can be daunting to a beginner. + +For this reason it's highly advised you familiarize yourself with discord.py, python and asyncio, BEFORE +you attempt to write a music bot. + +This example makes use of: Python 3.6 + +For a more basic voice example please read: + https://github.com/Rapptz/discord.py/blob/rewrite/examples/basic_voice.py + +This is a very basic playlist example, which allows per guild playback of unique queues. +The commands implement very basic logic for basic usage. But allow for expansion. It would be advisable to implement +your own permissions and usage logic for commands. + +e.g You might like to implement a vote before skipping the song or only allow admins to stop the player. + +Music bots require lots of work, and tuning. Goodluck. +If you find any bugs feel free to ping me on discord. @Eviee#0666 +""" import discord -import youtube_dl from discord.ext import commands -from discord.ext import tasks -from pathlib import Path - -# Straight up copied from -# https://github.com/Rapptz/discord.py/blob/master/examples/basic_voice.py -# Suppress noise about console usage from errors -youtube_dl.utils.bug_reports_message = lambda: '' +import asyncio +import itertools +import sys +import traceback +from async_timeout import timeout +from functools import partial +from youtube_dl import YoutubeDL +from pathlib import Path +from discord.ext import tasks -ytdl_format_options = { +ytdlopts = { 'format': 'bestaudio/best', 'outtmpl': 'downloads/%(extractor)s-%(id)s-%(title)s.%(ext)s', 'restrictfilenames': True, @@ -23,117 +43,396 @@ ytdl_format_options = { 'quiet': True, 'no_warnings': True, 'default_search': 'auto', - 'source_address': '0.0.0.0' # bind to ipv4 since ipv6 addresses cause issues sometimes + 'source_address': '0.0.0.0' # ipv6 addresses cause issues sometimes } -ffmpeg_options = { - 'options': '-vn' +ffmpegopts = { + 'before_options': '-nostdin', + 'options': '-vn -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5' } -ytdl = youtube_dl.YoutubeDL(ytdl_format_options) +ytdl = YoutubeDL(ytdlopts) + + +class VoiceConnectionError(commands.CommandError): + """Custom Exception class for connection errors.""" + + +class InvalidVoiceChannel(VoiceConnectionError): + """Exception for cases of invalid Voice Channels.""" class YTDLSource(discord.PCMVolumeTransformer): - def __init__(self, source, *, data, volume=0.5): - super().__init__(source, volume) - self.data = data + def __init__(self, source, *, data, requester): + super().__init__(source) + self.requester = requester self.title = data.get('title') - self.url = data.get('url') + self.web_url = data.get('webpage_url') + + # YTDL info dicts (data) have other useful information you might want + # https://github.com/rg3/youtube-dl/blob/master/README.md + + def __getitem__(self, item: str): + """Allows us to access attributes similar to a dict. + + This is only useful when you are NOT downloading. + """ + return self.__getattribute__(item) @classmethod - async def from_url(cls, url, *, loop=None, stream=False): + async def create_source(cls, ctx, search: str, *, loop, download=True): loop = loop or asyncio.get_event_loop() - data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream)) + + to_run = partial(ytdl.extract_info, url=search, download=download) + data = await loop.run_in_executor(None, to_run) if 'entries' in data: # take first item from a playlist data = data['entries'][0] - filename = data['url'] if stream else ytdl.prepare_filename(data) - return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data) + await ctx.send(f'```ini\n[Added {data["title"]} to the Queue.]\n```', delete_after=15) + + if download: + source = ytdl.prepare_filename(data) + else: + return {'webpage_url': data['webpage_url'], 'requester': ctx.author, 'title': data['title']} + + return cls(discord.FFmpegPCMAudio(source, **ffmpegopts), data=data, requester=ctx.author) + + @classmethod + async def regather_stream(cls, data, *, loop): + """Used for preparing a stream, instead of downloading. + + Since Youtube Streaming links expire.""" + loop = loop or asyncio.get_event_loop() + requester = data['requester'] + + to_run = partial(ytdl.extract_info, url=data['webpage_url'], download=False) + data = await loop.run_in_executor(None, to_run) + + return cls(discord.FFmpegPCMAudio(data['url'], **ffmpegopts), data=data, requester=requester) + + +class MusicPlayer: + """A class which is assigned to each guild using the bot for Music. + + This class implements a queue and loop, which allows for different guilds to listen to different playlists + simultaneously. + + When the bot disconnects from the Voice it's instance will be destroyed. + """ + + __slots__ = ('bot', '_guild', '_channel', '_cog', 'queue', 'next', 'current', 'np', 'volume') + + def __init__(self, ctx): + self.bot = ctx.bot + self._guild = ctx.guild + self._channel = ctx.channel + self._cog = ctx.cog + + self.queue = asyncio.Queue() + self.next = asyncio.Event() + + self.np = None # Now playing message + self.volume = .5 + self.current = None + + ctx.bot.loop.create_task(self.player_loop()) + + async def player_loop(self): + """Our main player loop.""" + await self.bot.wait_until_ready() + + while not self.bot.is_closed(): + self.next.clear() + + try: + # Wait for the next song. If we timeout cancel the player and disconnect... + async with timeout(300): # 5 minutes... + source = await self.queue.get() + except asyncio.TimeoutError: + if self in self._cog.players.values(): + return self.destroy(self._guild) + return + + if not isinstance(source, YTDLSource): + # Source was probably a stream (not downloaded) + # So we should regather to prevent stream expiration + try: + source = await YTDLSource.regather_stream(source, loop=self.bot.loop) + except Exception as e: + await self._channel.send(f'There was an error processing your song.\n' + f'```css\n[{e}]\n```') + continue + + source.volume = self.volume + self.current = source + + self._guild.voice_client.play(source, after=lambda _: self.bot.loop.call_soon_threadsafe(self.next.set)) + self.np = await self._channel.send(f'**Now Playing:** `{source.title}` requested by ' + f'`{source.requester}`') + await self.next.wait() + + # Make sure the FFmpeg process is cleaned up. + source.cleanup() + self.current = None + + try: + # We are no longer playing this song... + await self.np.delete() + except discord.HTTPException: + pass + + def destroy(self, guild): + """Disconnect and cleanup the player.""" + return self.bot.loop.create_task(self._cog.cleanup(guild)) class Player(commands.Cog): + """Music related commands.""" + + __slots__ = ('bot', 'players') + def __init__(self, bot): self.bot = bot self.cleanup.start() + self.players = {} - async def is_in_vc(ctx): + async def cleanup(self, guild): try: - return ctx.author.voice.channel + await guild.voice_client.disconnect() except AttributeError: - return False + pass + + try: + for entry in self.players[guild.id].queue._queue: + if isinstance(entry, YTDLSource): + entry.cleanup() + self.players[guild.id].queue._queue.clear() + except KeyError: + pass + + try: + del self.players[guild.id] + except KeyError: + pass + + async def __local_check(self, ctx): + """A local check which applies to all commands in this cog.""" + if not ctx.guild: + raise commands.NoPrivateMessage + return True + + async def __error(self, ctx, error): + """A local error handler for all errors arising from commands in this cog.""" + if isinstance(error, commands.NoPrivateMessage): + try: + return await ctx.send('This command can not be used in Private Messages.') + except discord.HTTPException: + pass + elif isinstance(error, InvalidVoiceChannel): + await ctx.send('Error connecting to Voice Channel. ' + 'Please make sure you are in a valid channel or provide me with one') + + print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr) + traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr) + + def get_player(self, ctx): + """Retrieve the guild player, or generate one.""" + try: + player = self.players[ctx.guild.id] + except KeyError: + player = MusicPlayer(ctx) + self.players[ctx.guild.id] = player + + return player + + @commands.command(name='connectvc', aliases=['join']) + async def connect_(self, ctx, *, channel: discord.VoiceChannel=None): + """Connect to voice. + + Parameters + ------------ + channel: discord.VoiceChannel [Optional] + The channel to connect to. If a channel is not specified, an attempt to join the voice channel you are in + will be made. + + This command also handles moving the bot to different channels. + """ + if not channel: + try: + channel = ctx.author.voice.channel + except AttributeError: + raise InvalidVoiceChannel('No channel to join. Please either specify a valid channel or join one.') + + vc = ctx.voice_client + + if vc: + if vc.channel.id == channel.id: + return + try: + await vc.move_to(channel) + except asyncio.TimeoutError: + raise VoiceConnectionError(f'Moving to channel: <{channel}> timed out.') + else: + try: + await channel.connect() + except asyncio.TimeoutError: + raise VoiceConnectionError(f'Connecting to channel: <{channel}> timed out.') + + await ctx.send(f'Connected to: **{channel}**', delete_after=20) + + @commands.command(name='play', aliases=['sing']) + async def play_(self, ctx, *, search: str): + """Request a song and add it to the queue. + + This command attempts to join a valid voice channel if the bot is not already in one. + Uses YTDL to automatically search and retrieve a song. + + Parameters + ------------ + search: str [Required] + The song to search and retrieve using YTDL. This could be a simple search, an ID or URL. + """ + await ctx.trigger_typing() + + vc = ctx.voice_client + + if not vc: + await ctx.invoke(self.connect_) - @commands.check(is_in_vc) - @commands.command() - async def join(self, ctx, *, channel: discord.VoiceChannel): - """Joins a voice channel""" + player = self.get_player(ctx) - if ctx.voice_client is not None: - return await ctx.voice_client.move_to(channel) + # If download is False, source will be a dict which will be used later to regather the stream. + # If download is True, source will be a discord.FFmpegPCMAudio with a VolumeTransformer. + source = await YTDLSource.create_source(ctx, search, loop=self.bot.loop, download=False) - await channel.connect() - @commands.command() - async def play(self, ctx, *, query): - """Plays a file from the local filesystem""" + await player.queue.put(source) - source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query)) - ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None) + @commands.command(name='pause') + async def pause_(self, ctx): + """Pause the currently playing song.""" + vc = ctx.voice_client - await ctx.send('Now playing: {}'.format(query)) - @commands.command() - async def yt(self, ctx, *, url): - """Plays from a url (almost anything youtube_dl supports)""" + if not vc or not vc.is_playing(): + return await ctx.send('I am not currently playing anything!', delete_after=20) + elif vc.is_paused(): + return + + vc.pause() + await ctx.send(f'**`{ctx.author}`**: Paused the song!') + + @commands.command(name='resume') + async def resume_(self, ctx): + """Resume the currently paused song.""" + vc = ctx.voice_client + + if not vc or not vc.is_connected(): + return await ctx.send('I am not currently playing anything!', delete_after=20) + elif not vc.is_paused(): + return + + vc.resume() + await ctx.send(f'**`{ctx.author}`**: Resumed the song!') + + @commands.command(name='skip') + async def skip_(self, ctx): + """Skip the song.""" + vc = ctx.voice_client + + if not vc or not vc.is_connected(): + return await ctx.send('I am not currently playing anything!', delete_after=20) + + if vc.is_paused(): + pass + elif not vc.is_playing(): + return + + vc.stop() + await ctx.send(f'**`{ctx.author}`**: Skipped the song!') + + @commands.command(name='queue', aliases=['q', 'playlist']) + async def queue_info(self, ctx): + """Retrieve a basic queue of upcoming songs.""" + vc = ctx.voice_client + + if not vc or not vc.is_connected(): + return await ctx.send('I am not currently connected to voice!', delete_after=20) + + player = self.get_player(ctx) + if player.queue.empty(): + return await ctx.send('There are currently no more queued songs.') + + # Grab up to 5 entries from the queue... + upcoming = list(itertools.islice(player.queue._queue, 0, 5)) + + fmt = '\n'.join(f'**`{_["title"]}`**' for _ in upcoming) + embed = discord.Embed(title=f'Upcoming - Next {len(upcoming)}', description=fmt) + + await ctx.send(embed=embed) + + @commands.command(name='now_playing', aliases=['np', 'current', 'currentsong', 'playing']) + async def now_playing_(self, ctx): + """Display information about the currently playing song.""" + vc = ctx.voice_client + + if not vc or not vc.is_connected(): + return await ctx.send('I am not currently connected to voice!', delete_after=20) + + player = self.get_player(ctx) + if not player.current: + return await ctx.send('I am not currently playing anything!') + + try: + # Remove our previous now_playing message. + await player.np.delete() + except discord.HTTPException: + pass - async with ctx.typing(): - player = await YTDLSource.from_url(url, loop=self.bot.loop) - ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None) + player.np = await ctx.send(f'**Now Playing:** `{vc.source.title}` ' + f'requested by `{vc.source.requester}`') - await ctx.send('Now playing: {}'.format(player.title)) + @commands.command(name='volume', aliases=['vol']) + async def change_volume(self, ctx, *, vol: float): + """Change the player volume. - @commands.command() - async def stream(self, ctx, *, url): - """Streams from a url (same as yt, but doesn't predownload)""" + Parameters + ------------ + volume: float or int [Required] + The volume to set the player to in percentage. This must be between 1 and 100. + """ + vc = ctx.voice_client - async with ctx.typing(): - player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True) - ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None) + if not vc or not vc.is_connected(): + return await ctx.send('I am not currently connected to voice!', delete_after=20) - await ctx.send('Now playing: {}'.format(player.title)) + if not 0 < vol < 101: + return await ctx.send('Please enter a value between 1 and 100.') - @commands.check(is_in_vc) - @commands.command() - async def volume(self, ctx, volume: int): - """Changes the player's volume""" + player = self.get_player(ctx) - if ctx.voice_client is None: - return await ctx.send("Not connected to a voice channel.") + if vc.source: + vc.source.volume = vol / 100 - ctx.voice_client.source.volume = volume / 100 - await ctx.send("Changed volume to {}%".format(volume)) + player.volume = vol / 100 + await ctx.send(f'**`{ctx.author}`**: Set the volume to **{vol}%**') - @commands.check(is_in_vc) - @commands.command() - async def stop(self, ctx): - """Stops and disconnects the bot from voice""" + @commands.command(name='stop') + async def stop_(self, ctx): + """Stop the currently playing song and destroy the player. - await ctx.voice_client.disconnect() + !Warning! + This will destroy the player assigned to your guild, also deleting any queued songs and settings. + """ + vc = ctx.voice_client - @play.before_invoke - @yt.before_invoke - @stream.before_invoke - async def ensure_voice(self, ctx): - if ctx.voice_client is None: - if ctx.author.voice: - await ctx.author.voice.channel.connect() - else: - await ctx.send("You are not connected to a voice channel.") - raise commands.CommandError("Author not connected to a voice channel.") - elif ctx.voice_client.is_playing(): - ctx.voice_client.stop() + if not vc or not vc.is_connected(): + return await ctx.send('I am not currently playing anything!', delete_after=20) + await self.cleanup(ctx.guild) + @tasks.loop(hours=10.0) async def cleanup(self): for p in Path("./downloads/").glob("*"): @@ -141,4 +440,4 @@ class Player(commands.Cog): def setup(bot): - bot.add_cog(Player(bot)) \ No newline at end of file + bot.add_cog(Player(bot)) -- cgit v1.2.3 From 55cef1c7b6c6f4703eedae29965f5b1df5573a56 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Sat, 4 Jul 2020 16:52:20 +0100 Subject: Command descriptions added --- bot.py | 4 +- cogs/admin.py | 26 ++- cogs/compiler.py | 79 --------- cogs/general.py | 466 ++++++++++++++++++++++++++++++++++++++++++++++++++- cogs/help.py | 395 ------------------------------------------- cogs/trans.py | 2 + cogs/utils.py | 7 + custom_commands.json | 4 +- 8 files changed, 488 insertions(+), 495 deletions(-) mode change 100644 => 100755 cogs/admin.py delete mode 100755 cogs/compiler.py delete mode 100755 cogs/help.py diff --git a/bot.py b/bot.py index 6c0720d..12ea846 100755 --- a/bot.py +++ b/bot.py @@ -9,12 +9,10 @@ extensions = [ "cogs.utils", "cogs.admin", "cogs.src", - "cogs.help", "cogs.trans", "cogs.player", "cogs.general", - "cogs.logs", - "cogs.compiler" + "cogs.logs" ] diff --git a/cogs/admin.py b/cogs/admin.py old mode 100644 new mode 100755 index c00097b..d2b3cab --- a/cogs/admin.py +++ b/cogs/admin.py @@ -25,11 +25,12 @@ class Admin(commands.Cog): @commands.check(is_botmaster) async def forceexit(self, ctx): await ctx.send('Self Destructing') - exit() + 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()}```") @@ -39,6 +40,7 @@ class Admin(commands.Cog): @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) @@ -48,6 +50,7 @@ class Admin(commands.Cog): @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) @@ -103,23 +106,10 @@ class Admin(commands.Cog): 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 connect(self, ctx): - await ctx.author.voice.channel.connect() - await ctx.send(f"Joined channel {ctx.author.voice.channel.name}") - - @commands.command() - @commands.check(is_mod) - async def disconnect(self, ctx): - await ctx.voice_client.disconnect() - await ctx.send(f"Left channel {ctx.author.voice.channel.name}") - """ - @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() @@ -153,6 +143,7 @@ class Admin(commands.Cog): @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 @@ -167,6 +158,7 @@ class Admin(commands.Cog): @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) @@ -174,6 +166,7 @@ class Admin(commands.Cog): @commands.command(aliases=['ban'], 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 @@ -194,6 +187,7 @@ class Admin(commands.Cog): @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: @@ -205,6 +199,7 @@ class Admin(commands.Cog): @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(','))) @@ -214,6 +209,7 @@ class Admin(commands.Cog): @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]) diff --git a/cogs/compiler.py b/cogs/compiler.py deleted file mode 100755 index b595992..0000000 --- a/cogs/compiler.py +++ /dev/null @@ -1,79 +0,0 @@ -from discord.ext import commands -import discord -import requests -import json - -class Compiler(commands.Cog): - def __init__(self, bot): - self.bot = bot - - @commands.command() - async def compile(self, ctx, language=None, *, code=None): - """ - listRequest = requests.get("https://wandbox.org/api/list.json") - compilerList = json.loads(listRequest.text) - - for i in compilerList: - if i["language"] == language: - compiler = i["name"] - print(compiler) - """ - compilers = { - "bash": "bash", - "c":"gcc-head-c", - "c#":"dotnetcore-head", - "coffeescript": "coffeescript-head", - "cpp": "gcc-head", - "elixir": "elixir-head", - "go": "go-head", - "java": "openjdk-head", - "javascript":"nodejs-head", - "lua": "lua-5.3.4", - "perl": "perl-head", - "php": "php-head", - "python":"cpython-3.8.0", - "ruby": "ruby-head", - "rust": "rust-head", - "sql": "sqlite-head", - "swift": "swift-5.0.1", - "typescript":"typescript-3.5.1", - "vim-script": "vim-head" - } - if not language: - await ctx.send(f"```json\n{json.dumps(compilers, indent=4)}```") - if not code: - await ctx.send("No code found") - return - try: - compiler = compilers[language.lower()] - except KeyError: - await ctx.send("Language not found") - return - body = { - "compiler": compiler, - "code": code, - "save": True - } - head = { - "Content-Type":"application/json" - } - async with ctx.typing(): - r = requests.post("https://wandbox.org/api/compile.json", headers=head, data=json.dumps(body)) - try: - response = json.loads(r.text) - #await ctx.send(f"```json\n{json.dumps(response, indent=4)}```") - print(f"```json\n{json.dumps(response, indent=4)}```") - except json.decoder.JSONDecodeError: - await ctx.send(f"```json\n{r.text}```") - - try: - embed=discord.Embed(title="Compiled code") - embed.add_field(name="Output", value=f'```{response["program_message"]}```', inline=False) - embed.add_field(name="Exit code", value=response["status"], inline=True) - embed.add_field(name="Link", value=f"[Permalink]({response['url']})", inline=True) - await ctx.send(embed=embed) - except KeyError: - await ctx.send(f"```json\n{json.dumps(response, indent=4)}```") - -def setup(bot): - bot.add_cog(Compiler(bot)) diff --git a/cogs/general.py b/cogs/general.py index 57bf044..968332b 100755 --- a/cogs/general.py +++ b/cogs/general.py @@ -4,6 +4,13 @@ import datetime import requests import json import dateutil.parser +from random import randint +import os, sys, inspect +current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) +parent_dir = os.path.dirname(current_dir) +sys.path.insert(0, parent_dir) +import bot + def dump(obj): output = "" @@ -13,12 +20,395 @@ def dump(obj): return output +class MyHelpCommand(commands.MinimalHelpCommand): + messages = [ + "As seen on TV!", + "Awesome!", + "100% pure!", + "May contain nuts!", + "Better than Prey!", + "More polygons!", + "Sexy!", + "Limited edition!", + "Flashing letters!", + "Made by Notch!", + "It's here!", + "Best in class!", + "It's finished!", + "Kind of dragon free!", + "Excitement!", + "More than 500 sold!", + "One of a kind!", + "Heaps of hits on YouTube!", + "Indev!", + "Spiders everywhere!", + "Check it out!", + "Holy cow", + " man!", + "It's a game!", + "Made in Sweden!", + "Uses LWJGL!", + "Reticulating splines!", + "Minecraft!", + "Yaaay!", + "Singleplayer!", + "Keyboard compatible!", + "Undocumented!", + "Ingots!", + "Exploding creepers!", + "That's no moon!", + "l33t!", + "Create!", + "Survive!", + "Dungeon!", + "Exclusive!", + "The bee's knees!", + "Down with O.P.P.!", + "Closed source!", + "Classy!", + "Wow!", + "Not on steam!", + "Oh man!", + "Awesome community!", + "Pixels!", + "Teetsuuuuoooo!", + "Kaaneeeedaaaa!", + "Now with difficulty!", + "Enhanced!", + "90% bug free!", + "Pretty!", + "12 herbs and spices!", + "Fat free!", + "Absolutely no memes!", + "Free dental!", + "Ask your doctor!", + "Minors welcome!", + "Cloud computing!", + "Legal in Finland!", + "Hard to label!", + "Technically good!", + "Bringing home the bacon!", + "Indie!", + "GOTY!", + "Ceci n'est pas une title screen!", + "Euclidian!", + "Now in 3D!", + "Inspirational!", + "Herregud!", + "Complex cellular automata!", + "Yes", + " sir!", + "Played by cowboys!", + "OpenGL 1.2!", + "Thousands of colors!", + "Try it!", + "Age of Wonders is better!", + "Try the mushroom stew!", + "Sensational!", + "Hot tamale", + " hot hot tamale!", + "Play him off", + " keyboard cat!", + "Guaranteed!", + "Macroscopic!", + "Bring it on!", + "Random splash!", + "Call your mother!", + "Monster infighting!", + "Loved by millions!", + "Ultimate edition!", + "Freaky!", + "You've got a brand new key!", + "Water proof!", + "Uninflammable!", + "Whoa", + " dude!", + "All inclusive!", + "Tell your friends!", + "NP is not in P!", + "Notch <3 ez!", + "Music by C418!", + "Livestreamed!", + "Haunted!", + "Polynomial!", + "Terrestrial!", + "All is full of love!", + "Full of stars!", + "Scientific!", + "Cooler than Spock!", + "Collaborate and listen!", + "Never dig down!", + "Take frequent breaks!", + "Not linear!", + "Han shot first!", + "Nice to meet you!", + "Buckets of lava!", + "Ride the pig!", + "Larger than Earth!", + "sqrt(-1) love you!", + "Phobos anomaly!", + "Punching wood!", + "Falling off cliffs!", + "0% sugar!", + "150% hyperbole!", + "Synecdoche!", + "Let's danec!", + "Seecret Friday update!", + "Reference implementation!", + "Lewd with two dudes with food!", + "Kiss the sky!", + "20 GOTO 10!", + "Verlet intregration!", + "Peter Griffin!", + "Do not distribute!", + "Cogito ergo sum!", + "4815162342 lines of code!", + "A skeleton popped out!", + "The Work of Notch!", + "The sum of its parts!", + "BTAF used to be good!", + "I miss ADOM!", + "umop-apisdn!", + "OICU812!", + "Bring me Ray Cokes!", + "Finger-licking!", + "Thematic!", + "Pneumatic!", + "Sublime!", + "Octagonal!", + "Une baguette!", + "Gargamel plays it!", + "Rita is the new top dog!", + "SWM forever!", + "Representing Edsbyn!", + "Matt Damon!", + "Supercalifragilisticexpialidocious!", + "Consummate V's!", + "Cow Tools!", + "Double buffered!", + "Fan fiction!", + "Flaxkikare!", + "Jason! Jason! Jason!", + "Hotter than the sun!", + "Internet enabled!", + "Autonomous!", + "Engage!", + "Fantasy!", + "DRR! DRR! DRR!", + "Kick it root down!", + "Regional resources!", + "Woo", + " facepunch!", + "Woo", + " somethingawful!", + "Woo", + " /v/!", + "Woo", + " tigsource!", + "Woo", + " minecraftforum!", + "Woo", + " worldofminecraft!", + "Woo", + " reddit!", + "Woo", + " 2pp!", + "Google anlyticsed!", + "Now supports åäö!", + "Give us Gordon!", + "Tip your waiter!", + "Very fun!", + "12345 is a bad password!", + "Vote for net neutrality!", + "Lives in a pineapple under the sea!", + "MAP11 has two names!", + "Omnipotent!", + "Gasp!", + "...!", + "Bees", + " bees", + " bees", + " bees!", + "Jag känner en bot!", + "This text is hard to read if you play the game at the default resolution", + " but at 1080p it's fine!", + "Haha", + " LOL!", + "Hampsterdance!", + "Switches and ores!", + "Menger sponge!", + "idspispopd!", + "Eple (original edit)!", + "So fresh", + " so clean!", + "Slow acting portals!", + "Try the Nether!", + "Don't look directly at the bugs!", + "Oh", + " ok", + " Pigmen!", + "Finally with ladders!", + "Scary!", + "Play Minecraft", + " Watch Topgear", + " Get Pig!", + "Twittered about!", + "Jump up", + " jump up", + " and get down!", + "Joel is neat!", + "A riddle", + " wrapped in a mystery!", + "Huge tracts of land!", + "Welcome to your Doom!", + "Stay a while", + " stay forever!", + "Stay a while and listen!", + "Treatment for your rash!", + "\"Autological\" is!", + "Information wants to be free!", + "\"Almost never\" is an interesting concept!", + "Lots of truthiness!", + "The creeper is a spy!", + "Turing complete!", + "It's groundbreaking!", + "Let our battle's begin!", + "The sky is the limit!", + "Jeb has amazing hair!", + "Ryan also has amazing hair!", + "Casual gaming!", + "Undefeated!", + "Kinda like Lemmings!", + "Follow the train", + " CJ!", + "Leveraging synergy!", + "This message will never appear on the splash screen", + " isn't that weird?", + "DungeonQuest is unfair!", + "110813!", + "90210!", + "Check out the far lands!", + "Tyrion would love it!", + "Also try VVVVVV!", + "Also try Super Meat Boy!", + "Also try Terraria!", + "Also try Mount And Blade!", + "Also try Project Zomboid!", + "Also try World of Goo!", + "Also try Limbo!", + "Also try Pixeljunk Shooter!", + "Also try Braid!", + "That's super!", + "Bread is pain!", + "Read more books!", + "Khaaaaaaaaan!", + "Less addictive than TV Tropes!", + "More addictive than lemonade!", + "Bigger than a bread box!", + "Millions of peaches!", + "Fnord!", + "This is my true form!", + "Totally forgot about Dre!", + "Don't bother with the clones!", + "Pumpkinhead!", + "Hobo humping slobo babe!", + "Made by Jeb!", + "Has an ending!", + "Finally complete!", + "Feature packed!", + "Boots with the fur!", + "Stop", + " hammertime!", + "Testificates!", + "Conventional!", + "Homeomorphic to a 3-sphere!", + "Doesn't avoid double negatives!", + "Place ALL the blocks!", + "Does barrel rolls!", + "Meeting expectations!", + "PC gaming since 1873!", + "Ghoughpteighbteau tchoghs!", + "Déjà vu!", + "Déjà vu!", + "Got your nose!", + "Haley loves Elan!", + "Afraid of the big", + " black bat!", + "Doesn't use the U-word!", + "Child's play!", + "See you next Friday or so!", + "From the streets of Södermalm!", + "150 bpm for 400000 minutes!", + "Technologic!", + "Funk soul brother!", + "Pumpa kungen!", + "日本ハロー!", + "한국 안녕하세요!", + "Helo Cymru!", + "Cześć Polsko!", + "你好中国!", + "Привет Россия!", + "Γεια σου Ελλάδα!", + "My life for Aiur!", + "Lennart lennart = new Lennart();", + "I see your vocabulary has improved!", + "Who put it there?", + "You can't explain that!", + "if not ok then return end", + "§1C§2o§3l§4o§5r§6m§7a§8t§9i§ac", + "§kFUNKY LOL", + "SOPA means LOSER in Swedish!", + "Big Pointy Teeth!", + "Bekarton guards the gate!", + "Mmmph", + " mmph!", + "Don't feed avocados to parrots!", + "Swords for everyone!", + "Plz reply to my tweet!", + ".party()!", + "Take her pillow!", + "Put that cookie down!", + "Pretty scary!", + "I have a suggestion.", + "Now with extra hugs!", + "Now java 6!", + "Woah.", + "HURNERJSGER?", + "What's up", + " Doc?", + "Now contains 32 random daily cats!", + ""] + def get_command_signature(self, command): + return f'``{self.clean_prefix}{command.qualified_name} {command.signature}``' + def get_ending_note(self): + return self.messages[randint(0, len(self.messages)-1)] + class General(commands.Cog): def __init__(self, bot): self.bot = bot + self._original_help_command = bot.help_command + bot.help_command = MyHelpCommand() + bot.help_command.cog = self + + def cog_unload(self): + self.bot.help_command = self._original_help_command + + @commands.command() + async def prefix(self, ctx): + """Gets the bot prefixes""" + prefixes = bot.get_prefix(self.bot, ctx.message) + prefixes.pop(1) + prefixes.pop(1) + prefixes.pop(1) + output = "" + for i in prefixes: + output += i+", " + + await ctx.send(f"My prefixes are {output}") @commands.command() async def userinfo(self, ctx, user: discord.Member=None): + """Get information about a user""" #await ctx.send(f"```py\n{dump(user)}```") if not user: @@ -48,6 +438,7 @@ class General(commands.Cog): @commands.command() async def coop(self, ctx, *, user: discord.Member=None): + """Get the coop gang role""" if not user: user = ctx.message.author else: @@ -64,6 +455,7 @@ class General(commands.Cog): @commands.command() async def serverinfo(self, ctx, guild=None): + """Get information about the server you are in""" if not guild: guild = ctx.message.guild else: @@ -90,7 +482,8 @@ class General(commands.Cog): await ctx.send(embed=embed) @commands.command() - async def xboxUser(self, ctx, *, gamertag=None): + async def xboxuser(self, ctx, *, gamertag=None): + """Get information about an xbox live user""" if not gamertag: await ctx.send("You need to specify a gamer, gamer") return @@ -151,7 +544,7 @@ class General(commands.Cog): embed.add_field(name="Reputation", value=reputation, inline=True) await ctx.send(embed=embed) - @commands.command() + @commands.command(hidden=True) async def xboxpresence(self, ctx, *, gamertag=None): if not gamertag: await ctx.send("You need to specify a gamer, gamer") @@ -187,5 +580,74 @@ class General(commands.Cog): embed=discord.Embed(title=gamer["gamertag"], description=state, timestamp=ctx.message.created_at) await ctx.send(embed=embed) + @commands.command() + async def compile(self, ctx, language=None, *, code=None): + """Compile code from a variety of programming languages, powered by """ + """ + listRequest = requests.get("https://wandbox.org/api/list.json") + compilerList = json.loads(listRequest.text) + + for i in compilerList: + if i["language"] == language: + compiler = i["name"] + print(compiler) + """ + compilers = { + "bash": "bash", + "c":"gcc-head-c", + "c#":"dotnetcore-head", + "coffeescript": "coffeescript-head", + "cpp": "gcc-head", + "elixir": "elixir-head", + "go": "go-head", + "java": "openjdk-head", + "javascript":"nodejs-head", + "lua": "lua-5.3.4", + "perl": "perl-head", + "php": "php-head", + "python":"cpython-3.8.0", + "ruby": "ruby-head", + "rust": "rust-head", + "sql": "sqlite-head", + "swift": "swift-5.0.1", + "typescript":"typescript-3.5.1", + "vim-script": "vim-head" + } + if not language: + await ctx.send(f"```json\n{json.dumps(compilers, indent=4)}```") + if not code: + await ctx.send("No code found") + return + try: + compiler = compilers[language.lower()] + except KeyError: + await ctx.send("Language not found") + return + body = { + "compiler": compiler, + "code": code, + "save": True + } + head = { + "Content-Type":"application/json" + } + async with ctx.typing(): + r = requests.post("https://wandbox.org/api/compile.json", headers=head, data=json.dumps(body)) + try: + response = json.loads(r.text) + #await ctx.send(f"```json\n{json.dumps(response, indent=4)}```") + print(f"```json\n{json.dumps(response, indent=4)}```") + except json.decoder.JSONDecodeError: + await ctx.send(f"```json\n{r.text}```") + + try: + embed=discord.Embed(title="Compiled code") + embed.add_field(name="Output", value=f'```{response["program_message"]}```', inline=False) + embed.add_field(name="Exit code", value=response["status"], inline=True) + embed.add_field(name="Link", value=f"[Permalink]({response['url']})", inline=True) + await ctx.send(embed=embed) + except KeyError: + await ctx.send(f"```json\n{json.dumps(response, indent=4)}```") + def setup(bot): bot.add_cog(General(bot)) diff --git a/cogs/help.py b/cogs/help.py deleted file mode 100755 index 91c9c45..0000000 --- a/cogs/help.py +++ /dev/null @@ -1,395 +0,0 @@ -from discord.ext import commands -from random import randint -import os, sys, inspect -current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) -parent_dir = os.path.dirname(current_dir) -sys.path.insert(0, parent_dir) -import bot - -class MyHelpCommand(commands.MinimalHelpCommand): - messages = [ - "As seen on TV!", - "Awesome!", - "100% pure!", - "May contain nuts!", - "Better than Prey!", - "More polygons!", - "Sexy!", - "Limited edition!", - "Flashing letters!", - "Made by Notch!", - "It's here!", - "Best in class!", - "It's finished!", - "Kind of dragon free!", - "Excitement!", - "More than 500 sold!", - "One of a kind!", - "Heaps of hits on YouTube!", - "Indev!", - "Spiders everywhere!", - "Check it out!", - "Holy cow", - " man!", - "It's a game!", - "Made in Sweden!", - "Uses LWJGL!", - "Reticulating splines!", - "Minecraft!", - "Yaaay!", - "Singleplayer!", - "Keyboard compatible!", - "Undocumented!", - "Ingots!", - "Exploding creepers!", - "That's no moon!", - "l33t!", - "Create!", - "Survive!", - "Dungeon!", - "Exclusive!", - "The bee's knees!", - "Down with O.P.P.!", - "Closed source!", - "Classy!", - "Wow!", - "Not on steam!", - "Oh man!", - "Awesome community!", - "Pixels!", - "Teetsuuuuoooo!", - "Kaaneeeedaaaa!", - "Now with difficulty!", - "Enhanced!", - "90% bug free!", - "Pretty!", - "12 herbs and spices!", - "Fat free!", - "Absolutely no memes!", - "Free dental!", - "Ask your doctor!", - "Minors welcome!", - "Cloud computing!", - "Legal in Finland!", - "Hard to label!", - "Technically good!", - "Bringing home the bacon!", - "Indie!", - "GOTY!", - "Ceci n'est pas une title screen!", - "Euclidian!", - "Now in 3D!", - "Inspirational!", - "Herregud!", - "Complex cellular automata!", - "Yes", - " sir!", - "Played by cowboys!", - "OpenGL 1.2!", - "Thousands of colors!", - "Try it!", - "Age of Wonders is better!", - "Try the mushroom stew!", - "Sensational!", - "Hot tamale", - " hot hot tamale!", - "Play him off", - " keyboard cat!", - "Guaranteed!", - "Macroscopic!", - "Bring it on!", - "Random splash!", - "Call your mother!", - "Monster infighting!", - "Loved by millions!", - "Ultimate edition!", - "Freaky!", - "You've got a brand new key!", - "Water proof!", - "Uninflammable!", - "Whoa", - " dude!", - "All inclusive!", - "Tell your friends!", - "NP is not in P!", - "Notch <3 ez!", - "Music by C418!", - "Livestreamed!", - "Haunted!", - "Polynomial!", - "Terrestrial!", - "All is full of love!", - "Full of stars!", - "Scientific!", - "Cooler than Spock!", - "Collaborate and listen!", - "Never dig down!", - "Take frequent breaks!", - "Not linear!", - "Han shot first!", - "Nice to meet you!", - "Buckets of lava!", - "Ride the pig!", - "Larger than Earth!", - "sqrt(-1) love you!", - "Phobos anomaly!", - "Punching wood!", - "Falling off cliffs!", - "0% sugar!", - "150% hyperbole!", - "Synecdoche!", - "Let's danec!", - "Seecret Friday update!", - "Reference implementation!", - "Lewd with two dudes with food!", - "Kiss the sky!", - "20 GOTO 10!", - "Verlet intregration!", - "Peter Griffin!", - "Do not distribute!", - "Cogito ergo sum!", - "4815162342 lines of code!", - "A skeleton popped out!", - "The Work of Notch!", - "The sum of its parts!", - "BTAF used to be good!", - "I miss ADOM!", - "umop-apisdn!", - "OICU812!", - "Bring me Ray Cokes!", - "Finger-licking!", - "Thematic!", - "Pneumatic!", - "Sublime!", - "Octagonal!", - "Une baguette!", - "Gargamel plays it!", - "Rita is the new top dog!", - "SWM forever!", - "Representing Edsbyn!", - "Matt Damon!", - "Supercalifragilisticexpialidocious!", - "Consummate V's!", - "Cow Tools!", - "Double buffered!", - "Fan fiction!", - "Flaxkikare!", - "Jason! Jason! Jason!", - "Hotter than the sun!", - "Internet enabled!", - "Autonomous!", - "Engage!", - "Fantasy!", - "DRR! DRR! DRR!", - "Kick it root down!", - "Regional resources!", - "Woo", - " facepunch!", - "Woo", - " somethingawful!", - "Woo", - " /v/!", - "Woo", - " tigsource!", - "Woo", - " minecraftforum!", - "Woo", - " worldofminecraft!", - "Woo", - " reddit!", - "Woo", - " 2pp!", - "Google anlyticsed!", - "Now supports åäö!", - "Give us Gordon!", - "Tip your waiter!", - "Very fun!", - "12345 is a bad password!", - "Vote for net neutrality!", - "Lives in a pineapple under the sea!", - "MAP11 has two names!", - "Omnipotent!", - "Gasp!", - "...!", - "Bees", - " bees", - " bees", - " bees!", - "Jag känner en bot!", - "This text is hard to read if you play the game at the default resolution", - " but at 1080p it's fine!", - "Haha", - " LOL!", - "Hampsterdance!", - "Switches and ores!", - "Menger sponge!", - "idspispopd!", - "Eple (original edit)!", - "So fresh", - " so clean!", - "Slow acting portals!", - "Try the Nether!", - "Don't look directly at the bugs!", - "Oh", - " ok", - " Pigmen!", - "Finally with ladders!", - "Scary!", - "Play Minecraft", - " Watch Topgear", - " Get Pig!", - "Twittered about!", - "Jump up", - " jump up", - " and get down!", - "Joel is neat!", - "A riddle", - " wrapped in a mystery!", - "Huge tracts of land!", - "Welcome to your Doom!", - "Stay a while", - " stay forever!", - "Stay a while and listen!", - "Treatment for your rash!", - "\"Autological\" is!", - "Information wants to be free!", - "\"Almost never\" is an interesting concept!", - "Lots of truthiness!", - "The creeper is a spy!", - "Turing complete!", - "It's groundbreaking!", - "Let our battle's begin!", - "The sky is the limit!", - "Jeb has amazing hair!", - "Ryan also has amazing hair!", - "Casual gaming!", - "Undefeated!", - "Kinda like Lemmings!", - "Follow the train", - " CJ!", - "Leveraging synergy!", - "This message will never appear on the splash screen", - " isn't that weird?", - "DungeonQuest is unfair!", - "110813!", - "90210!", - "Check out the far lands!", - "Tyrion would love it!", - "Also try VVVVVV!", - "Also try Super Meat Boy!", - "Also try Terraria!", - "Also try Mount And Blade!", - "Also try Project Zomboid!", - "Also try World of Goo!", - "Also try Limbo!", - "Also try Pixeljunk Shooter!", - "Also try Braid!", - "That's super!", - "Bread is pain!", - "Read more books!", - "Khaaaaaaaaan!", - "Less addictive than TV Tropes!", - "More addictive than lemonade!", - "Bigger than a bread box!", - "Millions of peaches!", - "Fnord!", - "This is my true form!", - "Totally forgot about Dre!", - "Don't bother with the clones!", - "Pumpkinhead!", - "Hobo humping slobo babe!", - "Made by Jeb!", - "Has an ending!", - "Finally complete!", - "Feature packed!", - "Boots with the fur!", - "Stop", - " hammertime!", - "Testificates!", - "Conventional!", - "Homeomorphic to a 3-sphere!", - "Doesn't avoid double negatives!", - "Place ALL the blocks!", - "Does barrel rolls!", - "Meeting expectations!", - "PC gaming since 1873!", - "Ghoughpteighbteau tchoghs!", - "Déjà vu!", - "Déjà vu!", - "Got your nose!", - "Haley loves Elan!", - "Afraid of the big", - " black bat!", - "Doesn't use the U-word!", - "Child's play!", - "See you next Friday or so!", - "From the streets of Södermalm!", - "150 bpm for 400000 minutes!", - "Technologic!", - "Funk soul brother!", - "Pumpa kungen!", - "日本ハロー!", - "한국 안녕하세요!", - "Helo Cymru!", - "Cześć Polsko!", - "你好中国!", - "Привет Россия!", - "Γεια σου Ελλάδα!", - "My life for Aiur!", - "Lennart lennart = new Lennart();", - "I see your vocabulary has improved!", - "Who put it there?", - "You can't explain that!", - "if not ok then return end", - "§1C§2o§3l§4o§5r§6m§7a§8t§9i§ac", - "§kFUNKY LOL", - "SOPA means LOSER in Swedish!", - "Big Pointy Teeth!", - "Bekarton guards the gate!", - "Mmmph", - " mmph!", - "Don't feed avocados to parrots!", - "Swords for everyone!", - "Plz reply to my tweet!", - ".party()!", - "Take her pillow!", - "Put that cookie down!", - "Pretty scary!", - "I have a suggestion.", - "Now with extra hugs!", - "Now java 6!", - "Woah.", - "HURNERJSGER?", - "What's up", - " Doc?", - "Now contains 32 random daily cats!", - ""] - def get_command_signature(self, command): - return f'``{self.clean_prefix}{command.qualified_name} {command.signature}``' - def get_ending_note(self): - return self.messages[randint(0, len(self.messages)-1)] - -class Help(commands.Cog): - def __init__(self, bot): - self.bot = bot - self._original_help_command = bot.help_command - bot.help_command = MyHelpCommand() - bot.help_command.cog = self - - def cog_unload(self): - self.bot.help_command = self._original_help_command - - @commands.command() - async def prefix(self, ctx): - prefixes = bot.get_prefix(self.bot, ctx.message) - prefixes.pop(1) - prefixes.pop(1) - prefixes.pop(1) - output = "" - for i in prefixes: - output += i+", " - - await ctx.send(f"My prefixes are {output}") - -def setup(bot): - bot.add_cog(Help(bot)) diff --git a/cogs/trans.py b/cogs/trans.py index 9c5d307..9ca1004 100755 --- a/cogs/trans.py +++ b/cogs/trans.py @@ -31,6 +31,7 @@ class Trans(commands.Cog): @commands.command(help="Translate text in english (using google translate)", brief="Translate to english", aliases=["翻译", "脑热", "动漫"]) async def translate(self, ctx, *, message): + """Translate to english""" response = await translateMsg(message) embed=discord.Embed(title="Translation",description=f"{ctx.message.author.mention} says:", timestamp=ctx.message.created_at, color=0x4d9aff) embed.add_field(name=f"[{response['detectedSourceLanguage']}] Source:" , value=response['input'], inline=False) @@ -39,6 +40,7 @@ class Trans(commands.Cog): @commands.command() async def trans(self, ctx, lan, *, message): + """Translate to a specific language""" response = await translateMsg(message, lan) embed=discord.Embed(title="Translation",description=f"{ctx.message.author.mention} says:", timestamp=ctx.message.created_at, color=0x4d9aff) embed.add_field(name=f"[{response['detectedSourceLanguage']}] Source:" , value=response['input'], inline=False) diff --git a/cogs/utils.py b/cogs/utils.py index 6227e0a..be0d09c 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -48,6 +48,7 @@ class Utils(commands.Cog): @commands.cooldown(1, 25, commands.BucketType.guild) @commands.command() async def findseed(self, ctx): + """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) @@ -83,6 +84,7 @@ class Utils(commands.Cog): @commands.command() async def findsleep(self, ctx): + """Test your sleep""" if ctx.message.channel.id != int(self.bot.config[str(ctx.message.guild.id)]["bot_channel"]): await ctx.message.delete() return @@ -162,6 +164,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: @@ -172,6 +175,7 @@ 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() @@ -223,15 +227,18 @@ class Utils(commands.Cog): @commands.cooldown(1, 60, commands.BucketType.guild) @commands.command() async def someone(self, ctx): + """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' diff --git a/custom_commands.json b/custom_commands.json index f0a3d4b..884bbf4 100755 --- a/custom_commands.json +++ b/custom_commands.json @@ -35,5 +35,7 @@ "!learntoread": "When two players are tied on the leaderboards **ONLY ONE FUCKER WILL BE VISIBLE**", "!mobiledupe": "1) place item to dupe in the crafting grid\n2) keep pressed until the green bar thing appears\nclick any \"Impossible\" craft (red ones)\n3)press the item to dupe (that is in your hotbar now -> it should have moved there since you pressed the impossible craft)\n4)your item should be duped", "!source": "https://github.com/AnInternetTroll/mcbeDiscordBot", - "!sr.c": "https://www.speedrun.com/mcbe" + "!sr.c": "https://www.speedrun.com/mcbe", + "!lbsite": "https://aninternettroll.github.io/mcbeVerifierLeaderboard/index.html", + "!leaderboardsite": "https://aninternettroll.github.io/mcbeVerifierLeaderboard/index.html" } \ No newline at end of file -- cgit v1.2.3 From 5c499b146bf73b337040ceb1ae4bdb02dd0480ad Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Tue, 7 Jul 2020 17:32:50 +0100 Subject: /no longer blocks the bot --- cogs/utils.py | 80 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/cogs/utils.py b/cogs/utils.py index be0d09c..012a8c3 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -16,6 +16,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(""" @@ -35,6 +36,45 @@ async def reportStuff(self, ctx, message): 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): @@ -177,44 +217,8 @@ class Utils(commands.Cog): 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")) -- cgit v1.2.3 From 6022b17889ca5231214e0281bdea3b2388000572 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Thu, 9 Jul 2020 17:11:02 +0100 Subject: Better nitro support --- cogs/general.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/cogs/general.py b/cogs/general.py index 968332b..1e841af 100755 --- a/cogs/general.py +++ b/cogs/general.py @@ -423,9 +423,16 @@ class General(commands.Cog): else: color = user.color + if user.is_avatar_animated(): + profilePic = user.avatar_url_as(format="gif") + else: + profilePic = user.avatar_url_as(format="png") + embed=discord.Embed(title=user.name, description=user.mention, color=color, timestamp=ctx.message.created_at) + if user.premium_since: + embed.add_field(name="Boosting since", value=user.premium_since.date()) #embed.set_thumbnail(url="attachment://temp.webp") - embed.set_thumbnail(url=user.avatar_url_as(format="png")) + embed.set_thumbnail(url=profilePic) embed.add_field(name="Nickname", value=user.display_name, inline=False) embed.add_field(name="Joined on", value=user.joined_at.date(), inline=True) embed.add_field(name="Status", value=user.status, inline=True) @@ -471,13 +478,33 @@ class General(commands.Cog): for i in guild.emojis: emojiList += str(i) + " " + if guild.is_icon_animated(): + serverIcon = guild.icon_url_as(format="gif") + else: + serverIcon = guild.icon_url_as(format="png") + + inactiveMembers = await guild.estimate_pruned_members(days=7) + embed=discord.Embed(title=guild.name, description=guild.description, color=color, timestamp=ctx.message.created_at) - embed.set_thumbnail(url=guild.icon_url_as(format="png")) - embed.set_image(url=guild.splash_url_as(format="png")) + if guild.premium_subscription_count == 0: + pass + else: + if guild.premium_subscription_count == 1: + embed.add_field(name="Boosted by:", value=f"{guild.premium_subscription_count} member", inline=True) + else: + embed.add_field(name="Boosted by:", value=f"{guild.premium_subscription_count} members", inline=True) + if guild.premium_subscribers: + boosters = "" + for i in guild.premium_subscribers: + boosters += i.mention+" " + embed.add_field(name="Boosted by:", value=boosters, inline=True) + embed.set_thumbnail(url=serverIcon) + embed.set_image(url=guild.banner_url_as(format="png")) embed.add_field(name="Created on", value=guild.created_at.date(), inline=True) embed.add_field(name="Members", value=guild.member_count, inline=True) embed.add_field(name="Emojis", value=emojiList, inline=True) embed.add_field(name="Owner", value=guild.owner.mention, inline=True) + embed.add_field(name="Members who haven't spoken in 7 days:", value=inactiveMembers, inline=True) embed.set_footer(text=f"ID: {guild.id}") await ctx.send(embed=embed) -- cgit v1.2.3 From 47464b0619ee29eb9ec1a159e2d17334aaa4b144 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Fri, 10 Jul 2020 21:09:16 +0100 Subject: Fixed /verify in DMs --- cogs/general.py | 2 +- cogs/utils.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cogs/general.py b/cogs/general.py index 1e841af..0612e67 100755 --- a/cogs/general.py +++ b/cogs/general.py @@ -499,7 +499,7 @@ class General(commands.Cog): boosters += i.mention+" " embed.add_field(name="Boosted by:", value=boosters, inline=True) embed.set_thumbnail(url=serverIcon) - embed.set_image(url=guild.banner_url_as(format="png")) + embed.set_image(url=guild.splash_url_as(format="png")) embed.add_field(name="Created on", value=guild.created_at.date(), inline=True) embed.add_field(name="Members", value=guild.member_count, inline=True) embed.add_field(name="Emojis", value=emojiList, inline=True) diff --git a/cogs/utils.py b/cogs/utils.py index 012a8c3..752a7b7 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -161,6 +161,8 @@ class Utils(commands.Cog): @commands.Cog.listener() async def on_message(self, message): + if not message.guild: + return if message.channel.id != int(self.bot.config[str(message.guild.id)]["fair_channel"]): return if message.author.bot: -- cgit v1.2.3 From 0da672ab6b9a38029a2605b30cb65f400c5032e0 Mon Sep 17 00:00:00 2001 From: Thomas Voss <57815710+Mango0x45@users.noreply.github.com> Date: Sun, 12 Jul 2020 01:00:26 +0200 Subject: Update admin.py --- cogs/admin.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cogs/admin.py b/cogs/admin.py index d2b3cab..f0ab204 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -155,6 +155,31 @@ class Admin(commands.Cog): 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_botmaster) + async def ban(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 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 guild.ban(member, reason="A reason idk") + await ctx.send("{0.mention} has been banned 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 guild.unban(member, reason="Time is up") + @commands.command() @commands.check(is_botmaster) async def logs(self, ctx): -- cgit v1.2.3 From c2c05f461db8481f3546efeb24507450fad43059 Mon Sep 17 00:00:00 2001 From: Thomas Voss <57815710+Mango0x45@users.noreply.github.com> Date: Sun, 12 Jul 2020 01:01:56 +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 f0ab204..0099182 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -188,7 +188,7 @@ class Admin(commands.Cog): file = discord.File("discord.log") await ctx.send(file=file) - @commands.command(aliases=['ban'], hidden=True) + @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""" -- cgit v1.2.3 From 110425b3222c4d4e0cec134909f48a041e47971d Mon Sep 17 00:00:00 2001 From: Thomas Voss <57815710+Mango0x45@users.noreply.github.com> Date: Sun, 12 Jul 2020 01:10:28 +0200 Subject: Ban command to ban admins --- cogs/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index 0099182..415d25f 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -172,13 +172,13 @@ class Admin(commands.Cog): embed = discord.Embed(title = "You can't ban me, I'm an almighty bot") await ctx.send(embed = embed) continue - await guild.ban(member, reason="A reason idk") + await ctx.guild.ban(member, reason=reason) await ctx.send("{0.mention} has been banned 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 guild.unban(member, reason="Time is up") + await ctx.guild.unban(member, reason="Time is up") @commands.command() @commands.check(is_botmaster) -- cgit v1.2.3 From 36b282ef5b74370e2faab7e357e742c8167caa88 Mon Sep 17 00:00:00 2001 From: Luca Matei Pintilie Date: Sun, 12 Jul 2020 01:16:13 +0200 Subject: Doesn’t delete messages and fixed doc string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cogs/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/admin.py b/cogs/admin.py index 415d25f..19438b4 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -160,7 +160,7 @@ class Admin(commands.Cog): async def ban(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""" + """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") @@ -172,7 +172,7 @@ class Admin(commands.Cog): embed = discord.Embed(title = "You can't ban me, I'm an almighty bot") await ctx.send(embed = embed) continue - await ctx.guild.ban(member, reason=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 mute_minutes > 0: -- cgit v1.2.3 From 058a82a5a367d38d6c9415c6b66f034476c337c9 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Sun, 12 Jul 2020 20:31:52 +0100 Subject: Started switch from requests to aiohttp --- bot.py | 2 + cogs/admin.py | 6 +- cogs/general.py | 193 ++++++++++++++++++++++++++------------------------- cogs/utils.py | 2 - custom_commands.json | 4 +- 5 files changed, 105 insertions(+), 102 deletions(-) diff --git a/bot.py b/bot.py index 12ea846..d405115 100755 --- a/bot.py +++ b/bot.py @@ -1,6 +1,7 @@ from discord.ext import commands import discord import logging +import aiohttp import datetime import json @@ -35,6 +36,7 @@ class BedrockBot(commands.Bot): super().__init__(command_prefix=get_prefix, case_insensitive=True) self.logger = logging.getLogger('discord') self.messageBlacklist = [] + self.session = aiohttp.ClientSession() with open('custom_commands.json', 'r') as f: self.custom_commands = json.load(f) diff --git a/cogs/admin.py b/cogs/admin.py index 19438b4..3a6299f 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -1,7 +1,6 @@ from discord.ext import commands import discord import asyncio -import subprocess import json import git import os @@ -158,7 +157,7 @@ class Admin(commands.Cog): @commands.command() @commands.check(is_botmaster) async def ban(self, ctx, members: commands.Greedy[discord.Member]=False, - mute_minutes: int = 0, + ban_minutes: int = 0, *, reason: str = "absolutely no reason"): """Mass ban members with an optional mute_minutes parameter to time it""" @@ -172,11 +171,12 @@ class Admin(commands.Cog): 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 {mute_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 mute_minutes > 0: - await asyncio.sleep(mute_minutes * 60) + await asyncio.sleep(ban_minutes * 60) for member in members: await ctx.guild.unban(member, reason="Time is up") diff --git a/cogs/general.py b/cogs/general.py index 0612e67..cf05eb4 100755 --- a/cogs/general.py +++ b/cogs/general.py @@ -515,61 +515,61 @@ class General(commands.Cog): await ctx.send("You need to specify a gamer, gamer") return - r = requests.get(f"https://xbl-api.prouser123.me/profile/gamertag/{gamertag}") - gamer = json.loads(r.text) + async with self.bot.session.get(f'https://xbl-api.prouser123.me/profile/gamertag/{gamertag}') as r: + gamer = json.loads(await r.text()) - try: - await ctx.send(f"{gamer['error']}: {gamer['message']}") - return - except KeyError: - pass - - for i in gamer["profileUsers"][0]["settings"]: - if i["id"] == "GameDisplayName": - gameName = i["value"] - continue - if i["id"] == "AppDisplayPicRaw": - picUrl = i["value"] - continue - if i["id"] == "Gamerscore": - Gamerscore = i["value"]+"<:gamerscore:727131234534424586>" - continue - if i["id"] == "AccountTier": - accountTier = i["value"] - continue - if i["id"] == "XboxOneRep": - reputation = i["value"] - continue - if i["id"] == "PreferredColor": - color = int(json.loads(requests.get(i["value"]).text)["primaryColor"], 16) - continue - if i["id"] == "Location": - location = i["value"] - continue - if i["id"] == "Bio": - #if len(i["value"]) == 0: - # Bio = "Unknown" - #else: - Bio = i["value"] - continue - if i["id"] == "Watermarks": - Watermarks = i["value"] - continue - if i["id"] == "RealName": - RealName = i["value"] - continue - - - embed=discord.Embed(title=gameName, description=Bio, color=color, timestamp=ctx.message.created_at) - embed.set_thumbnail(url=picUrl) - embed.add_field(name="Gamerscore", value=Gamerscore, inline=True) - if len(location) != 0: - embed.add_field(name="Location", value=location, inline=True) - if len(Watermarks) != 0: - embed.add_field(name="Watermarks", value=Watermarks, inline=True) - embed.add_field(name="Account Tier", value=accountTier, inline=True) - embed.add_field(name="Reputation", value=reputation, inline=True) - await ctx.send(embed=embed) + try: + await ctx.send(f"{gamer['error']}: {gamer['message']}") + return + except KeyError: + pass + + for i in gamer["profileUsers"][0]["settings"]: + if i["id"] == "GameDisplayName": + gameName = i["value"] + continue + if i["id"] == "AppDisplayPicRaw": + picUrl = i["value"] + continue + if i["id"] == "Gamerscore": + Gamerscore = i["value"]+"<:gamerscore:727131234534424586>" + continue + if i["id"] == "AccountTier": + accountTier = i["value"] + continue + if i["id"] == "XboxOneRep": + reputation = i["value"] + continue + if i["id"] == "PreferredColor": + color = int(json.loads(requests.get(i["value"]).text)["primaryColor"], 16) + continue + if i["id"] == "Location": + location = i["value"] + continue + if i["id"] == "Bio": + #if len(i["value"]) == 0: + # Bio = "Unknown" + #else: + Bio = i["value"] + continue + if i["id"] == "Watermarks": + Watermarks = i["value"] + continue + if i["id"] == "RealName": + RealName = i["value"] + continue + + + embed=discord.Embed(title=gameName, description=Bio, color=color, timestamp=ctx.message.created_at) + embed.set_thumbnail(url=picUrl) + embed.add_field(name="Gamerscore", value=Gamerscore, inline=True) + if len(location) != 0: + embed.add_field(name="Location", value=location, inline=True) + if len(Watermarks) != 0: + embed.add_field(name="Watermarks", value=Watermarks, inline=True) + embed.add_field(name="Account Tier", value=accountTier, inline=True) + embed.add_field(name="Reputation", value=reputation, inline=True) + await ctx.send(embed=embed) @commands.command(hidden=True) async def xboxpresence(self, ctx, *, gamertag=None): @@ -577,35 +577,35 @@ class General(commands.Cog): await ctx.send("You need to specify a gamer, gamer") return - r = requests.get(f"https://xbl-api.prouser123.me/presence/gamertag/{gamertag}") - gamer = json.loads(r.text) + async with self.bot.session.get(f"https://xbl-api.prouser123.me/presence/gamertag/{gamertag}") as r: + gamer = json.loads(await r.text()) - try: - await ctx.send(f"{gamer['error']}: {gamer['message']}") - return - except KeyError: - pass + try: + await ctx.send(f"{gamer['error']}: {gamer['message']}") + return + except KeyError: + pass - state = gamer["state"] + state = gamer["state"] - try: - game = json.loads(requests.get(f"https://xbl-api.prouser123.me/titleinfo/{gamer['lastSeen']['titleId']}").text) - gameName = game["titles"][0]["name"] - gamePic = game["titles"][0]["images"][4]["url"] - timestamp = dateutil.parser.isoparse(gamer["lastSeen"]["timestamp"]) - lastSeen = True - except Exception as e: - print(e) - lastSeen = False - - if lastSeen: - embed=discord.Embed(title=gamer["gamertag"], description=state, timestamp=timestamp) - embed.set_thumbnail(url=gamePic) - embed.add_field(name="Game", value=gameName, inline=True) - await ctx.send(embed=embed) - else: - embed=discord.Embed(title=gamer["gamertag"], description=state, timestamp=ctx.message.created_at) - await ctx.send(embed=embed) + try: + game = json.loads(requests.get(f"https://xbl-api.prouser123.me/titleinfo/{gamer['lastSeen']['titleId']}").text) + gameName = game["titles"][0]["name"] + gamePic = game["titles"][0]["images"][4]["url"] + timestamp = dateutil.parser.isoparse(gamer["lastSeen"]["timestamp"]) + lastSeen = True + except Exception as e: + print(e) + lastSeen = False + + if lastSeen: + embed=discord.Embed(title=gamer["gamertag"], description=state, timestamp=timestamp) + embed.set_thumbnail(url=gamePic) + embed.add_field(name="Game", value=gameName, inline=True) + await ctx.send(embed=embed) + else: + embed=discord.Embed(title=gamer["gamertag"], description=state, timestamp=ctx.message.created_at) + await ctx.send(embed=embed) @commands.command() async def compile(self, ctx, language=None, *, code=None): @@ -659,22 +659,23 @@ class General(commands.Cog): "Content-Type":"application/json" } async with ctx.typing(): - r = requests.post("https://wandbox.org/api/compile.json", headers=head, data=json.dumps(body)) - try: - response = json.loads(r.text) - #await ctx.send(f"```json\n{json.dumps(response, indent=4)}```") - print(f"```json\n{json.dumps(response, indent=4)}```") - except json.decoder.JSONDecodeError: - await ctx.send(f"```json\n{r.text}```") - - try: - embed=discord.Embed(title="Compiled code") - embed.add_field(name="Output", value=f'```{response["program_message"]}```', inline=False) - embed.add_field(name="Exit code", value=response["status"], inline=True) - embed.add_field(name="Link", value=f"[Permalink]({response['url']})", inline=True) - await ctx.send(embed=embed) - except KeyError: - await ctx.send(f"```json\n{json.dumps(response, indent=4)}```") + async with self.bot.session.post("https://wandbox.org/api/compile.json", headers=head, data=json.dumps(body)) as r: + #r = requests.post("https://wandbox.org/api/compile.json", headers=head, data=json.dumps(body)) + try: + response = json.loads(await r.text()) + #await ctx.send(f"```json\n{json.dumps(response, indent=4)}```") + print(f"```json\n{json.dumps(response, indent=4)}```") + except json.decoder.JSONDecodeError: + await ctx.send(f"```json\n{r.text}```") + + try: + embed=discord.Embed(title="Compiled code") + embed.add_field(name="Output", value=f'```{response["program_message"]}```', inline=False) + embed.add_field(name="Exit code", value=response["status"], inline=True) + embed.add_field(name="Link", value=f"[Permalink]({response['url']})", inline=True) + await ctx.send(embed=embed) + except KeyError: + await ctx.send(f"```json\n{json.dumps(response, indent=4)}```") def setup(bot): bot.add_cog(General(bot)) diff --git a/cogs/utils.py b/cogs/utils.py index 752a7b7..da18fb3 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 diff --git a/custom_commands.json b/custom_commands.json index 884bbf4..a651cc8 100755 --- a/custom_commands.json +++ b/custom_commands.json @@ -37,5 +37,7 @@ "!source": "https://github.com/AnInternetTroll/mcbeDiscordBot", "!sr.c": "https://www.speedrun.com/mcbe", "!lbsite": "https://aninternettroll.github.io/mcbeVerifierLeaderboard/index.html", - "!leaderboardsite": "https://aninternettroll.github.io/mcbeVerifierLeaderboard/index.html" + "!leaderboardsite": "https://aninternettroll.github.io/mcbeVerifierLeaderboard/index.html", + "!stop_crying": "Mods are human, we have lives. If your run isn't verified within 0.1 seconds of you submitting it then please don't Dm us asking us to verify your run. Speedrun.com gives you up to 3 weeks as an estimated time so if after 3 weeks have passed and your run hasn't been verified, then shoot one of us a Dm. If you constantly Dm us and hassle mods, you will get 3 warnings before you become muted and if you still continue, punishments will escalate like other breachments of the rules.", + "!staff": "https://media.discordapp.net/attachments/709672550707363931/721226547817873519/tenor.gif" } \ No newline at end of file -- cgit v1.2.3 From e30c570dea35d5efd7597ae08a24efc2208a4a0b Mon Sep 17 00:00:00 2001 From: Mango0x45 Date: Fri, 17 Jul 2020 19:17:52 +0200 Subject: Removed .vscode/ --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100755 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100755 index 478c149..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "python.pythonPath": "C:\\Users\\matei\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe" -} \ No newline at end of file -- cgit v1.2.3 From 254533614d8be6d31d10b87b4c31bc97444e770b Mon Sep 17 00:00:00 2001 From: Luca Matei Pintilie Date: Wed, 22 Jul 2020 15:10:09 +0200 Subject: Welcome people --- cogs/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cogs/utils.py b/cogs/utils.py index da18fb3..42d2b7b 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -157,6 +157,14 @@ class Utils(commands.Cog): 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 + 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 not message.guild: -- cgit v1.2.3 From 41526349740b6ed8e4d5564ed67934016126d7be Mon Sep 17 00:00:00 2001 From: Luca Matei Pintilie Date: Wed, 22 Jul 2020 15:24:19 +0200 Subject: Ignore the new member message --- cogs/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/utils.py b/cogs/utils.py index 42d2b7b..bacf5e6 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -160,7 +160,7 @@ class Utils(commands.Cog): @commands.Cog.listener() async def on_member_join(self, member): def check(msg): - return msg.author == member + 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>") -- cgit v1.2.3