Compare commits
2 commits
854a1f14e5
...
9f1d864b31
Author | SHA1 | Date | |
---|---|---|---|
9f1d864b31 | |||
57f49d8e42 |
1 changed files with 24 additions and 4 deletions
|
@ -60,7 +60,8 @@ class Moderation(commands.Cog):
|
|||
@commands.Cog.listener('on_audit_log_entry_create')
|
||||
async def autologger(self, entry: discord.AuditLogEntry):
|
||||
"""This method automatically logs moderations done by users manually ("right clicks")."""
|
||||
if entry.user.bot or entry.target.bot and await self.config.ignore_other_bots() is True:
|
||||
if await self.config.ignore_other_bots() is True:
|
||||
if entry.user.bot or entry.target.bot:
|
||||
return
|
||||
duration = "NULL"
|
||||
if entry.reason:
|
||||
|
@ -79,9 +80,9 @@ class Moderation(commands.Cog):
|
|||
duration_datetime = timed_out_until_aware - datetime.now(tz=timezone.utc)
|
||||
minutes = round(duration_datetime.total_seconds() / 60)
|
||||
duration = timedelta(minutes=minutes)
|
||||
moderation_type = 'TIMEOUT'
|
||||
moderation_type = 'MUTE'
|
||||
else:
|
||||
moderation_type = 'UNTIMEOUT'
|
||||
moderation_type = 'UNMUTE'
|
||||
else:
|
||||
return
|
||||
await self.mysql_log(entry.guild.id, entry.user.id, moderation_type, entry.target.id, duration, reason)
|
||||
|
@ -171,6 +172,25 @@ class Moderation(commands.Cog):
|
|||
database.close()
|
||||
logging.debug("MySQL row inserted into %s_moderation!\n%s, %s, %s, %s, %s, %s, %s, %s, 0, NULL", guild_id, moderation_id, timestamp, moderation_type, target_id, author_id, duration, end_timestamp, reason)
|
||||
|
||||
@commands.hybrid_command(name="mute", aliases=['timeout'])
|
||||
@commands.mod_or_permissions(discord.Permissions.moderate_members)
|
||||
async def mute(self, ctx: commands.Context, target: discord.Member, duration: str, reason: str):
|
||||
"""Mute a user."""
|
||||
try:
|
||||
parsed_time = parse(sval=duration, as_timedelta=True, raise_exception=True)
|
||||
except ValueError:
|
||||
await ctx.message.reply(f"Please provide a valid duration!\nSee `{ctx.prefix}tdc`")
|
||||
return
|
||||
await target.timeout(parsed_time)
|
||||
response = await ctx.send(content=f"{target.mention} has been muted for {str(parsed_time)}!\n**Reason** - `{reason}`")
|
||||
try:
|
||||
embed = discord.Embed(title="Muted", description=f"You have been muted for `{str(parsed_time)}` in {ctx.guild.name}.", color=await self.bot.get_embed_color(None))
|
||||
embed.add_field(name='Reason', value=f"`{reason}`")
|
||||
await target.send(embed=embed)
|
||||
except discord.errors.HTTPException:
|
||||
await response.edit(content=f"{response.content}\n*Failed to send DM, user likely has the bot blocked.*")
|
||||
self.mysql_log(ctx.guild.id, ctx.author.id, 'MUTE', target.id, parsed_time, reason)
|
||||
|
||||
@commands.group(autohelp=True)
|
||||
@checks.admin()
|
||||
async def moderationset(self, ctx: commands.Context):
|
||||
|
|
Loading…
Reference in a new issue