Use new send to admins method in infractions
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
bf7d4ba23f
commit
7a70bd37e7
|
@ -22,11 +22,12 @@ from database import (
|
||||||
GuildSettings,
|
GuildSettings,
|
||||||
Infractions as InfractionsModel,
|
Infractions as InfractionsModel,
|
||||||
)
|
)
|
||||||
|
from heimdallr.Heimdallr import HeimdallrClient
|
||||||
|
|
||||||
|
|
||||||
class Infractions(Extension):
|
class Infractions(Extension):
|
||||||
def __init__(self, client):
|
def __init__(self, client):
|
||||||
self.client: Client = client
|
self.client: HeimdallrClient = client
|
||||||
|
|
||||||
@slash_command(
|
@slash_command(
|
||||||
name="infractions", description="View your infractions", dm_permission=False
|
name="infractions", description="View your infractions", dm_permission=False
|
||||||
|
@ -218,31 +219,31 @@ class Infractions(Extension):
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
warning_msg = None
|
warning_msg = None
|
||||||
|
|
||||||
|
failed_to_dm_user = not silent and warning_msg is None
|
||||||
|
|
||||||
|
if failed_to_dm_user:
|
||||||
|
await ctx.send(
|
||||||
|
f"{user.mention} has received an infraction, but I couldn't DM them.",
|
||||||
|
ephemeral=True,
|
||||||
|
)
|
||||||
|
else:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
f'Warned {user.display_name} ({user.username}#{user.discriminator}, {user.id}) for "{reason}" with severity {weight}', # pylint: disable=line-too-long
|
f'Warned {user.display_name} ({user.username}#{user.discriminator}, {user.id}) for "{reason}" with severity {weight}', # pylint: disable=line-too-long
|
||||||
ephemeral=True,
|
ephemeral=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await self.client.send_message_to_admins(
|
||||||
guild_settings: Optional[GuildSettings] = GuildSettings.get_or_none(GuildSettings.guild_id == int(ctx.guild_id))
|
guild=ctx.guild,
|
||||||
if guild_settings is not None:
|
embed=Embed(
|
||||||
if guild_settings.admin_channel is not None:
|
|
||||||
admin_channel = await self.client.fetch_channel(int(guild_settings.admin_channel))
|
|
||||||
if admin_channel is not None:
|
|
||||||
await admin_channel.send(embed=Embed(
|
|
||||||
title=f"Warned {user.display_name} ({user.username}#{user.discriminator}, {user.id})",
|
title=f"Warned {user.display_name} ({user.username}#{user.discriminator}, {user.id})",
|
||||||
description=f"{reason}",
|
description=f"{reason}",
|
||||||
color=infraction_colour(0x0000FF),
|
color=infraction_colour(0x0000FF),
|
||||||
fields=[
|
fields=[
|
||||||
EmbedField("**Warned by**",
|
EmbedField("**Warned by**",
|
||||||
f"{ctx.author.display_name} ({ctx.author.username}#{ctx.author.discriminator})")
|
f"{ctx.author.display_name} ({ctx.author.username}#{ctx.author.discriminator})"
|
||||||
|
)
|
||||||
],
|
],
|
||||||
))
|
)
|
||||||
|
|
||||||
if not silent and warning_msg is None:
|
|
||||||
await ctx.send(
|
|
||||||
f"{user.mention} has been warned, but I couldn't DM them.",
|
|
||||||
ephemeral=True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@slash_command(
|
@slash_command(
|
||||||
|
|
Loading…
Reference in New Issue