Skip to content

Commit

Permalink
Restructured modlogconfig as well. Fixes FRCDiscord#369.
Browse files Browse the repository at this point in the history
  • Loading branch information
BCurbs committed Aug 23, 2022
1 parent feb8cd8 commit 5062d5f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dozer/cogs/actionlogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ async def on_member_ban(self, guild: discord.Guild, user: discord.User):
@group(invoke_without_command=True)
@has_permissions(administrator=True)
async def messagelogconfig(self, ctx: DozerContext):
"""Set or show the modlog channel for a server"""
"""Set or show the messagelog channel for a server"""
config = await GuildMessageLog.get_by(guild_id=ctx.guild.id)
if len(config) != 0:
embed = discord.Embed(title=f"Messagelog Configuration for {ctx.guild.name}")
Expand Down
37 changes: 31 additions & 6 deletions dozer/cogs/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,10 +801,28 @@ async def purgenm(self, ctx: DozerContext):

"""=== Configuration commands ==="""

@command()
@group(invoke_without_command=True)
@has_permissions(administrator=True)
async def modlogconfig(self, ctx: DozerContext, channel_mentions: discord.TextChannel):
"""Set the modlog channel for a server by passing the channel id"""
async def modlogconfig(self, ctx: DozerContext):
"""Set or show the modlog channel for a server"""
config = await GuildModLog.get_by(guild_id=ctx.guild.id)
if len(config) != 0:
embed = discord.Embed(title=f"Modlog Configuration for {ctx.guild.name}")
embed.add_field(name='Channel:', value=f'<#{config[0].modlog_channel}>')
embed.set_footer(text='Triggered by ' + ctx.author.display_name)
await ctx.send(embed=embed)
else:
await ctx.send(f"Modlog is not configured. You can configure it with `{ctx.prefix}modlogconfig set [channel]`")

modlogconfig.example_usage = """
`{prefix}modlogconfig` - Shows the current modlog configuration.
`{prefix}modlogconfig set #join-leave-logs` - set a channel named #join-leave-logs to log joins/leaves.
`{prefix}modlogconfig disable` - Disables the modlog.
"""

@modlogconfig.command(name='set')
async def modlog_set(self, ctx: DozerContext, channel_mentions: discord.TextChannel):
"""Sets the modlog to a channel. """
config = await GuildModLog.get_by(guild_id=ctx.guild.id)
if len(config) != 0:
config = config[0]
Expand All @@ -815,9 +833,16 @@ async def modlogconfig(self, ctx: DozerContext, channel_mentions: discord.TextCh
await config.update_or_add()
await ctx.send(ctx.message.author.mention + ', modlog settings configured!')

modlogconfig.example_usage = """
`{prefix}modlogconfig #join-leave-logs` - set a channel named #join-leave-logs to log joins/leaves
"""
@modlogconfig.command(name='disable')
@has_permissions(administrator=True)
async def modlog_disable(self, ctx: DozerContext):
"""Disables modlog for the guild. """
config = await GuildModLog.get_by(guild_id=ctx.guild.id)
if len(config) != 0:
await GuildModLog.delete(guild_id=ctx.guild.id)
await ctx.send(f'{ctx.message.author.mention} messagelog disabled. ')
else:
await ctx.send(f'{ctx.message.author.mention} messagelog is not active')

@command()
@has_permissions(manage_guild=True)
Expand Down

0 comments on commit 5062d5f

Please sign in to comment.