Add modlog for on_slash_command, closes #34
This commit is contained in:
parent
ccad1220cb
commit
59e925c8e5
2 changed files with 33 additions and 1 deletions
|
@ -221,7 +221,7 @@ async def unwarn():
|
||||||
if warn["time"] + timedelta(hours=warn["duration"]) < datetime.now():
|
if warn["time"] + timedelta(hours=warn["duration"]) < datetime.now():
|
||||||
updates.append(
|
updates.append(
|
||||||
pymongo.UpdateOne(
|
pymongo.UpdateOne(
|
||||||
{{"_id": warn["_id"]}, {"$set": {"active": False}}}
|
{"_id": warn["_id"]}, {"$set": {"active": False}}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if updates:
|
if updates:
|
||||||
|
|
|
@ -3,8 +3,10 @@ from datetime import datetime, timedelta
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import pymongo
|
import pymongo
|
||||||
|
from discord import DMChannel
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.utils import find
|
from discord.utils import find
|
||||||
|
from discord_slash import SlashContext
|
||||||
|
|
||||||
import jarvis
|
import jarvis
|
||||||
from jarvis.config import get_config
|
from jarvis.config import get_config
|
||||||
|
@ -413,6 +415,36 @@ class ModlogCog(commands.Cog):
|
||||||
)
|
)
|
||||||
await channel.send(embed=embed)
|
await channel.send(embed=embed)
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
|
async def on_slash_command(self, ctx: SlashContext):
|
||||||
|
if not isinstance(ctx.channel, DMChannel):
|
||||||
|
modlog = self.db.jarvis.settings.find_one(
|
||||||
|
{"guild": ctx.guild.id, "setting": "modlog"}
|
||||||
|
)
|
||||||
|
if modlog:
|
||||||
|
channel = ctx.guild.get_channel(modlog["value"])
|
||||||
|
fields = [
|
||||||
|
Field("Command", ctx.name),
|
||||||
|
Field("Args", ctx.args, False),
|
||||||
|
]
|
||||||
|
if ctx.subcommand_name:
|
||||||
|
fields.insert(1, Field("Subcommand", ctx.subcommand_name))
|
||||||
|
embed = build_embed(
|
||||||
|
title="Command Invoked",
|
||||||
|
description=f"{ctx.author.mention} invoked a command",
|
||||||
|
fields=fields,
|
||||||
|
color="#fc9e3f",
|
||||||
|
)
|
||||||
|
embed.set_author(
|
||||||
|
name=ctx.author.name,
|
||||||
|
icon_url=ctx.author.avatar_url,
|
||||||
|
)
|
||||||
|
embed.set_footer(
|
||||||
|
text=f"{ctx.author.name}#{ctx.author.discriminator}"
|
||||||
|
+ f" | {ctx.author.id}"
|
||||||
|
)
|
||||||
|
await channel.send(embed=embed)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(ModlogCog(bot))
|
bot.add_cog(ModlogCog(bot))
|
||||||
|
|
Loading…
Add table
Reference in a new issue