Move command to client
This commit is contained in:
parent
a72ede0644
commit
cbf6587dbf
1 changed files with 0 additions and 38 deletions
|
@ -1,38 +0,0 @@
|
||||||
"""J.A.R.V.I.S. ModlogCommandCog."""
|
|
||||||
from dis_snek import InteractionContext, Snake, listen
|
|
||||||
from dis_snek.models.discord.channel import DMChannel
|
|
||||||
from dis_snek.models.discord.embed import EmbedField
|
|
||||||
|
|
||||||
from jarvis.db.models import Setting
|
|
||||||
from jarvis.utils import build_embed
|
|
||||||
|
|
||||||
|
|
||||||
class ModlogCommandCog(object):
|
|
||||||
"""J.A.R.V.I.S. ModlogCommandCog."""
|
|
||||||
|
|
||||||
def __init__(self, bot: Snake):
|
|
||||||
self.bot = bot
|
|
||||||
self.bot.add_listener(self.on_command)
|
|
||||||
|
|
||||||
@listen()
|
|
||||||
async def on_command(self, ctx: InteractionContext) -> None:
|
|
||||||
"""Process on_slash_command events."""
|
|
||||||
if not isinstance(ctx.channel, DMChannel) and ctx.name not in ["pw"]:
|
|
||||||
modlog = Setting.objects(guild=ctx.guild.id, setting="modlog").first()
|
|
||||||
if modlog:
|
|
||||||
channel = await ctx.guild.get_channel(modlog.value)
|
|
||||||
args = " ".join(f"{k}:v" for k, v in ctx.kwargs.items())
|
|
||||||
fields = [
|
|
||||||
EmbedField(name="Command", value=f"{ctx.invoked_name} {args}", inline=False),
|
|
||||||
]
|
|
||||||
embed = build_embed(
|
|
||||||
title="Command Invoked",
|
|
||||||
description=f"{ctx.author.mention} invoked a command",
|
|
||||||
fields=fields,
|
|
||||||
color="#fc9e3f",
|
|
||||||
)
|
|
||||||
embed.set_author(name=ctx.author.username, icon_url=ctx.author.display_avatar.url)
|
|
||||||
embed.set_footer(
|
|
||||||
text=f"{ctx.author.username}#{ctx.author.discriminator} | {ctx.author.id}"
|
|
||||||
)
|
|
||||||
await channel.send(embed=embed)
|
|
Loading…
Add table
Reference in a new issue