Compare commits

..

No commits in common. "9f1d864b3135ea56a870bd053717ad83a14ca25a" and "854a1f14e5205bdff42e86ebb96ad28cc6a4e16f" have entirely different histories.

View file

@ -60,8 +60,7 @@ class Moderation(commands.Cog):
@commands.Cog.listener('on_audit_log_entry_create') @commands.Cog.listener('on_audit_log_entry_create')
async def autologger(self, entry: discord.AuditLogEntry): async def autologger(self, entry: discord.AuditLogEntry):
"""This method automatically logs moderations done by users manually ("right clicks").""" """This method automatically logs moderations done by users manually ("right clicks")."""
if await self.config.ignore_other_bots() is True: if entry.user.bot or entry.target.bot and await self.config.ignore_other_bots() is True:
if entry.user.bot or entry.target.bot:
return return
duration = "NULL" duration = "NULL"
if entry.reason: if entry.reason:
@ -80,9 +79,9 @@ class Moderation(commands.Cog):
duration_datetime = timed_out_until_aware - datetime.now(tz=timezone.utc) duration_datetime = timed_out_until_aware - datetime.now(tz=timezone.utc)
minutes = round(duration_datetime.total_seconds() / 60) minutes = round(duration_datetime.total_seconds() / 60)
duration = timedelta(minutes=minutes) duration = timedelta(minutes=minutes)
moderation_type = 'MUTE' moderation_type = 'TIMEOUT'
else: else:
moderation_type = 'UNMUTE' moderation_type = 'UNTIMEOUT'
else: else:
return return
await self.mysql_log(entry.guild.id, entry.user.id, moderation_type, entry.target.id, duration, reason) await self.mysql_log(entry.guild.id, entry.user.id, moderation_type, entry.target.id, duration, reason)
@ -172,25 +171,6 @@ class Moderation(commands.Cog):
database.close() 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) 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) @commands.group(autohelp=True)
@checks.admin() @checks.admin()
async def moderationset(self, ctx: commands.Context): async def moderationset(self, ctx: commands.Context):