diff --git a/Cogs/Configuration/Views/Customationview.py b/Cogs/Configuration/Views/Customationview.py index c070c6cf..fe867893 100644 --- a/Cogs/Configuration/Views/Customationview.py +++ b/Cogs/Configuration/Views/Customationview.py @@ -357,5 +357,4 @@ async def Finish(self, interaction: discord.Interaction, button: discord.ui.Butt } Customisation.update_one(filter, {"$set": embed_data}, upsert=True) embed = discord.Embed(title=f"{greencheck} Customisation Saved", description="Your embed has been saved." ,color=discord.Colour.brand_green()) - await interaction.response.edit_message(content=None, embed=embed, view=None) \ No newline at end of file diff --git a/Cogs/Configuration/Views/Utilityview.py b/Cogs/Configuration/Views/Utilityview.py index 9bc7bbd2..42689db0 100644 --- a/Cogs/Configuration/Views/Utilityview.py +++ b/Cogs/Configuration/Views/Utilityview.py @@ -47,4 +47,7 @@ async def refreshembed(interaction): embed = discord.Embed(title="<:Pen:1126527802255085628> Utilties Module", description=f"**Enabled:** {modulemsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", color=discord.Color.dark_embed()) embed.set_thumbnail(url=interaction.guild.icon) embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) \ No newline at end of file + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") \ No newline at end of file diff --git a/Cogs/Configuration/Views/applicationsview.py b/Cogs/Configuration/Views/applicationsview.py index 3bb7b570..99c4ff9a 100644 --- a/Cogs/Configuration/Views/applicationsview.py +++ b/Cogs/Configuration/Views/applicationsview.py @@ -155,4 +155,7 @@ async def refreshembed(interaction): inline=False) embed.set_thumbnail(url=interaction.guild.icon) embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) \ No newline at end of file + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") \ No newline at end of file diff --git a/Cogs/Configuration/Views/connectionrolesview.py b/Cogs/Configuration/Views/connectionrolesview.py index 1ed6d084..ece77c4b 100644 --- a/Cogs/Configuration/Views/connectionrolesview.py +++ b/Cogs/Configuration/Views/connectionrolesview.py @@ -48,5 +48,8 @@ async def refreshembed(interaction): modulemsg = 'False' embed = discord.Embed(title="<:Role:1162074735803387944> Connection Roles Module", description=f"**Enabled:** {modulemsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", color=discord.Color.dark_embed()) embed.set_thumbnail(url=interaction.guild.icon) - embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) \ No newline at end of file + embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") \ No newline at end of file diff --git a/Cogs/Configuration/Views/feedbackview.py b/Cogs/Configuration/Views/feedbackview.py index 863971ba..160f0adb 100644 --- a/Cogs/Configuration/Views/feedbackview.py +++ b/Cogs/Configuration/Views/feedbackview.py @@ -106,5 +106,8 @@ async def refreshembed(interaction): embed.add_field(name="<:settings:1207368347931516928> Staff Feedback Configuration", value=f"<:replytop:1207366581735129118>**Enabled:** {modulemsg}\n<:replybottom:1207366623913316363>**Feedback Channel:** {feedbackchannelmsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", inline=False) embed.set_thumbnail(url=interaction.guild.icon) embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") diff --git a/Cogs/Configuration/Views/forumsview.py b/Cogs/Configuration/Views/forumsview.py index e48ad98b..caf66734 100644 --- a/Cogs/Configuration/Views/forumsview.py +++ b/Cogs/Configuration/Views/forumsview.py @@ -60,5 +60,8 @@ async def refreshembed(interaction): modulemsg = f"{moduleddata['Forums']}" embed = discord.Embed(title="<:forum:1162134180218556497> Forum Utilites", description=f"**Enabled:** {modulemsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", color=discord.Color.dark_embed()) embed.set_thumbnail(url=interaction.guild.icon) - embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) \ No newline at end of file + embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") \ No newline at end of file diff --git a/Cogs/Configuration/Views/infractionsview.py b/Cogs/Configuration/Views/infractionsview.py index 91398429..661adb8f 100644 --- a/Cogs/Configuration/Views/infractionsview.py +++ b/Cogs/Configuration/Views/infractionsview.py @@ -213,5 +213,7 @@ async def refreshembed(self, interaction): embed.add_field(name="<:settings:1207368347931516928> Infractions Configuration", value=f"<:replytop:1207366581735129118>**Enabled:** {modulemsg}\n<:replymiddle:1207366662916014100>**Infraction Channel:** {infchannelmsg}\n<:replybottom:1207366623913316363>**Infraction Types [{infractiontypescount}/15]** {infractiontypess}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", inline=False) embed.set_thumbnail(url=interaction.guild.icon) embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - - await interaction.message.edit(embed=embed) \ No newline at end of file + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") \ No newline at end of file diff --git a/Cogs/Configuration/Views/loaview.py b/Cogs/Configuration/Views/loaview.py index 5784ce95..f10d2c6c 100644 --- a/Cogs/Configuration/Views/loaview.py +++ b/Cogs/Configuration/Views/loaview.py @@ -152,6 +152,11 @@ async def refreshembed(interaction): embed = discord.Embed(title="<:LOA:1164969910238203995> LOA Module", color=discord.Color.dark_embed()) embed.add_field(name="<:settings:1207368347931516928> LOA Configuration", value=f"<:replytop:1207366581735129118>**Enabled:** {modulemsg}\n<:replymiddle:1207366662916014100>**LOA Channel:** {loachannelmsg}\n<:replybottom:1207366623913316363>**LOA Role:** {loarolemsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", inline=False) embed.set_thumbnail(url=interaction.guild.icon) - embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) + embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") + + \ No newline at end of file diff --git a/Cogs/Configuration/Views/modmailview.py b/Cogs/Configuration/Views/modmailview.py index 0675672b..d22c48dc 100644 --- a/Cogs/Configuration/Views/modmailview.py +++ b/Cogs/Configuration/Views/modmailview.py @@ -170,6 +170,9 @@ async def refreshembed(interaction): embed = discord.Embed(title="<:messagereceived:1201999712593383444> Modmail", color=discord.Color.dark_embed()) embed.add_field(name="<:settings:1207368347931516928> Modmail Configuration", value=f"<:replytop:1207366581735129118>**Enabled:** {modulemsg}\n<:replymiddle:1207366662916014100>**Modmail Category:** {modmailcategorys}\n<:replymiddle:1207366662916014100>**Modmail Pings:** {modmailroles}\n<:replybottom:1207366623913316363>**Transcript Channel:** {transcriptschannels}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)") embed.set_thumbnail(url=interaction.guild.icon) - embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) + embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") \ No newline at end of file diff --git a/Cogs/Configuration/Views/partnershipsview.py b/Cogs/Configuration/Views/partnershipsview.py index 297835a5..924974ca 100644 --- a/Cogs/Configuration/Views/partnershipsview.py +++ b/Cogs/Configuration/Views/partnershipsview.py @@ -105,4 +105,7 @@ async def refreshembed(interaction): embed.set_thumbnail(url=interaction.guild.icon) embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) \ No newline at end of file + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") \ No newline at end of file diff --git a/Cogs/Configuration/Views/promotionsview.py b/Cogs/Configuration/Views/promotionsview.py index cce16893..23d004ff 100644 --- a/Cogs/Configuration/Views/promotionsview.py +++ b/Cogs/Configuration/Views/promotionsview.py @@ -112,4 +112,7 @@ async def refreshembed(interaction): embed.add_field(name="<:settings:1207368347931516928> Promotions Configuration", value=f"<:replytop:1207366581735129118>**Enabled:** {modulemsg}\n<:replybottom:1207366623913316363>**Promotion Channel:** {promochannelmsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", inline=False) embed.set_thumbnail(url=interaction.guild.icon) embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) \ No newline at end of file + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") \ No newline at end of file diff --git a/Cogs/Configuration/Views/quotaview.py b/Cogs/Configuration/Views/quotaview.py index 75253377..9723dd33 100644 --- a/Cogs/Configuration/Views/quotaview.py +++ b/Cogs/Configuration/Views/quotaview.py @@ -130,6 +130,8 @@ async def refreshembed(interaction): embed = discord.Embed(title="<:Messages:1148610048151523339> Message Quota Module", color=discord.Color.dark_embed()) embed.add_field(name="<:settings:1207368347931516928> Message Quota Configuration", value=f"<:replytop:1207366581735129118>**Enabled:** {modulemsg}\n<:replybottom:1207366623913316363>**Quota:** {messagecountmsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", inline=False) embed.set_thumbnail(url=interaction.guild.icon) - embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) - \ No newline at end of file + embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") \ No newline at end of file diff --git a/Cogs/Configuration/Views/reportview.py b/Cogs/Configuration/Views/reportview.py index 112c03fd..6f164e26 100644 --- a/Cogs/Configuration/Views/reportview.py +++ b/Cogs/Configuration/Views/reportview.py @@ -149,4 +149,7 @@ async def refreshembed(interaction): embed.add_field(name="<:settings:1207368347931516928> Reports Configuration", value=f"<:replytop:1207366581735129118>**Enabled:** {modulemsg}\n<:replymiddle:1207366662916014100>**Reports Channel:** {partnershipchannelmsg}\n<:replybottom:1207366623913316363>**Reports Moderator Role:** {reprolemsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", inline=False) embed.set_thumbnail(url=interaction.guild.icon) embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) \ No newline at end of file + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") \ No newline at end of file diff --git a/Cogs/Configuration/Views/staffpanel.py b/Cogs/Configuration/Views/staffpanel.py index 77dbd097..da4970e0 100644 --- a/Cogs/Configuration/Views/staffpanel.py +++ b/Cogs/Configuration/Views/staffpanel.py @@ -460,4 +460,8 @@ async def refreshembed(interaction): embed = discord.Embed(title="<:staffdb:1206253848298127370> Staff Database & Panel", description=f"**Enabled:** {modulemsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", color=discord.Color.dark_embed()) embed.set_thumbnail(url=interaction.guild.icon) embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) \ No newline at end of file + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") + \ No newline at end of file diff --git a/Cogs/Configuration/Views/suggestionview.py b/Cogs/Configuration/Views/suggestionview.py index b37e78d6..30d6cfe6 100644 --- a/Cogs/Configuration/Views/suggestionview.py +++ b/Cogs/Configuration/Views/suggestionview.py @@ -106,4 +106,7 @@ async def refreshembed(interaction): embed.add_field(name="<:settings:1207368347931516928> Suggestions Configuration", value=f"<:replytop:1207366581735129118>**Enabled:** {modulemsg}\n<:replybottom:1207366623913316363>**Suggestion Channel:** {suggestionchannelmsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", inline=False) embed.set_thumbnail(url=interaction.guild.icon) embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) \ No newline at end of file + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") \ No newline at end of file diff --git a/Cogs/Configuration/Views/suspensionsview.py b/Cogs/Configuration/Views/suspensionsview.py index 9b5cb741..90dafa7a 100644 --- a/Cogs/Configuration/Views/suspensionsview.py +++ b/Cogs/Configuration/Views/suspensionsview.py @@ -61,5 +61,8 @@ async def refreshembed(interaction): embed = discord.Embed(title="<:Suspensions:1167093139845165229> Suspension Module", color=discord.Color.dark_embed()) embed.add_field(name="<:settings:1207368347931516928> Suspension Configuration", value=f"<:replytop:1207366581735129118>**Enabled:** {modulemsg}\n<:replybottom:1207366623913316363>**Suspension Channel:** Infraction Channel\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", inline=False) embed.set_thumbnail(url=interaction.guild.icon) - embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) \ No newline at end of file + embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") \ No newline at end of file diff --git a/Cogs/Configuration/Views/tagsview.py b/Cogs/Configuration/Views/tagsview.py index b87c6466..ab3a037b 100644 --- a/Cogs/Configuration/Views/tagsview.py +++ b/Cogs/Configuration/Views/tagsview.py @@ -60,5 +60,8 @@ async def refreshembed(interaction): modulemsg = f"{moduleddata['Tags']}" embed = discord.Embed(title="<:tag:1162134250414415922> Tags Module", description=f"**Enabled:** {modulemsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", color=discord.Color.dark_embed()) embed.set_thumbnail(url=interaction.guild.icon) - embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) - await interaction.message.edit(embed=embed) \ No newline at end of file + embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) + try: + await interaction.message.edit(embed=embed) + except discord.Forbidden: + print("Couldn't edit module due to missing permissions.") \ No newline at end of file diff --git a/Cogs/Modules/infractions.py b/Cogs/Modules/infractions.py index a783fe9c..b65a392e 100644 --- a/Cogs/Modules/infractions.py +++ b/Cogs/Modules/infractions.py @@ -234,7 +234,8 @@ async def infract(self, ctx, staff: discord.Member, action, reason: str, notes: if consent_data['infractionalert'] == "Enabled": try: await staff.send(f"<:SmallArrow:1140288951861649418> From **{ctx.guild.name}**", embed=embed) - except discord.Forbidden: + except: + print(f"Couldn't send infraction alert to {staff.display_name} in {ctx.guild.name}") pass else: pass diff --git a/Cogs/Modules/promotions.py b/Cogs/Modules/promotions.py index 260bab5e..06cce375 100644 --- a/Cogs/Modules/promotions.py +++ b/Cogs/Modules/promotions.py @@ -133,7 +133,12 @@ async def promote(self, ctx, staff: discord.Member, new: discord.Role, reason: s await ctx.send(f"{no} **{ctx.author.display_name},** I don't have permission to view that channel.") return if consent_data['PromotionAlerts'] == "Enabled": - await staff.send(f"🎉 You were promoted **@{ctx.guild.name}!**", embed=embed) + try: + await staff.send(f"🎉 You were promoted **@{ctx.guild.name}!**", embed=embed) + except: + print(f"{staff.display_name} has DMs disabled") + pass + else: pass else: diff --git a/Cogs/Modules/stafffeedback.py b/Cogs/Modules/stafffeedback.py index 10023af8..b299742c 100644 --- a/Cogs/Modules/stafffeedback.py +++ b/Cogs/Modules/stafffeedback.py @@ -82,8 +82,7 @@ async def feedback2(self, ctx, staff: discord.Member, rating: Literal['1/10', '2 if staff == ctx.author: await ctx.send(f"{no} **{ctx.author.display_name}**, you cannot rate yourself.") return - staff_role_data = await scollection.find_one({'guild_id': ctx.guild.id}) - staff_role_id = staff_role_data['staffrole'] + has_staff_role = await self.staffcheck(ctx, staff) diff --git a/Cogs/Modules/suspension.py b/Cogs/Modules/suspension.py index 62f2c672..fe3ff9bd 100644 --- a/Cogs/Modules/suspension.py +++ b/Cogs/Modules/suspension.py @@ -226,7 +226,7 @@ async def check_suspensions(self): await user.send( f"{tick} Your suspension in **@{guild.name}** has ended." ) - except discord.Forbidden: + except: print(f"Failed to send message to {user.name} in {guild.name}") continue @@ -302,7 +302,8 @@ async def callback(self, interaction: discord.Interaction): try: await self.user.send(f"<:SmallArrow:1140288951861649418> From **{interaction.guild.name}**", embed=embed, view=None) - except discord.Forbidden: + except: + print('Failed to send suspension message to user') pass @@ -380,7 +381,8 @@ async def No(self, interaction: discord.Interaction, button: discord.ui.Button): await interaction.response.edit_message(content=f"{tick} **{interaction.user.display_name}**, I've suspended **@{self.user.display_name}**", view=None, embed=None) try: await self.user.send(f"<:SmallArrow:1140288951861649418> From **{interaction.guild.name}**", embed=embed, view=None) - except discord.Forbidden: + except: + print('Failed to send suspension message to user') pass else: await interaction.response.edit_message(content=f"{no} {interaction.user.display_name}, I don't have permission to view this channel.", view=None, embed=None) @@ -428,16 +430,22 @@ async def SuspensionVoid(self, interaction: discord.Interaction, button: discord await member.add_roles(*roles_to_return) await interaction.edit_original_response(content=f"{tick} Suspension has been voided. Roles have been restored.", view=None, embed=None) await suspensions.delete_one({'guild_id': interaction.guild.id, 'staff': self.user.id}) - await member.send(f"<:bin:1160543529542635520> Your suspension has been voided **@{interaction.guild.name}**") + except discord.Forbidden: await interaction.edit_original_response(content=f"{no} Failed to restore roles due to insufficient permissions.", ephemeral=True) - + return + try: + await member.send(f"<:bin:1160543529542635520> Your suspension has been voided **@{interaction.guild.name}**") + except discord.Forbidden: + print('Failed to send suspension message to user') + pass else: member = interaction.guild.get_member(self.user.id) await suspensions.delete_one({'guild_id': interaction.guild.id, 'staff': self.user.id}) await interaction.response.edit_message(content=f"{tick} Suspension has been voided.", embed=None, view=None) try: await member.send(f"<:bin:1160543529542635520> Your suspension has been voided **@{interaction.guild.name}**") + print('Failed to send suspension message to user') except discord.Forbidden: pass else: