diff --git a/cogs/developer.py b/cogs/developer.py index 6c9f697..a5b7e04 100644 --- a/cogs/developer.py +++ b/cogs/developer.py @@ -37,6 +37,13 @@ async def sync(self, ctx: commands.Context[CodingBot]): @commands.command(name='load', aliases=['l']) @commands.is_owner() async def _load(self, ctx: commands.Context[CodingBot], cog_: str): + """ + Load a cog + + Usage: + ------ + `{prefix}load [cog]` + """ try: await self.bot.load_extension(cog_) embed = discord.Embed( @@ -55,6 +62,14 @@ async def _load(self, ctx: commands.Context[CodingBot], cog_: str): @commands.command(name='unload', aliases=['u']) @commands.is_owner() async def _unload(self, ctx: commands.Context[CodingBot], cog_: str): + """ + Unload a cog + + Usage: + ------ + `{prefix}unload [cog]` + + """ try: await self.bot.unload_extension(cog_) embed = discord.Embed( @@ -73,6 +88,13 @@ async def _unload(self, ctx: commands.Context[CodingBot], cog_: str): @commands.command(name='reload', aliases=['r']) @commands.is_owner() async def _reload(self, ctx: commands.Context[CodingBot], cog_: str): + """ + Reload a cog + + Usage: + ------ + `{prefix}reload [cog]` + """ try: await self.bot.reload_extension(cog_) embed = discord.Embed( @@ -91,6 +113,14 @@ async def _reload(self, ctx: commands.Context[CodingBot], cog_: str): @commands.command(name='loadall', aliases=['la']) @commands.is_owner() async def _loadall(self, ctx: commands.Context[CodingBot]): + """ + Load all cogs + + Usage: + ------ + `{prefix}loadall` + + """ data = os.listdir('./cogs') cogs: Dict[str, List[str]] = { 'loaded': [], @@ -114,6 +144,14 @@ async def _loadall(self, ctx: commands.Context[CodingBot]): @commands.command(name='unloadall', aliases=['ua', 'uall']) @commands.is_owner() async def _unloadall(self, ctx: commands.Context[CodingBot]): + """ + Unload all cogs + + Usage: + ------ + `{prefix}unloadall` + + """ cogs: Dict[str, List[str]] = { 'unloaded': [], 'not': [] @@ -133,6 +171,14 @@ async def _unloadall(self, ctx: commands.Context[CodingBot]): @commands.command(name='reloadall', aliases=['ra', 'rall']) @commands.is_owner() async def _reloadall(self, ctx: commands.Context[CodingBot]): + """ + Reload all cogs + + Usage: + ------ + `{prefix}reloadall` + + """ cogs: Dict[str, List[str]] = { 'reloaded': [], 'not': [] @@ -153,6 +199,16 @@ async def _reloadall(self, ctx: commands.Context[CodingBot]): @commands.command(name='getusermetric', aliases=['gum'], hidden=True) @commands.is_owner() async def _getusermetric(self, ctx: commands.Context[CodingBot], member: discord.Member): + """ + Get user metric + + Usage: + ------ + `{prefix}getusermetric [member]` + + """ + member = member or ctx.author + record = await self.bot.conn.select_record( 'thanks', table='thanks_info', diff --git a/cogs/fun.py b/cogs/fun.py index 1e859da..f47694c 100644 --- a/cogs/fun.py +++ b/cogs/fun.py @@ -5,6 +5,7 @@ from textwrap import wrap from typing import TYPE_CHECKING, Optional +import base64 import discord from discord.ext import commands from ext.helpers import create_trash_meme, get_rock @@ -30,9 +31,11 @@ async def trash( user: discord.Member ): """ - See your or mentioned user's pp - Example: {prefix}pp @user - Example: {prefix}pp + Throw someone in the trash + Usage: + ------ + `{prefix}trash ` + """ resp1 = await ctx.author.display_avatar.read() resp2 = await user.display_avatar.read() @@ -44,16 +47,18 @@ async def trash( @commands.hybrid_command() async def rock(self, ctx: commands.Context[CodingBot], *, query: Optional[str] = None): + """ + Get a random rock + Usage: + ------ + `{prefix}rock`: *will get a random rock* + `{prefix}rock [rock]`: *will get the [rock]* + + """ rock_info = await get_rock(self) return await self.bot.reply( ctx, - embed=rock_info[0], - view=Rocks( - cog=self, - embed_gen=get_rock, - stars=rock_info[1], - embed=rock_info[0], - ), + embed=rock_info, ) @commands.hybrid_command() @@ -101,13 +106,41 @@ async def meme(self, ctx: commands.Context[CodingBot]): @commands.hybrid_command(name="joke") async def joke(self, ctx: commands.Context[CodingBot]): - response = await self.http.api["some-random-api"]["joke"]() - joke = response['joke'] + """ + Tells a programming joke - embed = discord.Embed(title="He're a joke", description=joke) - embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) + Usage: + ------ + `{prefix}joke`: *will get a random joke* + """ + joke_json = await self.http.api["joke"]["api"]() + + parts = joke_json['type'] + + if parts == "single": + + joke = joke_json['joke'] + + embed = await self.bot.embed( + title = "Here's a joke for you:", + description = joke, + color = discord.Color.random() + ) + + return await self.bot.reply(ctx, embed=embed) + + else: + setup = joke_json['setup'] + delivery = joke_json['delivery'] + + embed = await self.bot.embed( + title = "Here's a joke for you:", + description = f"{setup}\n\n||{delivery}||", + color = discord.Color.random() + ) + await self.bot.reply(ctx, embed=embed) + - await self.bot.reply(ctx, embed=embed) @commands.hybrid_command(name="8ball") async def eightball(self, ctx: commands.Context[CodingBot], *, question: str): @@ -127,36 +160,41 @@ async def eightball(self, ctx: commands.Context[CodingBot], *, question: str): @commands.hybrid_command(name="token") async def token(self, ctx: commands.Context[CodingBot]): - response = await self.http.api["some-random-api"]["bottoken"]() - json = await response.json() + first_string = ctx.author.id + middle_string = random.randint(0, 100) + last_string = random.randint(1000000000,9999999999) - bottoken = json['token'] + token_part1 = base64.b64encode(f"{first_string}".encode("utf-8")).decode("utf-8") + token_part2 = base64.b64encode(f"{middle_string}".encode("utf-8")).decode("utf-8") + token_part3 = base64.b64encode(f"{last_string}".encode("utf-8")).decode("utf-8") - embed = discord.Embed(title="Ha ha ha, I grabbed your bot token.", description=bottoken, color=discord.Color.random()) + final_token = f"{token_part1}.{token_part2}.{token_part3}" + + embed = discord.Embed(title="Ha ha ha, I grabbed your token.", description=final_token, color=discord.Color.random()) embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) await self.bot.reply(ctx, embed=embed) - @commands.hybrid_command(name="animal") - async def animal(self, ctx: commands.Context[CodingBot], animal: Optional[str] = None): - options = ("dog", "cat", "panda", "fox", "red_panda", "koala", "bird", "raccoon", "kangaroo") - if (not animal) or (animal and animal not in options): - animal = random.choice(options) - - response = await self.http.api["some-random-api"]["animal"](animal) - if response.status in range(200,300): - json = await response.json() - - image = json["image"] - fact = json["fact"] - - embed = discord.Embed(title="Here's the animal image you asked.", color=discord.Color.random()) - embed.set_image(url=image) - embed.set_footer(text=fact) - else: - embed = discord.Embed(title="ERROR!", description=f"Received a bad status code of {response.status}") - embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) + # @commands.hybrid_command(name="animal") + # async def animal(self, ctx: commands.Context[CodingBot], animal: Optional[str] = None): + # options = ("dog", "cat", "panda", "fox", "red_panda", "koala", "bird", "raccoon", "kangaroo") + # if (not animal) or (animal and animal not in options): + # animal = random.choice(options) + + # response = await self.http.api["some-random-api"]["animal"](animal) + # if response.status in range(200,300): + # json = await response.json() + + # image = json["image"] + # fact = json["fact"] + + # embed = discord.Embed(title="Here's the animal image you asked.", color=discord.Color.random()) + # embed.set_image(url=image) + # embed.set_footer(text=fact) + # else: + # embed = discord.Embed(title="ERROR!", description=f"Received a bad status code of {response.status}") + # embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) - await self.bot.reply(ctx,embed=embed) + # await self.bot.reply(ctx,embed=embed) @commands.hybrid_group(invoke_without_command=True) async def binary(self, ctx: commands.Context[CodingBot]): @@ -179,36 +217,36 @@ async def binary_decode(self, ctx: commands.Context[CodingBot], binary: str): return await self.bot.reply(ctx, "The binary is an invalid length.") binary = binary.replace(" ", "") string = "".join(chr(int(binary[i:i+8], 2)) for i in range(0, len(binary), 8)) - embed = discord.Embed(title="Encoded to binary", description=string, color=discord.Color.random()) + embed = discord.Embed(title="Decoded from binary", description=string, color=discord.Color.random()) embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) - + await self.bot.reply(ctx,embed=embed) - @commands.hybrid_command(name="lyrics") - async def lyrics(self, ctx: commands.Context[CodingBot], *, query: str = None): - if not query: - embed = discord.Embed(title = "Hey! I'm confused", description=f"You must provide a search argument or I couldn't find the lyrics") - embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) + # @commands.hybrid_command(name="lyrics") + # async def lyrics(self, ctx: commands.Context[CodingBot], *, query: str = None): + # if not query: + # embed = discord.Embed(title = "Hey! I'm confused", description=f"You must provide a search argument or I couldn't find the lyrics") + # embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) - response = await self.http.api["some-random-api"]["lyrics"](query) - if response.status in range(200, 300): - json = await response.json() + # response = await self.http.api["some-random-api"]["lyrics"](query) + # if response.status in range(200, 300): + # json = await response.json() - lyrics = json['lyrics'] - artist = json['author'] - title = json['title'] - thumbnail = json['thumbnail']['genius'] + # lyrics = json['lyrics'] + # artist = json['author'] + # title = json['title'] + # thumbnail = json['thumbnail']['genius'] - for chunk in wrap(lyrics, 4096, replace_whitespace = False): - embed = discord.Embed(title = f"{artist} - {title}", description = chunk, color=discord.Color.random()) - embed.set_thumbnail(url=thumbnail) - embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) + # for chunk in wrap(lyrics, 4096, replace_whitespace = False): + # embed = discord.Embed(title = f"{artist} - {title}", description = chunk, color=discord.Color.random()) + # embed.set_thumbnail(url=thumbnail) + # embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) - else: - embed = discord.Embed(title="ERROR!", description=f"Received a bad status code of {response.status}") - embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) + # else: + # embed = discord.Embed(title="ERROR!", description=f"Received a bad status code of {response.status}") + # embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) - await self.bot.reply(ctx,embed=embed) + # await self.bot.reply(ctx,embed=embed) @commands.hybrid_command(name="reverse") async def reverse(self, ctx: commands.Context[CodingBot], *, text: str): @@ -223,75 +261,75 @@ async def owofy(self, ctx: commands.Context[CodingBot], *, text: str): await self.bot.reply(ctx,embed=embed) # Filters command - @commands.hybrid_group(invoke_without_command=True) - async def filter(self, ctx: commands.Context[CodingBot]): - embed = discord.Embed(title="Filter command", description="Available methods: `invert`, `greyscale`, `colour [hex]`", color=discord.Color.random()) - embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) - await self.bot.reply(ctx,embed=embed) - - @filter.command(name="invert") - async def filter_invert(self, ctx: commands.Context[CodingBot], member: discord.Member = None): - if not member: - member = ctx.author - pfp = member.display_avatar.url - response = await self.http.api["some-random-api"]["filters"]["invert"](pfp) - - embed = discord.Embed(title="Filter command - Invert", color=discord.Color.random()) - embed.set_image(url=response) - embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) - await self.bot.reply(ctx,embed=embed) - - @filter.command(name="greyscale") - async def filter_greyscale(self, ctx: commands.Context[CodingBot], member: discord.Member = None): - if not member: - member = ctx.author - pfp = member.display_avatar.url - response = await self.http.api["some-random-api"]["filters"]["greyscale"](pfp) - - embed = discord.Embed(title="Filter command - Greyscale", color=discord.Color.random()) - embed.set_image(url=response) - embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) - await self.bot.reply(ctx,embed=embed) - - @filter.command(name="colour") - async def filter_colour(self, ctx: commands.Context[CodingBot], member: discord.Member = None, hex_code: str = None): - if not member: - member = ctx.author - if not hex_code: - embed = discord.Embed(title="ERROR!", description="No Hex? Hex colour code is required") - embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) - hex_code = hex_code.replace('#', '') - pfp = member.display_avatar.url - response = await self.http.api["some-random-api"]["filters"]["greyscale"](pfp, hex_code) - - embed = discord.Embed(title="Filter command - Colour", color=discord.Color.random()) - embed.set_image(url=response) - embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) - await self.bot.reply(ctx,embed=embed) - - @filter.command(name="brightness") - async def filter_brightness(self, ctx: commands.Context[CodingBot], member: discord.Member = None): - if not member: - member = ctx.author - pfp = member.display_avatar.url - response = await self.http.api["some-random-api"]["filters"]["brightness"](pfp) - - embed = discord.Embed(title="Filter command - Brightness", color=discord.Color.random()) - embed.set_image(url=response) - embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) - await self.bot.reply(ctx,embed=embed) - - @filter.command(name="threshold") - async def filter_threshold(self, ctx: commands.Context[CodingBot], member: discord.Member = None): - if not member: - member = ctx.author - pfp = member.display_avatar.url - response = await self.http.api["some-random-api"]["filters"]["threshold"](pfp) - - embed = discord.Embed(title="Filter command - Threshold", color=discord.Color.random()) - embed.set_image(url=response) - embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) - await self.bot.reply(ctx,embed=embed) + # @commands.hybrid_group(invoke_without_command=True) + # async def filter(self, ctx: commands.Context[CodingBot]): + # embed = discord.Embed(title="Filter command", description="Available methods: `invert`, `greyscale`, `colour [hex]`", color=discord.Color.random()) + # embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) + # await self.bot.reply(ctx,embed=embed) + + # @filter.command(name="invert") + # async def filter_invert(self, ctx: commands.Context[CodingBot], member: discord.Member = None): + # if not member: + # member = ctx.author + # pfp = member.display_avatar.url + # response = await self.http.api["some-random-api"]["filters"]["invert"](pfp) + + # embed = discord.Embed(title="Filter command - Invert", color=discord.Color.random()) + # embed.set_image(url=response) + # embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) + # await self.bot.reply(ctx,embed=embed) + + # @filter.command(name="greyscale") + # async def filter_greyscale(self, ctx: commands.Context[CodingBot], member: discord.Member = None): + # if not member: + # member = ctx.author + # pfp = member.display_avatar.url + # response = await self.http.api["some-random-api"]["filters"]["greyscale"](pfp) + + # embed = discord.Embed(title="Filter command - Greyscale", color=discord.Color.random()) + # embed.set_image(url=response) + # embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) + # await self.bot.reply(ctx,embed=embed) + + # @filter.command(name="colour") + # async def filter_colour(self, ctx: commands.Context[CodingBot], member: discord.Member = None, hex_code: str = None): + # if not member: + # member = ctx.author + # if not hex_code: + # embed = discord.Embed(title="ERROR!", description="No Hex? Hex colour code is required") + # embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) + # hex_code = hex_code.replace('#', '') + # pfp = member.display_avatar.url + # response = await self.http.api["some-random-api"]["filters"]["greyscale"](pfp, hex_code) + + # embed = discord.Embed(title="Filter command - Colour", color=discord.Color.random()) + # embed.set_image(url=response) + # embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) + # await self.bot.reply(ctx,embed=embed) + + # @filter.command(name="brightness") + # async def filter_brightness(self, ctx: commands.Context[CodingBot], member: discord.Member = None): + # if not member: + # member = ctx.author + # pfp = member.display_avatar.url + # response = await self.http.api["some-random-api"]["filters"]["brightness"](pfp) + + # embed = discord.Embed(title="Filter command - Brightness", color=discord.Color.random()) + # embed.set_image(url=response) + # embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) + # await self.bot.reply(ctx,embed=embed) + + # @filter.command(name="threshold") + # async def filter_threshold(self, ctx: commands.Context[CodingBot], member: discord.Member = None): + # if not member: + # member = ctx.author + # pfp = member.display_avatar.url + # response = await self.http.api["some-random-api"]["filters"]["threshold"](pfp) + + # embed = discord.Embed(title="Filter command - Threshold", color=discord.Color.random()) + # embed.set_image(url=response) + # embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) + # await self.bot.reply(ctx,embed=embed) async def setup(bot: CodingBot): await bot.add_cog(Fun(bot)) diff --git a/cogs/general.py b/cogs/general.py index f9e3508..4204b6e 100644 --- a/cogs/general.py +++ b/cogs/general.py @@ -111,12 +111,26 @@ async def define(self, ctx: commands.Context[CodingBot], *, word: str): @commands.hybrid_group(invoke_without_command=True) async def avatar(self, ctx: commands.Context[CodingBot]): + """ + Commands for getting avatars. + + Usage: + ------ + `{prefix}avatar` *will send a list of available methods* + """ embed = discord.Embed(title="Avatar command", description="Available methods: `main`, `display`") embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) await self.bot.reply(ctx,embed=embed) @avatar.command(name="main") async def avatar_main(self, ctx: commands.Context[CodingBot], member: discord.Member): + """ + Returns the main avatar of a user. + + Usage: + ------ + `{prefix}avatar main [user]` *will send the main avatar of the user* + """ embed = discord.Embed(title=f"{member}'s Main Avatar", description=f"Showing {member.mention}'s Main Avatar", color=discord.Color.random()) embed.set_image(url=member.avatar.url) embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) @@ -124,6 +138,13 @@ async def avatar_main(self, ctx: commands.Context[CodingBot], member: discord.Me @avatar.command(name="display") async def avatar_display(self, ctx: commands.Context[CodingBot], member: discord.Member): + """ + Returns the display avatar of a user. + + Usage: + ------ + `{prefix}avatar display [user]` *will send the display avatar of the user* + """ embed = discord.Embed(title=f"{member}'s Avatar", description=f"Showing {member.mention}'s Avatar", color=discord.Color.random()) embed.set_image(url=member.display_avatar.url) embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url) diff --git a/cogs/helper.py b/cogs/helper.py index 393733c..a48acb1 100644 --- a/cogs/helper.py +++ b/cogs/helper.py @@ -227,7 +227,13 @@ async def help_warnings( ctx: commands.Context[CodingBot], member: discord.Member ) -> None: - + """ + Shows a list of help warnings for a member. + + Usage: + {prefix}helper warnings + + """ embed = discord.Embed( title=f"{member} Help warnings List", color=discord.Color.red()) records = await self.bot.conn.select_record( @@ -252,13 +258,19 @@ async def help_warnings( await self.bot.reply(ctx,embed=embed) - @helper.command(name="clearwarning") + @helper.command(name="clearwarning", aliases = ['chw']) async def help_clearwarning( self, ctx: commands.Context[CodingBot], member: discord.Member, index: int = None ) -> None: + """ + Clears a help warning from a member. + + Usage: + {prefix}helper clearwarning [index] + """ warn = None target = member or ctx.author @@ -304,7 +316,12 @@ async def help_ban( *, reason: str ) -> None: + """ + Ban someone from help channels + Usage: + {prefix}helper ban + """ help_ban_role = ctx.guild.get_role(HELP_BAN_ROLE_ID) read_help_rules_role = ctx.guild.get_role(READ_HELP_RULES_ROLE_ID) if help_ban_role in member.roles: @@ -327,7 +344,12 @@ async def help_unban( ctx: commands.Context[CodingBot], member: discord.Member ) -> None: + """ + Unban someone from help channels + Usage: + {prefix}helper unban + """ help_ban_role = ctx.guild.get_role(HELP_BAN_ROLE_ID) read_help_rules_role = ctx.guild.get_role(READ_HELP_RULES_ROLE_ID) if not help_ban_role in member.roles: @@ -351,7 +373,12 @@ async def help_verify( ctx: commands.Context[CodingBot], target: discord.Member ) -> None: + """ + Help verify a member + Usage: + {prefix}helper verify + """ read_help_rules_role = ctx.guild.get_role(READ_HELP_RULES_ROLE_ID) if read_help_rules_role in target.roles: diff --git a/cogs/listeners.py b/cogs/listeners.py index 18561f4..eeda6be 100644 --- a/cogs/listeners.py +++ b/cogs/listeners.py @@ -90,7 +90,7 @@ async def user_mentioned(self, message: discord.Message): for member in message.mentions: record = self.bot.afk_cache.get(message.guild.id) if record: - record = record.get(message.author.id) + record = record.get(member.id) if record: reason, time_ = record em = discord.Embed( @@ -236,17 +236,20 @@ async def invite_in_message(self, message: discord.Message): @commands.Cog.listener('on_message') async def repo_mention(self, message: discord.Message): - if 'discord.py' in message.content and not message.author.bot: - regex = re.search(r'Rapptz/discord.py(#\d+)?', message.content) - if regex: - base_link = "https://github.com/Rapptz/discord.py" - group = regex.group(0) - if '#' in group: - group = group.split('#')[1] - base_link += f"/pull/{group}" - resp = await self.bot.session.get(base_link) - if resp.ok: - await message.channel.send(base_link) + """ + Format: repo: user/repo + + Responds with a link to the repo. + """ + if message.content.lower().startswith('repo:') and not message.author.bot: + repo = message.content.split('repo:')[1].strip() + if '/' not in repo: + return + user, repo = repo.split('/') + base_link = f"https://github.com/{user}/{repo}" + resp = await self.bot.session.get(base_link) + if resp.ok: + await message.channel.send(base_link) diff --git a/cogs/misc.py b/cogs/misc.py index e68c4fe..95c82eb 100644 --- a/cogs/misc.py +++ b/cogs/misc.py @@ -66,8 +66,7 @@ async def afk(self, ctx: commands.Context[CodingBot], *, reason: Optional[str] = assert isinstance(ctx.author, discord.Member) assert ctx.guild is not None - if not reason: - reason = "AFK" + reason = reason or "AFK" member = ctx.author staff_role = ctx.guild.get_role(795145820210462771) on_pat_staff = member.guild.get_role(726441123966484600) # "on_patrol_staff" role @@ -147,6 +146,13 @@ async def run(self, ctx, *, codeblock: str): @commands.hybrid_group(name="thanks", invoke_without_command=True) @commands.cooldown(1, 10, commands.BucketType.member) async def thanks(self, ctx: commands.Context[CodingBot], member: discord.Member): + """ + See how many thanks someone has. + + Usage: + ------ + `{prefix}thanks {user}`: *will show how many thanks user has* + """ record = await self.bot.conn.select_record( 'thanks', table='thanks_info', @@ -205,6 +211,13 @@ async def thank(self, ctx: commands.Context[CodingBot], member: discord.Member, @thank.command(name="show") @commands.has_any_role(783909939311280129, 797688360806121522) async def thank_show(self, ctx: commands.Context[CodingBot], member: discord.Member): + """ + Show the thanks information of a user. + + Usage: + ------ + `{prefix}thank show {user}`: *will show the thanks information of user* + """ records = await self.bot.conn.select_record( 'thanks', table='thanks_data', @@ -253,6 +266,14 @@ async def thank_show(self, ctx: commands.Context[CodingBot], member: discord.Mem @thank.command(name="delete") @commands.has_any_role(783909939311280129, 797688360806121522) async def thank_delete(self, ctx: commands.Context[CodingBot], thank_id: str): + """ + Delete a thank. + + Usage: + ------ + `{prefix}thank delete [thank_id]`: *will delete the thank with the id [thank_id]* + + """ record = await self.bot.conn.select_record( 'thanks', table='thanks_data', @@ -333,6 +354,9 @@ async def thank_leaderboard(self, ctx: commands.Context[CodingBot]): @commands.hybrid_group(invoke_without_command=True) async def trainee(self, ctx: commands.Context[CodingBot]): + """ + Sends the trainee help menu. + """ await ctx.send_help('trainee') @trainee.command(name="list") @@ -362,23 +386,31 @@ async def trainee_list(self, ctx: commands.Context[CodingBot]): ) await self.bot.reply(ctx, embed=embed) - # @commands.hybrid_command(aliases=['sp']) - # @commands.cooldown(5, 60.0, type=commands.BucketType.user) - # async def spotify(self, ctx: commands.Context, member: discord.Member = None): - # member = member or ctx.author - # spotify = Spotify(bot=self.bot, member=member) - # embed = await spotify.get_embed() - # if not embed: - # if member == ctx.author: - # return await ctx.reply(f"You are currently not listening to spotify!", mention_author=False) - # return await self.bot.reply( - # ctx, - # f"{member.mention} is not listening to Spotify", - # mention_author=False, - # allowed_mentions=discord.AllowedMentions(users=False) - # ) - # embed, file, view = embed - # await self.bot.send(ctx, embed=embed, file=file, view=view) + @commands.hybrid_command(aliases=['sp']) + @commands.cooldown(5, 60.0, type=commands.BucketType.user) + async def spotify(self, ctx: commands.Context, member: discord.Member = None): + """ + Shows the spotify status of a member. + + Usage: + ------ + `{prefix}spotify`: *will show your spotify status* + `{prefix}spotify [member]`: *will show the spotify status of [member]* + """ + member = member or ctx.author + spotify = Spotify(bot=self.bot, member=member) + embed = await spotify.get_embed() + if not embed: + if member == ctx.author: + return await ctx.reply(f"You are currently not listening to spotify!", mention_author=False) + return await self.bot.reply( + ctx, + f"{member.mention} is not listening to Spotify", + mention_author=False, + allowed_mentions=discord.AllowedMentions(users=False) + ) + embed, file, view = embed + await self.bot.send(ctx, embed=embed, file=file, view=view) # @commands.command(name='sauce') # async def sauce(self, ctx: commands.Context[CodingBot], source: Optional[str] = None): @@ -433,7 +465,7 @@ async def trainee_list(self, ctx: commands.Context[CodingBot]): # embed = discord.Embed(timestamp=discord.utils.utcnow()) # embed.add_field( - # name="Anime Title", + # name="Anime Title", DD # value=f"Native: {native}\nEnglish: {english}\nRomaji: {romaji}", # inline=False # ) diff --git a/cogs/moderation.py b/cogs/moderation.py index a090ffb..01dc3aa 100644 --- a/cogs/moderation.py +++ b/cogs/moderation.py @@ -11,7 +11,7 @@ from ext.errors import InsufficientPrivilegeError from ext.models import CodingBot, TimeConverter from ext.ui.view import ConfirmButton - +from ext.consts import TCR_MEMBER_ROLE_ID if TYPE_CHECKING: from ext.models import CodingBot @@ -684,14 +684,14 @@ async def welcomer( await ctx.send_help('welcomer') @welcomer.command(name="enable") - async def welcomer_enable(self, ctx: commands.Context[CodingBot]) -> None: + async def welcomer_enable(self, ctx: commands.Context[CodingBot], help = "Enable welcomer") -> None: if not self.bot.welcomer_enabled: self.bot.welcomer_enabled = True await self.bot.reply(ctx, "Welcomer is now enabled.") else: await self.bot.reply(ctx, "Welcomer is already enabled.") - @welcomer.command(name="disable") + @welcomer.command(name="disable", help = "Disable welcomer") async def welcomer_disable(self, ctx: commands.Context[CodingBot]) -> None: if self.bot.welcomer_enabled: self.bot.welcomer_enabled = False @@ -699,7 +699,7 @@ async def welcomer_disable(self, ctx: commands.Context[CodingBot]) -> None: else: await self.bot.reply(ctx, "Welcomer is already disabled.") - @welcomer.command(name="redirect") + @welcomer.command(name="redirect", help = "Set welcomer channel") async def welcomer_redirect( self, ctx: commands.Context[CodingBot], @@ -724,11 +724,18 @@ async def raid_mode(self, ctx: commands.Context[CodingBot]) -> None: Raid mode commands Commands: + {prefix}raid-mode enable *start raid mode* + {prefix}raid-mode disable *stop raid mode* """ await ctx.send_help('raid-mode') @raid_mode.command(name="enable") async def raid_mode_enable(self, ctx: commands.Context[CodingBot]) -> None: + """ + Enable raid mode + + This will ban all members that have joined during the raid. + """ if not self.bot.raid_mode_enabled: if self.bot.raid_checker.possible_raid: self.bot.raid_mode_enabled = True diff --git a/cogs/tasks.py b/cogs/tasks.py index e20c1a2..efd9534 100644 --- a/cogs/tasks.py +++ b/cogs/tasks.py @@ -28,7 +28,7 @@ async def status_change(self): statuses = ['over TCR', 'you', 'swas', '@everyone', 'general chat', 'discord', ',help', 'your mom', 'bob and shadow argue', 'swas simp for false', 'new members', 'the staff team', 'helpers', 'code', 'mass murders', 'karen be an idiot', 'a video', 'watches', 'bob', 'fight club', 'youtube', - 'https://devbio.me/u/CodingBot', 'potatoes', 'simps', 'people', 'my server', 'humans destroy the world', + 'potatoes', 'simps', 'people', 'my server', 'humans destroy the world', 'AI take over the world', 'female bots 😳', 'dinosaurs', 'https://youtu.be/o-YBDTqX_ZU', 'idiots', 'the beginning of WWIII', 'verified bot tags with envy', 'Server Boosters (boost to get your name on here)', 'OG members', "dalek rising from the ashes", 'spongebob', 'turtles', 'SQUIRREL!!!', 'people get banned', diff --git a/ext/helpers.py b/ext/helpers.py index c61746d..12935fb 100644 --- a/ext/helpers.py +++ b/ext/helpers.py @@ -189,8 +189,8 @@ def generate_image(self, member: discord.Member, **kwargs: Any) -> discord.File: else: if vanity: invite = vanity - if len(invite.code) > 15: - invite.code = f'{invite.code[:15]}...' + if len(invite.code) > 7: + invite.code = f'{invite.code[:7]}...' text = f'• Joined using vanity invite: {invite.code} ({invite.uses} uses)' else: text = 'I couldn\'t find who invited them' @@ -615,9 +615,8 @@ async def get_embed(self) -> Tuple[discord.Embed, discord.File, discord.ui.View] async def get_rock(self): rock = await self.http.api["rock"]["random"]() name = rock["name"] - desc = rock["desc"] + desc = rock["description"] image = rock["image"] - rating = rock["rating"] embed = await self.bot.embed( title=f"🪨 {name}", url=image or "https://www.youtube.com/watch?v=o-YBDTqX_ZU", @@ -625,7 +624,7 @@ async def get_rock(self): ) if image is not None and image != "none" and image != "": embed.set_thumbnail(url=image) - return (embed, rating) + return (embed) class AntiRaid: """ diff --git a/ext/http.py b/ext/http.py index bde657b..a4f679b 100644 --- a/ext/http.py +++ b/ext/http.py @@ -14,8 +14,8 @@ def __init__(self, session: aiohttp.ClientSession): }, # ////////////////////////////////////////////////////////////////////////////////////// "rock": { - "random": lambda: self.get("https://rockapi.apiworks.tech/random", _json=True), - "top": lambda: self.get("https://rockapi.apiworks.tech/top"), + "random": lambda: self.get("https://rockapi.apiworks.tech/rock/random", _json=True), + "top": lambda: self.get("https://rockapi.apiworks.tech/rock/top"), }, "numbers": { "random": lambda _type="trivia": self.api["numbers"]["random_"+_type](), @@ -55,6 +55,9 @@ def __init__(self, session: aiohttp.ClientSession): "brightness": lambda pfp: f"https://some-random-api.ml/canvas/brightness?avatar={pfp}", "threshold": lambda pfp: f"https://some-random-api.ml/canvas/threshold?avatar={pfp}", } + }, + "joke": { + "api": lambda: self.get("https://v2.jokeapi.dev/joke/Programming", _json=True), } } diff --git a/ext/models.py b/ext/models.py index 9554480..4633da9 100644 --- a/ext/models.py +++ b/ext/models.py @@ -334,7 +334,7 @@ def __init__(self) -> None: } ) super().__init__( - command_prefix=[')'], intents=INTENTS, case_insensitive=True, + command_prefix=['>'], intents=INTENTS, case_insensitive=True, help_command=help_command ) self.conn: Database = discord.utils.MISSING @@ -353,6 +353,14 @@ def __init__(self) -> None: self.afk_cache: Dict[int, Dict[int, Tuple[str, int]]] = {} self.version: Version = VERSION self.logger: logging.Logger = create_logger("CodingBot") + self.owner_ids = [ + 556119013298667520, # Swas.py + 879644654587478027, # Swas's alt + 690420846774321221, # BobDotCom + 579041484796461076, # Conch.py + 687882857171255309, # Lexionas74 + 462067035556282378, # Gxpy + ] async def setup_hook(self) -> None: self.raid_checker.check_for_raid.start() diff --git a/ext/ui/view.py b/ext/ui/view.py index 27d9778..7447347 100644 --- a/ext/ui/view.py +++ b/ext/ui/view.py @@ -15,62 +15,6 @@ from ext.models import CodingBot -class Rocks(discord.ui.View): - def __init__(self, *, cog, embed_gen, stars, embed): - self.cog = cog - self.embed_gen = embed_gen - self.pages = [ - (embed, stars), - ] - self.page = 0 - super().__init__() - for child in self.children: - if child.custom_id == "stars_count": - child.label = "⭐" * stars if stars else "o" - - @discord.ui.button(label="-", custom_id="stars_count") - async def stars_hud(self, interaction, button): - pass - - @discord.ui.button(label="<", custom_id="prev", disabled=True) - async def prev_rock(self, interaction, button): - if self.page == 0: - button.disabled = True - return await interaction.response.edit_message(view=self) - self.page -= 1 - data = self.pages[self.page * -1] - self.stars = data[1] - for child in self.children: - if child.custom_id == "stars_count": - child.label = "⭐" * self.stars if self.stars else "o" - elif child.custom_id == "next": - if self.page + 1 < len(self.pages): - child.Style = discord.ButtonStyle.gray - return await interaction.response.edit_message( - embed=data[0], view=self - ) - - @discord.ui.button( - label=">", custom_id="next", style=discord.ButtonStyle.green - ) - async def next_rock(self, interaction, button): - if self.page + 1 == len(self.pages): - button.Style = discord.ButtonStyle.green - await self.gen() - self.page += 1 - data = self.pages[self.page] - self.stars = data[1] - for child in self.children: - if child.custom_id == "stars_count": - child.label = "⭐" * self.stars if self.stars else "o" - elif child.custom_id == "prev": - child.disabled = False - await interaction.response.edit_message(embed=data[0], view=self) - - async def gen(self): - self.pages.append(await self.embed_gen(self.cog)) - - class Piston(discord.ui.View): def __init__(