Skip to content

Commit f841f2e

Browse files
committed
cleaned up warn
1 parent 9b4710e commit f841f2e

File tree

1 file changed

+18
-31
lines changed

1 file changed

+18
-31
lines changed

chiya/cogs/warn.py

+18-31
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import time
1+
import arrow
22

33
import discord
44
from discord import app_commands
55
from discord.ext import commands
66

7-
from chiya import database
87
from chiya.config import config
8+
from chiya.database import ModLog
99
from chiya.utils import embeds
1010
from chiya.utils.helpers import log_embed_to_channel
1111

@@ -43,51 +43,38 @@ async def warn(self, ctx: discord.Interaction, member: discord.Member | discord.
4343
mod_embed = embeds.make_embed(
4444
ctx=ctx,
4545
author=True,
46-
title=f"Warning member: {member.name}",
47-
description=f"{member.mention} was warned by {ctx.user.mention} for: {reason}",
48-
thumbnail_url="https://i.imgur.com/4jeFA3h.png",
46+
title="Warned member",
47+
description=f"{member.mention} was warned by {ctx.user.mention}",
48+
thumbnail_url="https://files.catbox.moe/xbwoe8.png",
4949
color=discord.Color.gold(),
50+
fields=[
51+
{"name": "Reason:", "value": reason, "inline": False},
52+
],
5053
)
5154

5255
try:
5356
user_embed = embeds.make_embed(
5457
author=False,
5558
title="Uh-oh, you've received a warning!",
5659
description="If you believe this was a mistake, contact staff.",
57-
image_url="https://i.imgur.com/rVf0mlG.gif",
60+
image_url="https://files.catbox.moe/2mscuu.gif",
5861
color=discord.Color.blurple(),
5962
fields=[
60-
{
61-
"name": "Server:",
62-
"value": f"[{ctx.guild.name}]({await ctx.guild.vanity_invite()})",
63-
"inline": True,
64-
},
63+
{"name": "Server:", "value": ctx.guild.name, "inline": True},
6564
{"name": "Reason:", "value": reason, "inline": False},
6665
],
6766
)
6867
await member.send(embed=user_embed)
6968
except (discord.Forbidden, discord.HTTPException):
70-
mod_embed.add_field(
71-
name="Notice:",
72-
value=(
73-
f"Unable to message {member.mention} about this action. "
74-
"This can be caused by the user not being in the server, "
75-
"having DMs disabled, or having the bot blocked."
76-
),
77-
)
69+
mod_embed.set_footer(text="⚠️ Unable to message user about this action.")
7870

79-
db = database.Database().get()
80-
db["mod_logs"].insert(
81-
dict(
82-
user_id=member.id,
83-
mod_id=ctx.user.id,
84-
timestamp=int(time.time()),
85-
reason=reason,
86-
type="warn",
87-
)
88-
)
89-
db.commit()
90-
db.close()
71+
ModLog(
72+
user_id=member.id,
73+
mod_id=ctx.user.id,
74+
timestamp=arrow.utcnow().int_timestamp,
75+
reason=reason,
76+
type="warn",
77+
).save()
9178

9279
await ctx.followup.send(embed=mod_embed)
9380
await log_embed_to_channel(ctx=ctx, embed=mod_embed)

0 commit comments

Comments
 (0)