fix(moderation): made dm_users and ignore_other_bots guild-dependent
All checks were successful
Pylint / Pylint (push) Successful in 1m13s
All checks were successful
Pylint / Pylint (push) Successful in 1m13s
This commit is contained in:
parent
25ac0a3c0c
commit
90e0a4b153
1 changed files with 15 additions and 13 deletions
|
@ -21,7 +21,9 @@ class Moderation(commands.Cog):
|
||||||
mysql_address= " ",
|
mysql_address= " ",
|
||||||
mysql_database = " ",
|
mysql_database = " ",
|
||||||
mysql_username = " ",
|
mysql_username = " ",
|
||||||
mysql_password = " ",
|
mysql_password = " "
|
||||||
|
)
|
||||||
|
self.config.register_guild(
|
||||||
ignore_other_bots = True,
|
ignore_other_bots = True,
|
||||||
dm_users = True
|
dm_users = True
|
||||||
)
|
)
|
||||||
|
@ -69,7 +71,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 await self.config.guild(entry.guild.id).ignore_other_bots() is True:
|
||||||
if entry.user.bot or entry.target.bot:
|
if entry.user.bot or entry.target.bot:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@ -223,7 +225,7 @@ class Moderation(commands.Cog):
|
||||||
"""Add a note to a user."""
|
"""Add a note to a user."""
|
||||||
await interaction.response.send_message(content=f"{target.mention} has recieved a note!\n**Reason** - `{reason}`")
|
await interaction.response.send_message(content=f"{target.mention} has recieved a note!\n**Reason** - `{reason}`")
|
||||||
if silent is None:
|
if silent is None:
|
||||||
silent = not await self.config.dm_users()
|
silent = not await self.config.guild(interaction.guild.id).dm_users()
|
||||||
if silent is False:
|
if silent is False:
|
||||||
try:
|
try:
|
||||||
embed = await self.embed_factory('message', interaction.guild, reason, 'note', await interaction.original_response())
|
embed = await self.embed_factory('message', interaction.guild, reason, 'note', await interaction.original_response())
|
||||||
|
@ -237,7 +239,7 @@ class Moderation(commands.Cog):
|
||||||
"""Warn a user."""
|
"""Warn a user."""
|
||||||
await interaction.response.send_message(content=f"{target.mention} has been warned!\n**Reason** - `{reason}`")
|
await interaction.response.send_message(content=f"{target.mention} has been warned!\n**Reason** - `{reason}`")
|
||||||
if silent is None:
|
if silent is None:
|
||||||
silent = not await self.config.dm_users()
|
silent = not await self.config.guild(interaction.guild.id).dm_users()
|
||||||
if silent is False:
|
if silent is False:
|
||||||
try:
|
try:
|
||||||
embed = await self.embed_factory('message', interaction.guild, reason, 'warned', await interaction.original_response())
|
embed = await self.embed_factory('message', interaction.guild, reason, 'warned', await interaction.original_response())
|
||||||
|
@ -263,7 +265,7 @@ class Moderation(commands.Cog):
|
||||||
await target.timeout(parsed_time, reason=f"Muted by {interaction.user.id} for: {reason}")
|
await target.timeout(parsed_time, reason=f"Muted by {interaction.user.id} for: {reason}")
|
||||||
await interaction.response.send_message(content=f"{target.mention} has been muted for {humanize.precisedelta(parsed_time)}!\n**Reason** - `{reason}`")
|
await interaction.response.send_message(content=f"{target.mention} has been muted for {humanize.precisedelta(parsed_time)}!\n**Reason** - `{reason}`")
|
||||||
if silent is None:
|
if silent is None:
|
||||||
silent = not await self.config.dm_users()
|
silent = not await self.config.guild(interaction.guild.id).dm_users()
|
||||||
if silent is False:
|
if silent is False:
|
||||||
try:
|
try:
|
||||||
embed = await self.embed_factory('message', interaction.guild, reason, 'muted', await interaction.original_response(), parsed_time)
|
embed = await self.embed_factory('message', interaction.guild, reason, 'muted', await interaction.original_response(), parsed_time)
|
||||||
|
@ -285,7 +287,7 @@ class Moderation(commands.Cog):
|
||||||
reason = "No reason given."
|
reason = "No reason given."
|
||||||
await interaction.response.send_message(content=f"{target.mention} has been unmuted!\n**Reason** - `{reason}`")
|
await interaction.response.send_message(content=f"{target.mention} has been unmuted!\n**Reason** - `{reason}`")
|
||||||
if silent is None:
|
if silent is None:
|
||||||
silent = not await self.config.dm_users()
|
silent = not await self.config.guild(interaction.guild.id).dm_users()
|
||||||
if silent is False:
|
if silent is False:
|
||||||
try:
|
try:
|
||||||
embed = await self.embed_factory('message', interaction.guild, reason, 'unmuted', await interaction.original_response())
|
embed = await self.embed_factory('message', interaction.guild, reason, 'unmuted', await interaction.original_response())
|
||||||
|
@ -299,7 +301,7 @@ class Moderation(commands.Cog):
|
||||||
"""Kick a user."""
|
"""Kick a user."""
|
||||||
await interaction.response.send_message(content=f"{target.mention} has been kicked!\n**Reason** - `{reason}`")
|
await interaction.response.send_message(content=f"{target.mention} has been kicked!\n**Reason** - `{reason}`")
|
||||||
if silent is None:
|
if silent is None:
|
||||||
silent = not await self.config.dm_users()
|
silent = not await self.config.guild(interaction.guild.id).dm_users()
|
||||||
if silent is False:
|
if silent is False:
|
||||||
try:
|
try:
|
||||||
embed = await self.embed_factory('message', interaction.guild, reason, 'kicked', await interaction.original_response())
|
embed = await self.embed_factory('message', interaction.guild, reason, 'kicked', await interaction.original_response())
|
||||||
|
@ -343,7 +345,7 @@ class Moderation(commands.Cog):
|
||||||
else:
|
else:
|
||||||
await interaction.response.send_message(content=f"{target.mention} has been banned!\n**Reason** - `{reason}`")
|
await interaction.response.send_message(content=f"{target.mention} has been banned!\n**Reason** - `{reason}`")
|
||||||
if silent is None:
|
if silent is None:
|
||||||
silent = not await self.config.dm_users()
|
silent = not await self.config.guild(interaction.guild.id).dm_users()
|
||||||
if silent is False:
|
if silent is False:
|
||||||
try:
|
try:
|
||||||
embed = await self.embed_factory('message', interaction.guild, reason, 'banned', await interaction.original_response())
|
embed = await self.embed_factory('message', interaction.guild, reason, 'banned', await interaction.original_response())
|
||||||
|
@ -368,7 +370,7 @@ class Moderation(commands.Cog):
|
||||||
reason = "No reason given."
|
reason = "No reason given."
|
||||||
await interaction.response.send_message(content=f"{target.mention} has been unbanned!\n**Reason** - `{reason}`")
|
await interaction.response.send_message(content=f"{target.mention} has been unbanned!\n**Reason** - `{reason}`")
|
||||||
if silent is None:
|
if silent is None:
|
||||||
silent = not await self.config.dm_users()
|
silent = not await self.config.guild(interaction.guild.id).dm_users()
|
||||||
if silent is False:
|
if silent is False:
|
||||||
try:
|
try:
|
||||||
embed = await self.embed_factory('message', interaction.guild, reason, 'unbanned', await interaction.original_response())
|
embed = await self.embed_factory('message', interaction.guild, reason, 'unbanned', await interaction.original_response())
|
||||||
|
@ -505,8 +507,8 @@ class Moderation(commands.Cog):
|
||||||
@checks.admin()
|
@checks.admin()
|
||||||
async def moderationset_ignorebots(self, ctx: commands.Context):
|
async def moderationset_ignorebots(self, ctx: commands.Context):
|
||||||
"""Toggle if the cog should ignore other bots' moderations."""
|
"""Toggle if the cog should ignore other bots' moderations."""
|
||||||
await self.config.ignore_other_bots.set(not await self.config.ignore_other_bots())
|
await self.config.guild(ctx.guild.id).ignore_other_bots.set(not await self.config.guild(ctx.guild.id).ignore_other_bots())
|
||||||
await ctx.send(f"Ignore bots setting set to {await self.config.ignore_other_bots()}")
|
await ctx.send(f"Ignore bots setting set to {await self.config.guild(ctx.guild.id).ignore_other_bots()}")
|
||||||
|
|
||||||
@moderationset.command(name="dm")
|
@moderationset.command(name="dm")
|
||||||
@checks.admin()
|
@checks.admin()
|
||||||
|
@ -514,8 +516,8 @@ class Moderation(commands.Cog):
|
||||||
"""Toggle automatically messaging moderated users.
|
"""Toggle automatically messaging moderated users.
|
||||||
|
|
||||||
This option can be overridden by specifying the `silent` argument in any moderation command."""
|
This option can be overridden by specifying the `silent` argument in any moderation command."""
|
||||||
await self.config.dm_users.set(not await self.config.dm_users())
|
await self.config.guild(ctx.guild.id).dm_users.set(not await self.config.guild(ctx.guild.id).dm_users())
|
||||||
await ctx.send(f"DM users setting set to {await self.config.dm_users()}")
|
await ctx.send(f"DM users setting set to {await self.config.guild(ctx.guild.id).dm_users()}")
|
||||||
|
|
||||||
@moderationset.command(name="mysql")
|
@moderationset.command(name="mysql")
|
||||||
@checks.is_owner()
|
@checks.is_owner()
|
||||||
|
|
Loading…
Reference in a new issue