Fix error on mute if user has role higher than bot
This commit is contained in:
parent
2a280b66b6
commit
d0a0e3a456
1 changed files with 11 additions and 4 deletions
|
@ -6,6 +6,7 @@ from datetime import datetime, timedelta, timezone
|
||||||
from dateparser import parse
|
from dateparser import parse
|
||||||
from dateparser_data.settings import default_parsers
|
from dateparser_data.settings import default_parsers
|
||||||
from dis_snek import InteractionContext, Permissions, Snake
|
from dis_snek import InteractionContext, Permissions, Snake
|
||||||
|
from dis_snek.client.errors import Forbidden
|
||||||
from dis_snek.models.discord.embed import EmbedField
|
from dis_snek.models.discord.embed import EmbedField
|
||||||
from dis_snek.models.discord.modal import InputText, Modal, TextStyles
|
from dis_snek.models.discord.modal import InputText, Modal, TextStyles
|
||||||
from dis_snek.models.discord.user import Member
|
from dis_snek.models.discord.user import Member
|
||||||
|
@ -125,8 +126,11 @@ class MuteCog(ModcaseCog):
|
||||||
f"`{old_until}` is in the past, which isn't allowed", ephemeral=True
|
f"`{old_until}` is in the past, which isn't allowed", ephemeral=True
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
embed = await self._apply_timeout(ctx, ctx.target, reason, until)
|
try:
|
||||||
await response.send(embed=embed)
|
embed = await self._apply_timeout(ctx, ctx.target, reason, until)
|
||||||
|
await response.send(embed=embed)
|
||||||
|
except Forbidden:
|
||||||
|
await response.send("Unable to mute this user", ephemeral=True)
|
||||||
|
|
||||||
@slash_command(name="mute", description="Mute a user")
|
@slash_command(name="mute", description="Mute a user")
|
||||||
@slash_option(name="user", description="User to mute", opt_type=OptionTypes.USER, required=True)
|
@slash_option(name="user", description="User to mute", opt_type=OptionTypes.USER, required=True)
|
||||||
|
@ -179,8 +183,11 @@ class MuteCog(ModcaseCog):
|
||||||
return
|
return
|
||||||
|
|
||||||
until = datetime.now(tz=timezone.utc) + timedelta(minutes=duration)
|
until = datetime.now(tz=timezone.utc) + timedelta(minutes=duration)
|
||||||
embed = await self._apply_timeout(ctx, user, reason, until)
|
try:
|
||||||
await ctx.send(embed=embed)
|
embed = await self._apply_timeout(ctx, user, reason, until)
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
except Forbidden:
|
||||||
|
await ctx.send("Unable to mute this user", ephemeral=True)
|
||||||
|
|
||||||
@slash_command(name="unmute", description="Unmute a user")
|
@slash_command(name="unmute", description="Unmute a user")
|
||||||
@slash_option(
|
@slash_option(
|
||||||
|
|
Loading…
Add table
Reference in a new issue