From e0c9dc3b4df9c0acd29389d6d583303f62805187 Mon Sep 17 00:00:00 2001 From: TheKaushikGoswami Date: Tue, 1 Feb 2022 20:19:38 +0530 Subject: [PATCH] Release v2.2 --- cogs/api_cmd.py | 8 +- cogs/fun.py | 12 +- cogs/help.py | 4 +- cogs/mod.py | 435 ++++++++++++++++++++++-------------------------- cogs/olympus.py | 7 +- cogs/owner.py | 47 ++++++ cogs/utility.py | 63 +++---- 7 files changed, 289 insertions(+), 287 deletions(-) diff --git a/cogs/api_cmd.py b/cogs/api_cmd.py index ee59631..a13f9a8 100644 --- a/cogs/api_cmd.py +++ b/cogs/api_cmd.py @@ -266,7 +266,7 @@ async def wasted(self, ctx, member: Option(discord.Member, "Select the Wasted Me member = ctx.author async with aiohttp.ClientSession() as session: - async with session.get(f'https://some-random-api.ml/canvas/wasted?avatar={member.display_avatar.with_static_format("png").url}') as af: + async with session.get(f'https://some-random-api.ml/canvas/wasted?avatar={member.display_avatar.with_format("png").url}') as af: if 300 > af.status >= 200: fp = io.BytesIO (await af.read()) fileee = discord.File(fp, "wasted.png") @@ -284,7 +284,7 @@ async def passed(self, ctx, member: Option(discord.Member, "Select the Member wh member = ctx.author async with aiohttp.ClientSession() as session: - async with session.get(f'https://some-random-api.ml/canvas/passed?avatar={member.display_avatar.with_static_format("png").url}') as af: + async with session.get(f'https://some-random-api.ml/canvas/passed?avatar={member.display_avatar.with_format("png").url}') as af: if 300 > af.status >= 200: fp = io.BytesIO (await af.read()) fileee = discord.File(fp, "passed.png") @@ -300,7 +300,7 @@ async def comment(self, ctx, comment: Option(str, "The Contents of the Comment", if member == None: member = ctx.author name = str(member.name).replace(" ", "+") - avatar=member.display_avatar.with_static_format("png").url + avatar=member.display_avatar.with_format("png").url comment=comment.replace(" ", "+") image = f"https://some-random-api.ml/canvas/youtube-comment?username={name}&avatar={avatar}&comment={comment}" await ctx.respond(image) @@ -314,7 +314,7 @@ async def tweet(self, ctx, tweet: Option(str, "The Contents of the Tweet", requi member = ctx.author username=str(member.name).replace(" ", "+") displayname=str(member.display_name).replace(" ", "+") - avatar=member.display_avatar.with_static_format("png").url + avatar=member.display_avatar.with_format("png").url comment=tweet.replace(" ", "+") image = f"https://some-random-api.ml/canvas/tweet?username={username}&displayname={displayname}&comment={comment}&avatar={avatar}" await ctx.respond(image) diff --git a/cogs/fun.py b/cogs/fun.py index a0d2869..ffc67f0 100644 --- a/cogs/fun.py +++ b/cogs/fun.py @@ -40,8 +40,8 @@ async def _8ball(self, ctx, *, question: Option(str, "Write Your Question", requ e = discord.Embed(title=f"MAGIC 8-BALL", color=ctx.author.color) e.set_thumbnail( url=f'https://media.tenor.com/images/47ceded02690a48da88d02bb7c1f5f46/tenor.gif') - e.add_field(name=f"๐Ÿ”ฎQuestion by `{ctx.author}`: `{question}`", - value=f"**My Magic Foretells me:\n `{random.choice(responses)}`**",) + e.add_field(name=f"**๐Ÿ”ฎQuestion by `{ctx.author}`:**", value=f"`{question}`", inline=False) + e.add_field(name=f"**My Magic Foretells me:**", value = f"`{random.choice(responses)}`", inline=False) await ctx.respond(embed=e) # Lovemeter @@ -520,12 +520,8 @@ async def snap(self, ctx, member: Option(discord.Member, "Choose the Member", re d.text((90, 25+w), message, font=titlefnt, fill=colour["content"]) img.save('img.png') - if member.avatar.is_animated(): - await member.display_avatar.with_static_format("gif").save("pfp.gif") - f2 = Image.open("pfp.gif") - else: - await member.display_avatar.with_static_format("png").save("pfp.png") - f2 = Image.open("pfp.png") + await member.display_avatar.with_format("png").save("pfp.png") + f2 = Image.open("pfp.png") f1 = Image.open("img.png") f2.thumbnail((50, 55)) f2.save("pfp.png") diff --git a/cogs/help.py b/cogs/help.py index ff53850..b5fdc3d 100644 --- a/cogs/help.py +++ b/cogs/help.py @@ -24,7 +24,7 @@ async def help(self, ctx): embed1.set_thumbnail( url=f"https://media2.giphy.com/media/401pPJe8AtsC55e1y8/source.gif") embed1.add_field( - name="๐Ÿ›ก๏ธ Moderation", value=f'`nick` `purge` `purgeuser` `mute` `unmute` `kick` `ban` `nuke` `role` `slowmode` `lock` `unlock` `name_role`', inline=False) + name="๐Ÿ›ก๏ธ Moderation", value=f'`nick` `purge` `purgeuser` `mute` `unmute` `kick` `ban` `nuke` `role` `slowmode` `lock` `unlock`', inline=False) embed1.add_field( name="โšฝ Fun & Games", value=f'`8ball` `activity` `lovemeter` `rps` `sad/happy/angry` `hello` `lenny` `flip` `f` `calculator` `diceroll` `password` `slots` `cheers` `simp` `iq` `roast` `kill`', inline=False) embed1.add_field( @@ -36,7 +36,7 @@ async def help(self, ctx): embed1.add_field( name="๐Ÿค– Olympus", value=f'`about` `ping` `invite` `support` `help` `uptime`', inline=False) embed1.add_field( - name=f"๐Ÿ‘‘ Owner Only", value=f'`stats` `serverlist` `createinvite` `leave`', inline=False) + name=f"๐Ÿ‘‘ Owner Only", value=f'`stats` `serverlist` `createinvite` `leave` `change_presence`', inline=False) embed1.set_footer( text=f"Olympus is made with โค๏ธ | _TheKauchikG_#5300", icon_url=f'{ctx.author.avatar.url}') diff --git a/cogs/mod.py b/cogs/mod.py index f3a013f..8aa016d 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -1,3 +1,4 @@ +import datetime import discord from discord import Option from discord.commands.errors import ApplicationCommandInvokeError @@ -5,7 +6,6 @@ from discord.ext import commands from discord.commands import slash_command from discord.ext.commands.errors import MissingPermissions -import asyncio class Mod(commands.Cog): def __init__(self, bot): @@ -17,28 +17,25 @@ def __init__(self, bot): @commands.has_permissions(manage_nicknames=True) async def nick(self, ctx, member: Option(discord.Member, "Select the user", required=True), nickname: Option(str, "Write the new nickname of the user", required=False, default=None)): """โœ’๏ธ Change the nickname of a user""" - if nickname == None: - nick_msg = f"```{member}\'s nickname was reset by {ctx.author}```" - else: - nick_msg = f"```{member}\'s nickname was changed to {nickname} by {ctx.author}```" - if ctx.user.id == ctx.guild.owner_id: - await member.edit(nick=nickname) - await ctx.respond(nick_msg) - return - elif ctx.user.top_role.position > member.top_role.position: - await member.edit(nick=nickname) - await ctx.respond(nick_msg) - return - else: - await ctx.respond(f"**<:Cross:902943066724388926> You can't change the nickname of that person**", ephemeral=True) - - @nick.error - async def nick_error(self, ctx, error): - print(type(error), "--- Nickname Command") - if isinstance(error, MissingPermissions): + try: + if nickname == None: + nick_msg = f"```{member}\'s nickname was reset by {ctx.author}```" + else: + nick_msg = f"```{member}\'s nickname was changed to {nickname} by {ctx.author}```" + if ctx.user.id == ctx.guild.owner_id: + await member.edit(nick=nickname) + await ctx.respond(nick_msg) + return + elif ctx.user.top_role.position > member.top_role.position: + await member.edit(nick=nickname) + await ctx.respond(nick_msg) + return + else: + await ctx.respond(f"**<:Cross:902943066724388926> You can't change the nickname of that person**", ephemeral=True) + except discord.Forbidden: + await ctx.respond(f"**<:Cross:902943066724388926> I don't have enough permissions to change their nickname!**") + except commands.MissingPermissions: await ctx.respond(f"**<:Cross:902943066724388926> You need `Manage Nicknames` permission to be able to use this command.**") - if isinstance(error, ApplicationCommandInvokeError): - await ctx.respond(f"**<:Cross:902943066724388926> The user is having a higher role than me...**") # Purge @@ -46,22 +43,20 @@ async def nick_error(self, ctx, error): @commands.has_permissions(manage_messages=True) async def purge(self, ctx, amount: Option(int, "Enter the number of messages to be purged(Default = 3)", required=False)): """๐Ÿงน Clears a certain amount of messages from the channel""" - if amount == None: - amount = 3 - else: - amount = int(amount) - if amount <= 200: - await ctx.channel.purge(limit=amount) - await ctx.respond(f"** The higher-ups have purged some messages.**", delete_after=5) - - else: - await ctx.respond(f"**<:Cross:902943066724388926> Please input a number smaller than 200**", ephemeral=True) - - @purge.error - async def purge_error(self, ctx, error): - print(type(error), "--- Purge Command") - if isinstance(error, MissingPermissions): + try: + if amount == None: + amount = 3 + else: + amount = int(amount) + if amount <= 200: + await ctx.channel.purge(limit=amount) + await ctx.respond(f"** The higher-ups have purged some messages.**", delete_after=5) + else: + await ctx.respond(f"**<:Cross:902943066724388926> Please input a number smaller than 200**", ephemeral=True) + except commands.MissingPermissions: await ctx.respond(f"**<:Cross:902943066724388926> You need `Manage Messages` permission to be able to use this command.**") + except discord.Forbidden: + await ctx.respond(f"**<:Cross:902943066724388926> I don't have enough permissions to delete the messages!**") # PurgeUser @@ -69,31 +64,28 @@ async def purge_error(self, ctx, error): @commands.has_permissions(manage_messages=True) async def purgeuser(self, ctx, member: Option(discord.Member, "Select the Member", required=True), amount: Option(int, "Enter the number of messages to be purged(Default = 5)", required=False)): """๐Ÿงน Clears a certain amount of messages by a specific user""" - if amount == None: - amount = 5 - else: - amount = int(amount) - channel = ctx.channel - - def check(ctx): - return ctx.author.id == member.id - - if ctx.user.id == ctx.guild.owner_id: - await channel.purge(limit=amount, check=check, before=None) - await ctx.respond(f"** The higher-ups have purged someone\'s messsages.**", delete_after=5) - elif ctx.user.top_role.position > member.top_role.position: - await channel.purge(limit=amount, check=check, before=None) - await ctx.respond(f"** The higher-ups have purged someone\'s messsages.**", delete_after=5) - else: - await ctx.respond(f"**<:Cross:902943066724388926> You are not cool enough to delete that person\'s messages.**", ephemeral=True) - - @purgeuser.error - async def purgeuser_error(self, ctx, error): - print(type(error), "--- Purge User Command") - if isinstance(error, MissingPermissions): + try: + if amount == None: + amount = 5 + else: + amount = int(amount) + channel = ctx.channel + + def check(ctx): + return ctx.author.id == member.id + + if ctx.user.id == ctx.guild.owner_id: + await channel.purge(limit=amount, check=check, before=None) + await ctx.respond(f"** The higher-ups have purged someone\'s messsages.**", delete_after=5) + elif ctx.user.top_role.position > member.top_role.position: + await channel.purge(limit=amount, check=check, before=None) + await ctx.respond(f"** The higher-ups have purged someone\'s messsages.**", delete_after=5) + else: + await ctx.respond(f"**<:Cross:902943066724388926> You are not cool enough to delete that person\'s messages.**", ephemeral=True) + except commands.MissingPermissions: await ctx.respond(f"**<:Cross:902943066724388926> You need `Manage Messages` permission to be able to use this command.**") - if isinstance(error, ApplicationCommandInvokeError): - await ctx.respond(f"**<:Cross:902943066724388926> I don\'t have enough permissions to delete this user\'s messages.**") + except discord.Forbidden: + await ctx.respond(f"**<:Cross:902943066724388926> I don't have enough permissions to delete the messages!**") # Nuke Channel @@ -101,53 +93,47 @@ async def purgeuser_error(self, ctx, error): @commands.has_permissions(manage_channels=True) async def nukechannel(self, ctx): """๐Ÿ’ฅ Nukes a channel and re-create another clone of it""" - await ctx.defer() - channel = ctx.channel - positions = ctx.channel.position - n = await channel.clone() - await n.edit(position=positions) - await channel.delete() - await n.send(" :ok_hand: Successfully Nuked this channel") - await n.send("https://giphy.com/gifs/animation-explosion-bomb-FnatKdwxRxpVC?utm_source=media-link&utm_medium=landing&utm_campaign=Media%20Links&utm_term=") - - @nukechannel.error - async def nukechannel_error(self, ctx, error): - print(type(error), "--- Nuke Channel Command") - if isinstance(error, MissingPermissions): + try: + await ctx.defer() + channel = ctx.channel + positions = ctx.channel.position + n = await channel.clone() + await n.edit(position=positions) + await channel.delete() + await n.send(" :ok_hand: Successfully Nuked this channel") + await n.send("https://giphy.com/gifs/animation-explosion-bomb-FnatKdwxRxpVC?utm_source=media-link&utm_medium=landing&utm_campaign=Media%20Links&utm_term=") + except commands.MissingPermissions: await ctx.respond(f"**<:Cross:902943066724388926> You need `Manage Channels` permission to be able to use this command.**") - if isinstance(error, ApplicationCommandInvokeError): + except discord.Forbidden: await ctx.respond(f"**<:Cross:902943066724388926> I don\'t have enough permissions to nuke this channel.**") # Role @slash_command() @commands.has_permissions(manage_roles=True) - async def role(self, ctx, member: Option(discord.Member, "Select the member", required=True), role: Option(discord.Role, "Select the role", required=True)): + async def role(self, ctx, member: Option(discord.Member, "Select the member to change role of", required=True), role: Option(discord.Role, "Select the role", required=True)): """๐Ÿฅ Add or Remove a role from a User""" - if ctx.user.id == ctx.guild.owner_id: - if role not in member.roles: - await member.add_roles(role) - await ctx.respond(f"`{member}` was given role `{role.name}`.") + try: + if ctx.user.id == ctx.guild.owner_id: + if role not in member.roles: + await member.add_roles(role) + await ctx.respond(f"`{member}` was given role `{role.name}`.") + else: + await member.remove_roles(role) + await ctx.respond(f"`{member}` was removed from the role `{role.name}`.") + elif ctx.user.top_role.position > role.position: + if role not in member.roles: + await member.add_roles(role) + await ctx.respond(f"`{member}` was given role `{role.name}`.") + else: + await member.remove_roles(role) + await ctx.respond(f"`{member}` was removed from the role `{role.name}`.") else: - await member.remove_roles(role) - await ctx.respond(f"`{member}` was removed from the role `{role.name}`.") - elif ctx.user.top_role.position > role.position: - if role not in member.roles: - await member.add_roles(role) - await ctx.respond(f"`{member}` was given role `{role.name}`.") - else: - await member.remove_roles(role) - await ctx.respond(f"`{member}` was removed from the role `{role.name}`.") - else: - await ctx.respond(f"**<:Cross:902943066724388926> That role is higher than or same as your top-most role!**", ephemeral=True) - - @role.error - async def role_error(self, ctx, error): - print(type(error), "--- Role Command") - if isinstance(error, MissingPermissions): + await ctx.respond(f"**<:Cross:902943066724388926> That role is higher than or same as your top-most role!**", ephemeral=True) + except commands.MissingPermissions: await ctx.respond(f"**<:Cross:902943066724388926> You need `Manage Roles` permission to be able to use this command.**") - if isinstance(error, ApplicationCommandInvokeError): - await ctx.respond(f"**<:Cross:902943066724388926> I don\'t have enough permissions to manage this role.**") + except discord.Forbidden: + await ctx.respond(f"**<:Cross:902943066724388926> I don\'t have enough permissions to manage that role.**") # Slowmode @@ -155,19 +141,18 @@ async def role_error(self, ctx, error): @commands.has_permissions(manage_channels=True) async def slowmode(self, ctx, time: Option(str, "Enter the time (in seconds)", required=False)): """๐Ÿ• Adds or Removes the slowmode from the channel""" - if time == None: - await ctx.channel.edit(slowmode_delay=0) - await ctx.respond(f"Slowmode removed.") - else: - await ctx.channel.edit(slowmode_delay=int(time)) - await ctx.respond(f"`{time}s` of slowmode was set on the current channel.") - - @slowmode.error - async def slowmode_error(self, ctx, error): - print(type(error), "--- Slowmode Command") - if isinstance(error, MissingPermissions): + try: + if time == None: + await ctx.channel.edit(slowmode_delay=0) + await ctx.respond(f"Slowmode removed.") + else: + await ctx.channel.edit(slowmode_delay=int(time)) + await ctx.respond(f"`{time}s` of slowmode was set on the current channel.") + except commands.MissingPermissions: await ctx.respond(f"**<:Cross:902943066724388926> You need `Manage Channels` permission to be able to use this command.**") - if isinstance(error, ApplicationCommandInvokeError): + except discord.Forbidden: + await ctx.respond(f"**<:Cross:902943066724388926> I don\'t have enough permissions to edit this channel\'s settings.**") + except discord.HTTPException: await ctx.respond(f"**<:Cross:902943066724388926> Invalid Duration! The slowmode duration must be less than or equal to 21600 seconds.**") # Channel Lock @@ -178,14 +163,13 @@ async def lock(self, ctx): """๐Ÿ”’ Locks the channel for the server members""" overwrite = ctx.channel.overwrites_for(ctx.guild.default_role) overwrite.send_messages = False - await ctx.channel.set_permissions(ctx.guild.default_role, overwrite=overwrite) - await ctx.respond("**๐Ÿ”’ Channel locked down. Only staff members may speak. Do not bring the topic to other channels or risk disciplinary actions.**") - - @lock.error - async def lock_error(self, ctx, error): - print(type(error), "--- Lock Command") - if isinstance(error, MissingPermissions): + try: + await ctx.channel.set_permissions(ctx.guild.default_role, overwrite=overwrite) + await ctx.respond("**๐Ÿ”’ Channel locked down. Only staff members may speak. Do not bring the topic to other channels or risk disciplinary actions.**") + except commands.MissingPermissions: await ctx.respond(f"**<:Cross:902943066724388926> You need `Manage Channels` permission to be able to use this command.**") + except discord.Forbidden: + await ctx.respond(f"**<:Cross:902943066724388926> I don\'t have enough permissions to edit this channel\'s settings.**") # Channel Unlock @@ -195,169 +179,148 @@ async def unlock(self, ctx): """๐Ÿ”“ Unlocks the locked channel for the server members""" overwrite = ctx.channel.overwrites_for(ctx.guild.default_role) overwrite.send_messages = True - await ctx.channel.set_permissions(ctx.guild.default_role, overwrite=overwrite) - await ctx.respond("**๐Ÿ”“ Channel unlocked.**") - - @unlock.error - async def unlock_error(self, ctx, error): - print(type(error), "--- Unlock Command") - if isinstance(error, MissingPermissions): + try: + await ctx.channel.set_permissions(ctx.guild.default_role, overwrite=overwrite) + await ctx.respond("**๐Ÿ”“ Channel unlocked.**") + except commands.MissingPermissions: await ctx.respond(f"**<:Cross:902943066724388926> You need `Manage Channels` permission to be able to use this command.**") + except discord.Forbidden: + await ctx.respond(f"**<:Cross:902943066724388926> I don\'t have enough permissions to edit this channel\'s settings.**") # Mute @slash_command() - @commands.has_permissions(manage_messages=True) - async def mute(self, ctx, member: Option(discord.Member, "Select the user", required=True), time: Option(str, "Mention the mute duration(s: seconds, m: minutes, h: hours, d: days)", required=True), reason: Option(str, "Write the reason for mute", required=False, default="Reason Not Mentioned")): + @commands.has_permissions(moderate_members=True) + async def mute(self, ctx, member: Option(discord.Member, "Select the User to be Muted", required=True), time: Option(str, "Mention the mute duration(s:seconds, m:minutes, h:hours, d:days)", required=True), reason:Option(str, "Write the reason for mute", required=False)): """๐Ÿค Mutes a member for a specific duration of time""" - guild = ctx.guild - Muted = discord.utils.get(guild.roles, name="Muted") - # Gets the numbers from the time argument, start to -1 - seconds = int(time[:-1]) - duration = time[-1] # Gets the timed maniulation, s, m, h, d - if duration == "s": - seconds = seconds * 1 - elif duration == "m": - seconds = seconds * 60 - elif duration == "h": - seconds = seconds * 60 * 60 - elif duration == "d": - seconds = seconds * 86400 + if reason == None: + reason = f"Muted by {ctx.author} - No Reason Mentioned" else: - await ctx.respond("Invalid time input", ephemeral=True) - return - - if not Muted: - Muted = await guild.create_role(name="Muted") - - for channel in guild.channels: - await channel.set_permissions(Muted, speak=False, send_messages=False, read_message_history=True, read_messages=False) - - if ctx.user.id == ctx.guild.owner_id: - await member.add_roles(Muted, reason=reason) - await ctx.respond(f":ok_hand: {member.mention} was successfully muted!") - await asyncio.sleep(seconds) - await member.remove_roles(Muted, reason="Mute Period Over") - return - elif ctx.user.top_role.position > member.top_role.position: - await member.add_roles(Muted, reason=reason) - await ctx.respond(f":ok_hand: {member.mention} was successfully muted!") - await asyncio.sleep(seconds) - await member.remove_roles(Muted, reason="Mute Period Over") - elif ctx.user.id == 737903565313409095: - await member.add_roles(Muted, reason=reason) - await ctx.respond(f":ok_hand: {member.mention} was successfully muted!") - await asyncio.sleep(seconds) - await member.remove_roles(Muted, reason="Mute Period Over") + reason = f"Muted by {ctx.author} - {reason}" + prefix = int(time[:-1]) + suffix = time[-1] # Gets the timed maniulation, s, m, h, d + if suffix == "s": + duration = datetime.timedelta(seconds=prefix) + elif suffix == "m": + duration = datetime.timedelta(minutes=prefix) + elif suffix == "h": + duration = datetime.timedelta(hours=prefix) + elif suffix == "d": + duration = datetime.timedelta(days=prefix) else: - await ctx.respond(f"**<:Cross:902943066724388926> You are not cool enough to mute that person.**", ephemeral=True) + await ctx.respond("Invalid time input (Guide:- s:seconds, m:minutes, h:hours, d:days)", ephemeral=True) + return - @mute.error - async def mute_error(self, ctx, error): - print(type(error), "--- Mute Command") - if isinstance(error, MissingPermissions): - await ctx.respond(f"**<:Cross:902943066724388926> You need `Manage Messages` permission to be able to use this command.**") + try: + if ctx.user.id == ctx.guild.owner_id: + await member.timeout_for(duration=duration, reason=reason) + await ctx.respond(f":ok_hand: {member.mention} was successfully muted!") + elif ctx.user.top_role.position > member.top_role.position: + await member.timeout_for(duration=duration, reason=reason) + await ctx.respond(f":ok_hand: {member.mention} was successfully muted!") + else: + await ctx.respond(f"**<:Cross:902943066724388926> You are not cool enough to mute that person.**", ephemeral=True) + except discord.Forbidden: + await ctx.respond(f"**<:Cross:902943066724388926> I don't have enough permissions to mute this person!**") + except discord.HTTPException: + await ctx.respond(f"**<:Cross:902943066724388926> You can mute a member for maximum `28 days(28d)` due to Discord API limitations**") + except commands.MissingPermissions: + await ctx.respond(f"**<:Cross:902943066724388926> You need `Moderate Members` permission to be able to use this command.**") # Unmute @slash_command() @commands.has_permissions(manage_messages=True) - async def unmute(self, ctx, member: Option(discord.Member, "Select the user", required=True)): + async def unmute(self, ctx, member: Option(discord.Member, "Select the user to unmute", required=True)): """๐Ÿ—ฃ๏ธ Unmute a member""" - role = discord.utils.get(ctx.guild.roles, name="Muted") - if role in member.roles: - await member.remove_roles(role) - await ctx.respond(f"**:ok_hand: Successfully unmuted {member.mention}.**") - else: - await ctx.respond(f"**Is That Person even muted?** <:hmm:905680733597736980>") - - @unmute.error - async def unmute_error(self, ctx, error): - print(type(error), "--- Unmute Command") - if isinstance(error, MissingPermissions): - await ctx.respond(f"**<:Cross:902943066724388926> You need `Manage Messages` permission to be able to use this command.**") + try: + if member.communication_disabled_until != None: + await member.remove_timeout() + await ctx.respond(f"**:ok_hand: Successfully unmuted {member.mention}.**") + else: + await ctx.respond(f"**Is That Person even muted?** <:hmm:905680733597736980>") + except commands.MissingPermissions: + await ctx.respond(f"**<:Cross:902943066724388926> You need `Moderate Members` permission to be able to use this command.**") + except discord.Forbidden: + await ctx.respond(f"**<:Cross:902943066724388926> I don\'t have enough permissions to mute/unmute this member.**") # Kick @slash_command() @commands.has_permissions(kick_members=True) - async def kick(self, ctx, member: Option(discord.Member, "Select the user", required=True), reason: Option(str, "Write the reason", required=False, default="Reason Not Mentioned")): + async def kick(self, ctx, member: Option(discord.Member, "Select the user", required=True), reason: Option(str, "Write the reason for kick", required=False)): """๐Ÿฆถ Kicks a user from the server.""" + if reason == None: + reason = f"Kicked by {ctx.author} - No Reason Mentioned" + else: + reason = f"Kicked by {ctx.author} - {reason}" kick_embed = discord.Embed( description=f"**<:Tick:902943008096391299> `{member}` was successfully kicked!**", color=0x3498DB) - if ctx.user.id == ctx.guild.owner_id: - await member.kick(reason=reason) - await ctx.respond(embed=kick_embed) - return - elif ctx.user.top_role.position > member.top_role.position: - await member.kick(reason=reason) - await ctx.respond(embed=kick_embed) - else: - await ctx.respond(f"**<:Cross:902943066724388926> You are not cool enough to kick that person.**", ephemeral=True) - - @kick.error - async def kick_error(self, ctx, error): - print(type(error), "--- Kick Command") - if isinstance(error, MissingPermissions): + try: + if ctx.user.id == ctx.guild.owner_id: + await member.kick(reason=reason) + await ctx.respond(embed=kick_embed) + return + elif ctx.user.top_role.position > member.top_role.position: + await member.kick(reason=reason) + await ctx.respond(embed=kick_embed) + else: + await ctx.respond(f"**<:Cross:902943066724388926> You are not cool enough to kick that person.**", ephemeral=True) + except commands.MissingPermissions: await ctx.respond(f"**<:Cross:902943066724388926> You need `Kick Members` permission to be able to use this command.**") - if isinstance(error, ApplicationCommandInvokeError): - await ctx.respond(f"**<:Cross:902943066724388926> I don\'t have enough permissions to kick this member!**") - + except discord.Forbidden: + await ctx.respond(f"**<:Cross:902943066724388926> I don\'t have enough permissions to kick that person.**") # Ban @slash_command() @commands.has_permissions(ban_members=True) - async def ban(self, ctx, member: Option(discord.Member, "Select the user", required=True), reason: Option(str, "Write the reason", required=False, default="Reason Not Mentioned")): + async def ban(self, ctx, member: Option(discord.Member, "Select the user", required=True), reason: Option(str, "Write the reason for ban", required=False)): """โœˆ๏ธ Bans a Member from the server""" + if reason == None: + reason = f"Banned by {ctx.author} - No Reason Mentioned" + else: + reason = f"Banned by {ctx.author} - {reason}" ban_embed = discord.Embed( description=f"**<:Tick:902943008096391299> `{member}` was successfully banned!**", color=0x3498DB) - if ctx.user.id == ctx.guild.owner_id: - await member.ban(reason=reason) - await ctx.respond(embed=ban_embed) - return - elif ctx.user.top_role.position > member.top_role.position: - await member.ban(reason=reason) - await ctx.respond(embed=ban_embed) - else: - await ctx.respond(f"**<:Cross:902943066724388926> You are not cool enough to ban that person.**", ephemeral=True) - - @ban.error - async def ban_error(self, ctx, error): - print(type(error), "--- Ban Command") - if isinstance(error, MissingPermissions): + try: + if ctx.user.id == ctx.guild.owner_id: + await member.ban(reason=reason) + await ctx.respond(embed=ban_embed) + return + elif ctx.user.top_role.position > member.top_role.position: + await member.ban(reason=reason) + await ctx.respond(embed=ban_embed) + else: + await ctx.respond(f"**<:Cross:902943066724388926> You are not cool enough to ban that person.**", ephemeral=True) + except commands.MissingPermissions: await ctx.respond(f"**<:Cross:902943066724388926> You need `Ban Members` permission to be able to use this command.**") - if isinstance(error, ApplicationCommandInvokeError): - await ctx.respond(f"**<:Cross:902943066724388926> I don\'t have enough permissions to ban this member!**") + except discord.Forbidden: + await ctx.respond(f"**<:Cross:902943066724388926> I don\'t have enough permissions to ban that person.**") - @ban.error - async def ban_error(self, ctx, error): - print(type(error), "--- Ban Command") - if isinstance(error, MissingPermissions): - await ctx.send(f"**<:Cross:902943066724388926> You need `Ban Members` permission to be able to use this command.**") - if isinstance(error, ApplicationCommandInvokeError): - await ctx.send(f"**<:Cross:902943066724388926> I don\'t have enough permissions to ban this member!**") # Unban @slash_command() @commands.has_permissions(ban_members=True) - async def unban(self, ctx, user: Option(str, "Enter the user ID"), reason: Option(str, "Write the reason", required=False, default="Reason Not Mentioned")): + async def unban(self, ctx, user: Option(str, "Enter the user ID"), reason: Option(str, "Write the reason for unban", required=False)): """๐Ÿ›ฌ Unbans a Member from the server""" + if reason == None: + reason = f"Unbanned by {ctx.author} - No Reason Mentioned" + else: + reason = f"Unbanned by {ctx.author} - {reason}" guild = ctx.guild unban_user = await self.bot.fetch_user(int(user)) unban_embed = discord.Embed( description=f"**<:Tick:902943008096391299> `{unban_user.name}` was unbanned!**", color=0x3498DB) - await guild.unban(unban_user) - await ctx.respond(embed=unban_embed) - - @unban.error - async def unban_error(self, ctx, error): - print(type(error), "--- Role Command") - if isinstance(error, MissingPermissions): + try: + await guild.unban(unban_user, reason=reason) + await ctx.respond(embed=unban_embed) + except commands.MissingPermissions: await ctx.respond(f"**<:Cross:902943066724388926> You need `Ban Members` permission to be able to use this command.**") - if isinstance(error, NotFound): - await ctx.respond(f"**<:Cross:902943066724388926> Are You sure this user is banned? Coz Am Not.**") - + except discord.Forbidden: + await ctx.respond(f"**<:Cross:902943066724388926> I don\'t have enough permissions to ban that person.**") + except discord.NotFound: + await ctx.respond(f"**<:Cross:902943066724388926> Are You sure this user is banned? Coz Am Pretty sure He/She Isn't banned.**") def setup(bot): bot.add_cog(Mod(bot)) diff --git a/cogs/olympus.py b/cogs/olympus.py index 8b9cb97..3fc70e8 100644 --- a/cogs/olympus.py +++ b/cogs/olympus.py @@ -1,9 +1,14 @@ import discord, datetime, time -from discord import slash_command +from discord import command, slash_command from discord.ext import commands +import sys import datetime +import random import platform import time +from ago import human +import collections +from discord.ext.commands import bot import discord.utils start_time = time.time() diff --git a/cogs/owner.py b/cogs/owner.py index 925e13e..d24b807 100644 --- a/cogs/owner.py +++ b/cogs/owner.py @@ -104,6 +104,53 @@ async def leave_error(self, ctx, error): if isinstance(error, NotOwner): await ctx.respond(f"**<:Cross:902943066724388926> Hey! You lack permission to use this command as you don't own me!**") +# Say + + @slash_command() + @commands.is_owner() + async def say(self, ctx, message: Option(str, "Enter the message You want me to say", required=True)): + """๐Ÿ’ฌ Makes Me speak Something For You""" + say_embed = discord.Embed( + description=f'**<:Tick:902943008096391299> Your message was sent successfully!**', color=0x3498DB) + await ctx.respond(embed=say_embed, ephemeral=True) + await ctx.send(message) + + @say.error + async def say_error(self, ctx, error): + print(type(error), "--- Say Command") + if isinstance(error, NotOwner): + await ctx.respond(f"**<:Cross:902943066724388926> Hey! You lack permission to use this command as you don't own me!**") + +# Change Presence + + @slash_command() + @commands.is_owner() + async def change_presence(self, ctx, status: Option(str, "Status of the Bot", choices=["Online", "Idle", "Do Not Disturb", "Invisible"], required=False), activity: Option(str, "The Activity of the Bot", choices=["Playing", "Watching", "Listening", "Streaming"], required=False), activity_name = Option(str, "Name of the Activity", required=False, default="/help | Made with โค๏ธ by _TheKauchikG_#5300")): + """๐Ÿš€ Change the Activity of the Bot""" + statuses = {"Online" : discord.Status.online, "Idle" : discord.Status.idle, "Do Not Disturb" : discord.Status.do_not_disturb, "Invisible" : discord.Status.invisible} + final_status = statuses.get(status) + + activities = {"Playing" : discord.ActivityType.playing, "Watching" : discord.ActivityType.watching, "Listening" : discord.ActivityType.listening, "Streaming" : discord.ActivityType.streaming} + final_activity = activities.get(activity) + + presence_embed = discord.Embed(description=f'**<:Tick:902943008096391299> The Presence was updated successfully!**', color=0x3498DB) + try: + if final_activity == discord.ActivityType.streaming: + link = "https://www.twitch.tv/thekaushikgoswami" + await self.bot.change_presence(status=discord.Status.streaming, activity=discord.Activity(type=final_activity,name=activity_name, url=link)) + await ctx.respond(embed=presence_embed) + elif final_activity == discord.ActivityType.playing: + game=discord.Game(activity_name) + await self.bot.change_presence(status=final_status, activity=game) + await ctx.respond(embed=presence_embed) + else: + await self.bot.change_presence(status=final_status, activity=discord.Activity(type=final_activity, name=activity_name)) + await ctx.respond(embed=presence_embed) + except discord.InvalidArgument: + await ctx.respond(f"**<:Cross:902943066724388926> There was an issue in setting up that activity. Please Try Again**", ephemeral=True) + except NotOwner: + await ctx.respond(f"**<:Cross:902943066724388926> Hey! You lack permission to use this command as you don't own me!**") + # Rules @slash_command(guild_ids=[931474769797316638]) diff --git a/cogs/utility.py b/cogs/utility.py index 5983b2d..f59557e 100644 --- a/cogs/utility.py +++ b/cogs/utility.py @@ -19,34 +19,43 @@ def __init__(self, bot): async def userinfo(self, ctx, member: Option(discord.Member, "Choose The Member", required=False)): """๐Ÿ‘ค Gets Information about a User""" await ctx.defer() - if not member: + if member == None: member = ctx.author uroles = [] + for role in member.roles[1:]: if role.is_default(): continue uroles.append(role.mention) - uroles.reverse() - timestamp = 'ใ…ค' time = member.created_at time1 = member.joined_at if member.status == discord.Status.online: status = '<:online:909452628763750400>' elif member.status == discord.Status.idle: status = '<:idle:909452697999118337>' - elif member.status == discord.Status.dnd: + elif member.status == discord.Status.do_not_disturb: status = '<:dnd:909452665224822826>' - else: + elif member.status == discord.Status.offline: status = '<:offline:909452732719570974>' if member.activity == None: - activity = 'None' + activity = "None" else: - activity = member.activities[-1].name - if member.activities[0].details != None: - timestamp = member.activities[0].details + if member.activities[-1].type == discord.ActivityType.custom: + activity = "None" + elif member.activities[-1].type == discord.ActivityType.watching: + activity = f"Watching {member.activities[-1].name}" + elif member.activities[-1].type == discord.ActivityType.listening: + activity = f"Listening to {member.activities[-1].name}" + elif member.activities[-1].type == discord.ActivityType.playing: + activity = f"Playing {member.activities[-1].name}" + elif member.activities[-1].type == discord.ActivityType.streaming: + activity = f"Streaming {member.activities[-1].name} on {member.activities[-1].platform}" else: - timestamp = ' ' + try: + activity = member.activities[-1].name + except: + activity = member.activities[-1] embed = discord.Embed(color=ctx.author.color, type="rich") embed.set_thumbnail(url=f"{member.avatar.url}") embed.set_author(name=f"{member.name}'s information", @@ -54,17 +63,16 @@ async def userinfo(self, ctx, member: Option(discord.Member, "Choose The Member" embed.add_field(name="__General information__", value=f'**Nickname :** `{member.display_name}`\n' f'**ID :** {member.id}\n' f'**Account created :** `{member.created_at.strftime("%A, %B %d %Y %H:%M:%S %p")}`\n{human(time, 4)}\n' - f'**Server Joined :** `{member.created_at.strftime("%A, %B %d %Y %H:%M:%S %p")}`\n{human(time1, 4)}\n', inline=False) + f'**Server Joined :** `{member.joined_at.strftime("%A, %B %d %Y %H:%M:%S %p")}`\n{human(time1, 4)}\n', inline=False) embed.add_field(name="__Role info__", value=f'**Highest role :** {member.top_role.mention}\n' f'**Color** : `{member.color}`\n' f'**Role(s) :** {", ".join(uroles)}\n', inline=False) - embed.add_field(name="__Presence__", value=f'**Status : ** {status}\n' - f'**Activity : ** ```{activity}\nใ…ค{timestamp}```') + embed.add_field(name="__Presence__", value=f'**Status :** {status}\n' + f'**Activity :** ```{activity}```') embed.set_footer( text=f"Requested by {ctx.author.name}", icon_url=ctx.author.avatar.url) await ctx.edit(embed=embed) - return # avatar @@ -75,7 +83,7 @@ async def avatar(self, ctx, user: Option(discord.Member, "Choose the Member", re user = ctx.author embed = discord.Embed( title=f"`{user.name}`'s avatar", color=ctx.author.color) - embed.description = f'[PNG]({user.display_avatar.with_static_format("png")}) | [JPEG]({user.display_avatar.with_static_format("jpeg")}) | [WEBP]({user.display_avatar.with_static_format("webp")})' + embed.description = f'[PNG]({user.display_avatar.with_format("png")}) | [JPEG]({user.display_avatar.with_format("jpeg")}) | [WEBP]({user.display_avatar.with_format("webp")})' embed.set_image(url=str(user.display_avatar.with_static_format("png"))) embed.set_footer( text=f"Requested by {ctx.author}", icon_url=ctx.author.avatar.url) @@ -257,37 +265,20 @@ async def timer(self, ctx, time: Option(str, "Enter the time you want to set the # Mentions @slash_command() - async def mentions(self, ctx, limit: Option(str, "Number of messages to be checked for mentions (10 by Default)", default=10, required=False), user: Option(discord.Member, "Select the User whose mentions You want to check for", required=False)): + async def mentions(self, ctx, limit: Option(int, "Number of messages to be checked for mentions (10 by Default)", default=10, required=False), user: Option(discord.Member, "Select the User whose mentions You want to check for", required=False)): """๐Ÿ”ด Counts the amount of mentions You got in last certain amount of messages""" user = ctx.author if not user else user try: - limit = int(limit) + limit = limit except ValueError: - return await ctx.respond('The limit for the searching must be a number.') + return await ctx.respond('The limit for the searching must be a number.', ephemeral=True) if limit > 100: return await ctx.respond('Max limit is 100 messages. This is to keep the command consistent.') counter = 0 async for message in ctx.channel.history(limit=limit): if user.mentioned_in(message): counter += 1 - await ctx.respond('You have been pinged {} times in the last {} messages.'.format(counter, limit)) - -# Say - - @slash_command() - @commands.has_permissions(manage_messages=True) - async def say(self, ctx, message: Option(str, "Enter the message You want me to say", required=True)): - """๐Ÿ’ฌ Makes Me speak Something For You""" - say_embed = discord.Embed( - description=f'**<:Tick:902943008096391299> Your message was sent successfully!**', color=0x3498DB) - await ctx.respond(embed=say_embed, ephemeral=True) - await ctx.send(message) - - @say.error - async def say_error(self, ctx, error): - print(type(error), "--- Say Command") - if isinstance(error, MissingPermissions): - await ctx.respond(f"**<:Cross:902943066724388926> You need `Manage Messages` permission to be able to use this command.**") + await ctx.respond(f'User `{user} have been pinged {counter} times in the last {limit} messages.') def setup(bot): bot.add_cog(Utility(bot))