Skip to content

Commit

Permalink
Merge pull request #21 from realstealthninja/main
Browse files Browse the repository at this point in the history
fix: unmessagable user banned
  • Loading branch information
CaedenPH authored Feb 18, 2024
2 parents cde4b28 + 3172073 commit e174b10
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions cogs/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ async def _purge(self, ctx: Context, amount=80):
async def ban(
self, ctx: Context, member: disnake.Member, *, reason="No reason provided"
):
await member.send("You have been banned: " + reason)
try:
await member.send("You have been banned: " + reason)
except HTTPException:
await ctx.send("Could message user")
await member.ban(reason=reason)
embed = disnake.Embed(
title="Banned",
Expand All @@ -131,7 +134,10 @@ async def unban(self, ctx: Context, user_id: int, *, reason="No reason provided"
)
embed.add_field(name="Reason:", value=reason)
await ctx.reply(embed=embed)
await user.send("You have been unbanned")
try:
await user.send(f"You have been unbanned from {ctx.guild.name}")
except HTTPException:
await ctx.send("Could message user")

@has_permissions(manage_roles=True)
@commands.command(aliases=["add", "+role", "add_role"])
Expand Down Expand Up @@ -220,7 +226,10 @@ async def server_prefix(self, ctx: Context, *, prefix=None):
async def kick(
self, ctx: Context, member: disnake.Member, *, reason="No reason provided"
):
await member.send("You have been kicked: " + reason)
try:
await member.send("You have been kicked: " + reason)
except HTTPException:
await ctx.send("Could message user")
await member.kick(reason=reason)
embed = disnake.Embed(
title="Kicked",
Expand Down Expand Up @@ -259,9 +268,12 @@ async def permreactmute(self, ctx: Context, member: disnake.Member, *, reason=No
embed.add_field(name="Reason:", value=reason, inline=False)
await ctx.reply(embed=embed)
await member.add_roles(mutedRole, reason=reason)
await member.send(
f"You have been reaction muted from: {guild.name} Reason: {reason}"
)
try:
await member.send(
f"You have been reaction muted from: {guild.name} Reason: {reason}"
)
except HTTPException:
await ctx.send("Could message user")

@commands.command(description="Indefinitely mutes the member from sending messages")
@has_permissions(manage_messages=True)
Expand All @@ -288,7 +300,10 @@ async def permmute(self, ctx: Context, member: disnake.Member, *, reason=None):
embed.add_field(name="Reason:", value=reason, inline=False)
await ctx.reply(embed=embed)
await member.add_roles(mutedRole, reason=reason)
await member.send(f" you have been muted from: {guild.name} Reason: {reason}")
try:
await member.send(f" you have been muted from: {guild.name} Reason: {reason}")
except HTTPException:
await ctx.send("Could message user")

@commands.command(
aliases=["unrmute", "runmute"], description="Unreactmutes `<member>`"
Expand Down Expand Up @@ -316,9 +331,12 @@ async def unreactmute(self, ctx: Context, member: disnake.Member, *, reason=None
embed.add_field(name="Reason:", value=reason, inline=False)
await ctx.reply(embed=embed)
await member.remove_roles(Reactmuted, reason=reason)
await member.send(
f"You have been reaction muted from: {guild.name} Reason: {reason}"
)
try:
await member.send(
f"You have been reaction muted from: {guild.name} Reason: {reason}"
)
except HTTPException:
await ctx.send("Could message user")

@commands.command(aliases=["unmut"], description="Unmutes `<member>`")
@has_permissions(manage_messages=True)
Expand All @@ -343,9 +361,12 @@ async def unmute(self, ctx: Context, member: disnake.Member, *, reason=None):
embed.add_field(name="Reason:", value=reason, inline=False)
await ctx.reply(embed=embed)
await member.remove_roles(Reactmuted, reason=reason)
await member.send(
f"You have been reaction muted from: {guild.name} Reason: {reason}"
)
try:
await member.send(
f"You have been reaction muted from: {guild.name} Reason: {reason}"
)
except HTTPException:
await ctx.send("Could message user")

@commands.command(
aliases=["tempmute"],
Expand Down

0 comments on commit e174b10

Please sign in to comment.