Skip to content

Commit 81754e6

Browse files
authored
Merge pull request #1844 from python-discord/new-appeals-process
Direct users to the appeals server when banned
2 parents 7346131 + 0231712 commit 81754e6

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

bot/exts/moderation/infraction/_utils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,18 @@
2727
# Type aliases
2828
Infraction = t.Dict[str, t.Union[str, int, bool]]
2929

30-
APPEAL_EMAIL = "[email protected]"
30+
APPEAL_SERVER_INVITE = "https://discord.gg/WXrCJxWBnm"
3131

3232
INFRACTION_TITLE = "Please review our rules"
33-
INFRACTION_APPEAL_EMAIL_FOOTER = f"To appeal this infraction, send an e-mail to {APPEAL_EMAIL}"
33+
INFRACTION_APPEAL_SERVER_FOOTER = f"\n\nTo appeal this infraction, join our [appeals server]({APPEAL_SERVER_INVITE})."
3434
INFRACTION_APPEAL_MODMAIL_FOOTER = (
35-
'If you would like to discuss or appeal this infraction, '
36-
'send a message to the ModMail bot'
35+
'\n\nIf you would like to discuss or appeal this infraction, '
36+
'send a message to the ModMail bot.'
3737
)
3838
INFRACTION_AUTHOR_NAME = "Infraction information"
3939

40+
LONGEST_EXTRAS = max(len(INFRACTION_APPEAL_SERVER_FOOTER), len(INFRACTION_APPEAL_MODMAIL_FOOTER))
41+
4042
INFRACTION_DESCRIPTION_TEMPLATE = (
4143
"**Type:** {type}\n"
4244
"**Expires:** {expires}\n"
@@ -170,8 +172,10 @@ async def notify_infraction(
170172
)
171173

172174
# For case when other fields than reason is too long and this reach limit, then force-shorten string
173-
if len(text) > 4096:
174-
text = f"{text[:4093]}..."
175+
if len(text) > 4096 - LONGEST_EXTRAS:
176+
text = f"{text[:4093-LONGEST_EXTRAS]}..."
177+
178+
text += INFRACTION_APPEAL_SERVER_FOOTER if infr_type.lower() == 'ban' else INFRACTION_APPEAL_MODMAIL_FOOTER
175179

176180
embed = discord.Embed(
177181
description=text,
@@ -182,10 +186,6 @@ async def notify_infraction(
182186
embed.title = INFRACTION_TITLE
183187
embed.url = RULES_URL
184188

185-
embed.set_footer(
186-
text=INFRACTION_APPEAL_EMAIL_FOOTER if infr_type == 'Ban' else INFRACTION_APPEAL_MODMAIL_FOOTER
187-
)
188-
189189
return await send_private_embed(user, embed)
190190

191191

tests/bot/exts/moderation/infraction/test_utils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ async def test_notify_infraction(self, send_private_embed_mock):
139139
type="Ban",
140140
expires="2020-02-26 09:20 (23 hours and 59 minutes)",
141141
reason="No reason provided."
142-
),
142+
) + utils.INFRACTION_APPEAL_SERVER_FOOTER,
143143
colour=Colours.soft_red,
144144
url=utils.RULES_URL
145145
).set_author(
146146
name=utils.INFRACTION_AUTHOR_NAME,
147147
url=utils.RULES_URL,
148148
icon_url=Icons.token_removed
149-
).set_footer(text=utils.INFRACTION_APPEAL_MODMAIL_FOOTER),
149+
),
150150
"send_result": True
151151
},
152152
{
@@ -157,14 +157,14 @@ async def test_notify_infraction(self, send_private_embed_mock):
157157
type="Warning",
158158
expires="N/A",
159159
reason="Test reason."
160-
),
160+
) + utils.INFRACTION_APPEAL_MODMAIL_FOOTER,
161161
colour=Colours.soft_red,
162162
url=utils.RULES_URL
163163
).set_author(
164164
name=utils.INFRACTION_AUTHOR_NAME,
165165
url=utils.RULES_URL,
166166
icon_url=Icons.token_removed
167-
).set_footer(text=utils.INFRACTION_APPEAL_MODMAIL_FOOTER),
167+
),
168168
"send_result": False
169169
},
170170
# Note that this test case asserts that the DM that *would* get sent to the user is formatted
@@ -177,14 +177,14 @@ async def test_notify_infraction(self, send_private_embed_mock):
177177
type="Note",
178178
expires="N/A",
179179
reason="No reason provided."
180-
),
180+
) + utils.INFRACTION_APPEAL_MODMAIL_FOOTER,
181181
colour=Colours.soft_red,
182182
url=utils.RULES_URL
183183
).set_author(
184184
name=utils.INFRACTION_AUTHOR_NAME,
185185
url=utils.RULES_URL,
186186
icon_url=Icons.defcon_denied
187-
).set_footer(text=utils.INFRACTION_APPEAL_MODMAIL_FOOTER),
187+
),
188188
"send_result": False
189189
},
190190
{
@@ -195,14 +195,14 @@ async def test_notify_infraction(self, send_private_embed_mock):
195195
type="Mute",
196196
expires="2020-02-26 09:20 (23 hours and 59 minutes)",
197197
reason="Test"
198-
),
198+
) + utils.INFRACTION_APPEAL_MODMAIL_FOOTER,
199199
colour=Colours.soft_red,
200200
url=utils.RULES_URL
201201
).set_author(
202202
name=utils.INFRACTION_AUTHOR_NAME,
203203
url=utils.RULES_URL,
204204
icon_url=Icons.defcon_denied
205-
).set_footer(text=utils.INFRACTION_APPEAL_MODMAIL_FOOTER),
205+
),
206206
"send_result": False
207207
},
208208
{
@@ -213,14 +213,14 @@ async def test_notify_infraction(self, send_private_embed_mock):
213213
type="Mute",
214214
expires="N/A",
215215
reason="foo bar" * 4000
216-
)[:4093] + "...",
216+
)[:4093-utils.LONGEST_EXTRAS] + "..." + utils.INFRACTION_APPEAL_MODMAIL_FOOTER,
217217
colour=Colours.soft_red,
218218
url=utils.RULES_URL
219219
).set_author(
220220
name=utils.INFRACTION_AUTHOR_NAME,
221221
url=utils.RULES_URL,
222222
icon_url=Icons.defcon_denied
223-
).set_footer(text=utils.INFRACTION_APPEAL_MODMAIL_FOOTER),
223+
),
224224
"send_result": True
225225
}
226226
]

0 commit comments

Comments
 (0)