|
1 |
| -import time |
| 1 | +import arrow |
2 | 2 |
|
3 | 3 | import discord
|
4 | 4 | from discord import app_commands
|
5 | 5 | from discord.ext import commands
|
6 | 6 |
|
7 |
| -from chiya import database |
8 | 7 | from chiya.config import config
|
| 8 | +from chiya.database import ModLog |
9 | 9 | from chiya.utils import embeds
|
10 | 10 | from chiya.utils.helpers import log_embed_to_channel
|
11 | 11 |
|
@@ -43,51 +43,38 @@ async def warn(self, ctx: discord.Interaction, member: discord.Member | discord.
|
43 | 43 | mod_embed = embeds.make_embed(
|
44 | 44 | ctx=ctx,
|
45 | 45 | 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", |
49 | 49 | color=discord.Color.gold(),
|
| 50 | + fields=[ |
| 51 | + {"name": "Reason:", "value": reason, "inline": False}, |
| 52 | + ], |
50 | 53 | )
|
51 | 54 |
|
52 | 55 | try:
|
53 | 56 | user_embed = embeds.make_embed(
|
54 | 57 | author=False,
|
55 | 58 | title="Uh-oh, you've received a warning!",
|
56 | 59 | 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", |
58 | 61 | color=discord.Color.blurple(),
|
59 | 62 | 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}, |
65 | 64 | {"name": "Reason:", "value": reason, "inline": False},
|
66 | 65 | ],
|
67 | 66 | )
|
68 | 67 | await member.send(embed=user_embed)
|
69 | 68 | 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.") |
78 | 70 |
|
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() |
91 | 78 |
|
92 | 79 | await ctx.followup.send(embed=mod_embed)
|
93 | 80 | await log_embed_to_channel(ctx=ctx, embed=mod_embed)
|
|
0 commit comments