Skip to content

Commit 2325b26

Browse files
authored
chore: remove /confirm and references to Unconfirmed role (#26)
* chore: Remove `/confirm`, unconfirmed role, and welcome channel * Add default invite prefix variable * Add unconfirmed cleanup batch kick command To help facilitate in migrating unconfirmed pre-onboarding users to use the new onboarding feature once they join. * Reimplement to assume unconfirmed role has been removed * Add doc comments * Add long term Discord rate limit global constant * Add bot permission check * Add condition to ignore bots * Add basic interval ratelimiting * Include sending message to kicked user Provides information to the kicked user as to why they were kicked and how to rejoin. The kicked user is not gauranteed to get the DM; they have the option to reject all DMs from specific servers. * chore: Refactor implementation to be inline Uses existing Confirm view to simpify code flow. * feat: Add kick count to progress and final report * fix: Remove use of `asyncio.sleep` in favor of using `asyncio.wait_for` * fix: Use embed for DM message Keeps consistency in formatting with other notices that Pi-Bot sends to the user.
1 parent 966ca39 commit 2325b26

6 files changed

Lines changed: 360 additions & 79 deletions

File tree

bot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ async def setup_hook(self) -> None:
201201
"src.discord.staff.censor",
202202
"src.discord.staff.tags",
203203
"src.discord.staff.events",
204+
"src.discord.staff.usercleanup",
204205
"src.discord.embed",
205206
"src.discord.membercommands",
206207
"src.discord.devtools",

src/discord/censor.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
CATEGORY_STAFF,
1919
CHANNEL_SUPPORT,
2020
DISCORD_INVITE_ENDINGS,
21-
ROLE_UC,
2221
)
2322

2423
if TYPE_CHECKING:
@@ -241,11 +240,6 @@ async def on_message_edit(self, before: discord.Message, after: discord.Message)
241240

242241
@commands.Cog.listener()
243242
async def on_member_join(self, member: discord.Member):
244-
# Give new user confirmed role
245-
unconfirmed_role = discord.utils.get(member.guild.roles, name=ROLE_UC)
246-
assert isinstance(unconfirmed_role, discord.Role)
247-
await member.add_roles(unconfirmed_role)
248-
249243
# Check to see if user's name is innapropriate
250244
name = member.name
251245
if await self.censor_needed(name):

src/discord/globals.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
##############
99
# CONSTANTS
1010
##############
11+
DISCORD_DEFAULT_INVITE_ENDING = "scioly"
1112
DISCORD_INVITE_ENDINGS = [
1213
"9Z5zKtV",
1314
"C9PGV6h",
@@ -16,7 +17,7 @@
1617
"gh3aXbq",
1718
"skGQXd4",
1819
"RnkqUbK",
19-
"scioly",
20+
DISCORD_DEFAULT_INVITE_ENDING,
2021
]
2122

2223
# Roles
@@ -30,7 +31,6 @@
3031
ROLE_AT = "All Invitationals"
3132
ROLE_GAMES = "Games"
3233
ROLE_MR = "Member"
33-
ROLE_UC = "Unconfirmed"
3434
ROLE_DIV_A = "Division A"
3535
ROLE_DIV_B = "Division B"
3636
ROLE_DIV_C = "Division C"
@@ -116,6 +116,7 @@
116116
DISCORD_AUTOCOMPLETE_MAX_ENTRIES = 25
117117
# The maximum number of options that can be passed into a discord.ui.Select
118118
DISCORD_SELECT_MAX_OPTIONS = 20
119+
DISCORD_LONG_TERM_RATE_LIMIT = 1 # 5 requests / 5 seconds, so might as well keep 1 request / 1 second for long running tasks
119120

120121
##############
121122
# VARIABLES

src/discord/logger.py

Lines changed: 82 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Logs actions that happened on the Scioly.org Discord server to specific information
33
buckets, such as a Discord channel or database log.
44
"""
5+
56
from __future__ import annotations
67

78
import logging
@@ -19,7 +20,6 @@
1920
CHANNEL_EDITEDM,
2021
CHANNEL_LEAVE,
2122
CHANNEL_LOUNGE,
22-
ROLE_UC,
2323
)
2424

2525
if TYPE_CHECKING:
@@ -54,9 +54,11 @@ async def send_to_dm_log(self, message: discord.Message):
5454
# Create an embed containing the direct message info and send it to the log channel
5555
message_embed = discord.Embed(
5656
title=":speech_balloon: Incoming Direct Message to Pi-Bot",
57-
description=message.content
58-
if len(message.content) > 0
59-
else "This message contained no content.",
57+
description=(
58+
message.content
59+
if len(message.content) > 0
60+
else "This message contained no content."
61+
),
6062
color=discord.Color.brand_green(),
6163
)
6264
message_embed.add_field(
@@ -72,11 +74,13 @@ async def send_to_dm_log(self, message: discord.Message):
7274
)
7375
message_embed.add_field(
7476
name="Attachments",
75-
value=" | ".join(
76-
[f"**{a.filename}**: [Link]({a.url})" for a in message.attachments],
77-
)
78-
if len(message.attachments) > 0
79-
else "None",
77+
value=(
78+
" | ".join(
79+
[f"**{a.filename}**: [Link]({a.url})" for a in message.attachments],
80+
)
81+
if len(message.attachments) > 0
82+
else "None"
83+
),
8084
inline=True,
8185
)
8286
await dm_channel.send(embed=message_embed)
@@ -117,16 +121,9 @@ async def on_member_remove(self, member: discord.Member):
117121
member.guild.text_channels,
118122
name=CHANNEL_LEAVE,
119123
)
120-
unconfirmed_role = discord.utils.get(member.guild.roles, name=ROLE_UC)
121124
assert isinstance(leave_channel, discord.TextChannel)
122-
assert isinstance(unconfirmed_role, discord.Role)
123125

124-
if unconfirmed_role in member.roles:
125-
unconfirmed_statement = ":white_check_mark:"
126-
embed = discord.Embed(color=discord.Color.yellow())
127-
else:
128-
unconfirmed_statement = ":x:"
129-
embed = discord.Embed(color=discord.Color.brand_red())
126+
embed = discord.Embed(color=discord.Color.brand_red())
130127

131128
embed.title = "Member Leave"
132129

@@ -141,7 +138,6 @@ async def on_member_remove(self, member: discord.Member):
141138
)
142139

143140
embed.add_field(name="Joined At", value=joined_at)
144-
embed.add_field(name="Unconfirmed", value=unconfirmed_statement)
145141
await leave_channel.send(embed=embed)
146142

147143
@commands.Cog.listener()
@@ -382,35 +378,41 @@ async def log_edit_message_payload(self, payload):
382378
},
383379
{
384380
"name": "Attachments",
385-
"value": " | ".join(
386-
[
387-
f"**{a.filename}**: [Link]({a.url})"
388-
for a in message.attachments
389-
],
390-
)
391-
if len(message.attachments) > 0
392-
else "None",
381+
"value": (
382+
" | ".join(
383+
[
384+
f"**{a.filename}**: [Link]({a.url})"
385+
for a in message.attachments
386+
],
387+
)
388+
if len(message.attachments) > 0
389+
else "None"
390+
),
393391
"inline": "False",
394392
},
395393
{
396394
"name": "Past Content",
397-
"value": message.content[:1024]
398-
if len(message.content) > 0
399-
else "None",
395+
"value": (
396+
message.content[:1024] if len(message.content) > 0 else "None"
397+
),
400398
"inline": "False",
401399
},
402400
{
403401
"name": "New Content",
404-
"value": message_now.content[:1024]
405-
if len(message_now.content) > 0
406-
else "None",
402+
"value": (
403+
message_now.content[:1024]
404+
if len(message_now.content) > 0
405+
else "None"
406+
),
407407
"inline": "False",
408408
},
409409
{
410410
"name": "Embed",
411-
"value": "\n".join([str(e.to_dict()) for e in message.embeds])
412-
if len(message.embeds) > 0
413-
else "None",
411+
"value": (
412+
"\n".join([str(e.to_dict()) for e in message.embeds])
413+
if len(message.embeds) > 0
414+
else "None"
415+
),
414416
"inline": "False",
415417
},
416418
]
@@ -454,37 +456,43 @@ async def log_edit_message_payload(self, payload):
454456
},
455457
{
456458
"name": "Edited At",
457-
"value": discord.utils.format_dt(message_now.edited_at, "R")
458-
if message_now.edited_at is not None
459-
else "Never",
459+
"value": (
460+
discord.utils.format_dt(message_now.edited_at, "R")
461+
if message_now.edited_at is not None
462+
else "Never"
463+
),
460464
"inline": True,
461465
},
462466
{
463467
"name": "New Content",
464-
"value": message_now.content[:1024]
465-
if len(message_now.content) > 0
466-
else "None",
468+
"value": (
469+
message_now.content[:1024]
470+
if len(message_now.content) > 0
471+
else "None"
472+
),
467473
"inline": "False",
468474
},
469475
{
470476
"name": "Current Attachments",
471-
"value": " | ".join(
472-
[
473-
f"**{a.filename}**: [Link]({a.url})"
474-
for a in message_now.attachments
475-
],
476-
)
477-
if len(message_now.attachments) > 0
478-
else "None",
477+
"value": (
478+
" | ".join(
479+
[
480+
f"**{a.filename}**: [Link]({a.url})"
481+
for a in message_now.attachments
482+
],
483+
)
484+
if len(message_now.attachments) > 0
485+
else "None"
486+
),
479487
"inline": "False",
480488
},
481489
{
482490
"name": "Current Embed",
483-
"value": "\n".join([str(e.to_dict()) for e in message_now.embeds])[
484-
:1024
485-
]
486-
if len(message_now.embeds) > 0
487-
else "None",
491+
"value": (
492+
"\n".join([str(e.to_dict()) for e in message_now.embeds])[:1024]
493+
if len(message_now.embeds) > 0
494+
else "None"
495+
),
488496
"inline": "False",
489497
},
490498
]
@@ -551,30 +559,34 @@ async def log_delete_message_payload(self, payload):
551559
},
552560
{
553561
"name": "Attachments",
554-
"value": " | ".join(
555-
[
556-
f"**{a.filename}**: [Link]({a.url})"
557-
for a in message.attachments
558-
],
559-
)
560-
if len(message.attachments) > 0
561-
else "None",
562+
"value": (
563+
" | ".join(
564+
[
565+
f"**{a.filename}**: [Link]({a.url})"
566+
for a in message.attachments
567+
],
568+
)
569+
if len(message.attachments) > 0
570+
else "None"
571+
),
562572
"inline": "False",
563573
},
564574
{
565575
"name": "Content",
566-
"value": str(message.content)[:1024]
567-
if len(message.content) > 0
568-
else "None",
576+
"value": (
577+
str(message.content)[:1024]
578+
if len(message.content) > 0
579+
else "None"
580+
),
569581
"inline": "False",
570582
},
571583
{
572584
"name": "Embed",
573-
"value": "\n".join([str(e.to_dict()) for e in message.embeds])[
574-
:1024
575-
]
576-
if len(message.embeds) > 0
577-
else "None",
585+
"value": (
586+
"\n".join([str(e.to_dict()) for e in message.embeds])[:1024]
587+
if len(message.embeds) > 0
588+
else "None"
589+
),
578590
"inline": "False",
579591
},
580592
]

src/discord/membercommands.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Functionality for most member commands. These commands frequently help members manage
33
their state on the server, including allowing them to change their roles or subscriptions.
44
"""
5+
56
from __future__ import annotations
67

78
import datetime
@@ -22,6 +23,7 @@
2223
CATEGORY_STAFF,
2324
CHANNEL_INVITATIONALS,
2425
CHANNEL_UNSELFMUTE,
26+
DISCORD_DEFAULT_INVITE_ENDING,
2527
ROLE_LH,
2628
ROLE_MR,
2729
ROLE_SELFMUTE,
@@ -407,7 +409,9 @@ async def invite(self, interaction: discord.Interaction):
407409
Args:
408410
interaction (discord.Interaction): The interaction sent by Discord.
409411
"""
410-
await interaction.response.send_message("https://discord.gg/C9PGV6h")
412+
await interaction.response.send_message(
413+
f"https://discord.gg/{DISCORD_DEFAULT_INVITE_ENDING}",
414+
)
411415

412416
@app_commands.command(
413417
description="Returns a link to the Scioly.org forums.",

0 commit comments

Comments
 (0)