Skip to content

Commit

Permalink
[mod] 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
flaree committed Jul 22, 2024
1 parent 131c4b3 commit 54b8ecb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ You can contact me in the Red 3rd party server in #support_flare-cogs
| Highlight | 1.11.1 | <details><summary>Highlight certain words to be notified of if said in a certain channel.</summary></details> | flare(flare#0001) |
| JoinMessage | 0.1.0 | <details><summary>Send a message to a guilds general chat, system channel or first available channel.</summary></details> | flare (flare#0001) |
| Jsk | 0.0.2 | <details><summary>Jishaku ported to Red.</summary></details> | flare(flare#0001) |
| Mod | 1.2.0 | <details><summary>Mod with custom messages.</summary>Core mod with the inclusion of custom messages for banning, kicking and unbanning.</details> | flare(flare#0001) |
| Mod | 1.3.0 | <details><summary>Mod with custom messages.</summary>Core mod with the inclusion of custom messages for banning, kicking and unbanning.</details> | flare(flare#0001) |
| Covid | 0.0.3 | <details><summary>Grab the latest headlines, nationally or globally.</summary>Grab breaking headline around the world!</details> | flare(flare#0001) |
| Palette | 0.1.0 | <details><summary>Show colour palette of images, avatars etc.</summary>Show colour palette of images, avatars, emojis etc</details> | flare(flare#0001) and Kuro |
| PermChecker | 0.1.0 | <details><summary>This cog is a basic permission checker, used to check if a user/role/channel has a set permission.</summary></details> | flare(flare#0001) |
Expand Down
29 changes: 28 additions & 1 deletion mod/mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Mod(ModClass):

modset = ModClass.modset.copy()

__version__ = "1.2.0"
__version__ = "1.3.0"

def format_help_for_context(self, ctx: commands.Context):
pre_processed = super().format_help_for_context(ctx)
Expand All @@ -76,6 +76,7 @@ def __init__(self, bot: Red):
"ban_message": ban_message,
"tempban_message": tempban_message,
"unban_message": unban_message,
"require_reason": False,
}
)

Expand Down Expand Up @@ -184,6 +185,12 @@ async def modset_showmessages(self, ctx: commands.Context):
)
await ctx.send(box(msg))

@modset.command()
async def modset_require_reason(self, ctx: commands.Context, value: bool):
"""Set whether a reason is required for moderation actions."""
await self._config.guild(ctx.guild).require_reason.set(value)
await ctx.send(f"Reason requirement set to {value}")

kick = None

@commands.hybrid_command()
Expand All @@ -202,6 +209,10 @@ async def kick(self, ctx: commands.Context, member: discord.Member, *, reason: s
If a reason is specified, it will be the reason that shows up
in the audit log.
"""
require_reason = await self._config.guild(ctx.guild).require_reason()
if require_reason and reason is None:
await ctx.send("You must provide a reason for this action.")
return
author = ctx.author
guild = ctx.guild

Expand Down Expand Up @@ -316,6 +327,10 @@ async def tempban(
- `[p]tempban 428675506947227648 1d2h15m 5 Evil person`
This will ban the user with ID 428675506947227648 for 1 day 2 hours 15 minutes and will delete the last 5 days of their messages.
"""
require_reason = await self._config.guild(ctx.guild).require_reason()
if require_reason and reason is None:
await ctx.send("You must provide a reason for this action.")
return
guild = ctx.guild
author = ctx.author

Expand Down Expand Up @@ -426,6 +441,10 @@ async def tempban(
@checks.admin_or_permissions(ban_members=True)
async def softban(self, ctx: commands.Context, member: discord.Member, *, reason: str = None):
"""Kick a user and delete 1 day's worth of their messages."""
require_reason = await self._config.guild(ctx.guild).require_reason()
if require_reason and reason is None:
await ctx.send("You must provide a reason for this action.")
return
guild = ctx.guild
author = ctx.author

Expand Down Expand Up @@ -553,6 +572,10 @@ async def ban(
If days is not a number, it's treated as the first word of the reason.
Minimum 0 days, maximum 7. If not specified, the defaultdays setting will be used instead.
"""
require_reason = await self._config.guild(ctx.guild).require_reason()
if require_reason and reason is None:
await ctx.send("You must provide a reason for this action.")
return
guild = ctx.guild
if days is None:
days = await self.config.guild(guild).default_days()
Expand Down Expand Up @@ -727,6 +750,10 @@ async def unban(
1. Copy it from the mod log case (if one was created), or
2. enable developer mode, go to Bans in this server's settings, right-
click the user and select 'Copy ID'."""
require_reason = await self._config.guild(ctx.guild).require_reason()
if require_reason and reason is None:
await ctx.send("You must provide a reason for this action.")
return
guild = ctx.guild
author = ctx.author
audit_reason = get_audit_reason(ctx.author, reason, shorten=True)
Expand Down

0 comments on commit 54b8ecb

Please sign in to comment.