Skip to content

Commit f0ec514

Browse files
committed
[Mod] Add ban message, show user id.
1 parent 8a2c376 commit f0ec514

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

mod/kickban.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,24 @@ async def ban_user(
152152
toggle = await self.config.guild(guild).dm_on_kickban()
153153
if toggle:
154154
with contextlib.suppress(discord.HTTPException):
155+
ban_message = await self.config.guild(guild).ban_message()
155156
em = discord.Embed(
156157
title=bold(_("You have been banned from {guild}.").format(guild=guild)),
158+
description = ban_message or None,
157159
color=await self.bot.get_embed_color(user),
158160
)
159161
em.add_field(
160162
name=_("**Reason**"),
161163
value=reason if reason is not None else _("No reason was given."),
162-
inline=False,
164+
inline=True,
163165
)
166+
show_user_id = await self.config.guild(guild).show_user_id()
167+
if show_user_id:
168+
em.add_field(
169+
name=_("**User ID**"),
170+
value=user.id,
171+
inline=True,
172+
)
164173
await user.send(embed=em)
165174

166175
ban_type = "ban"

mod/mod.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class Mod(
5858
"reinvite_on_unban": False,
5959
"current_tempbans": [],
6060
"dm_on_kickban": False,
61+
"ban_message": None,
62+
"show_user_id": False,
6163
"default_days": 0,
6264
"default_tempban_duration": 60 * 60 * 24,
6365
"track_nicknames": True,

mod/settings.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ async def modset_showsettings(self, ctx: commands.Context):
4747
delete_delay = data["delete_delay"]
4848
reinvite_on_unban = data["reinvite_on_unban"]
4949
dm_on_kickban = data["dm_on_kickban"]
50+
ban_message = data["ban_message"]
51+
show_user_id = data["show_user_id"]
5052
default_days = data["default_days"]
5153
default_tempban_duration = data["default_tempban_duration"]
5254
if not track_all_names and track_nicknames:
@@ -93,6 +95,12 @@ async def modset_showsettings(self, ctx: commands.Context):
9395
msg += _("Send message to users on kick/ban: {yes_or_no}\n").format(
9496
yes_or_no=_("Yes") if dm_on_kickban else _("No")
9597
)
98+
msg += _("Ban Message: {ban_message}\n").format(
99+
ban_message=ban_message if ban_message else _("None")
100+
)
101+
msg += _("Show User ID: {yes_or_no}\n").format(
102+
yes_or_no=_("Yes") if show_user_id else _("No")
103+
)
96104
if default_days:
97105
msg += _("Default message history delete on ban: Previous {num_days} days\n").format(
98106
num_days=default_days
@@ -371,6 +379,44 @@ async def dm(self, ctx: commands.Context, enabled: bool = None):
371379
_("Bot will no longer attempt to send a DM to user before kick and ban.")
372380
)
373381

382+
@modset.command()
383+
@commands.guild_only()
384+
async def banmessage(self, ctx: commands.Context, *, message: str = None):
385+
"""Ban Message
386+
387+
Use it without message arg to clear
388+
"""
389+
guild = ctx.guild
390+
if message is None:
391+
await self.config.guild(guild).ban_message.set(None)
392+
await ctx.send(
393+
_("Ban message changed to default.")
394+
)
395+
return
396+
else:
397+
await self.config.guild(guild).ban_message.set(message)
398+
await ctx.send(_("Ban message set to `{}`").format(message))
399+
400+
@modset.command()
401+
@commands.guild_only()
402+
async def showid(self, ctx: commands.Context, enabled: bool = None):
403+
"""Toggle whether user id should be sent on ban message
404+
"""
405+
guild = ctx.guild
406+
if enabled is None:
407+
setting = await self.config.guild(guild).show_user_id()
408+
await ctx.send(
409+
_("Show user id on ban is currently set to: {setting}").format(setting=setting)
410+
)
411+
return
412+
await self.config.guild(guild).show_user_id.set(enabled)
413+
if enabled:
414+
await ctx.send(_("Bot will now send user id on ban."))
415+
else:
416+
await ctx.send(
417+
_("Bot will no longer send user id on ban.")
418+
)
419+
374420
@modset.command()
375421
@commands.guild_only()
376422
async def defaultdays(self, ctx: commands.Context, days: int = 0):

0 commit comments

Comments
 (0)