12
12
from core .thread import Thread
13
13
from .utils import async_tasks
14
14
15
+ # Remove view perms from this role while pining, so only on-duty mods get the ping.
16
+ MOD_TEAM_ROLE_ID = 267629731250176001
15
17
log = getLogger (__name__ )
16
18
17
19
@@ -40,6 +42,7 @@ class PingManager(commands.Cog):
40
42
def __init__ (self , bot : ModmailBot ):
41
43
self .bot = bot
42
44
45
+ self .mod_team_role : discord .Role = None
43
46
self .config : t .Optional [PingConfig ] = None
44
47
self .ping_tasks : list [PingTask ] = None
45
48
self .db = bot .api .get_plugin_partition (self )
@@ -52,6 +55,8 @@ async def init_plugin(self) -> None:
52
55
db_config = db_config or {}
53
56
self .config = PingConfig (** db_config )
54
57
58
+ self .mod_team_role = self .bot .guild .get_role (MOD_TEAM_ROLE_ID )
59
+
55
60
db_ping_tasks = await self .db .find_one ({"_id" : "ping-delay-tasks" })
56
61
db_ping_tasks = db_ping_tasks or {}
57
62
self .ping_tasks = [PingTask (** task ) for task in db_ping_tasks .get ("ping_tasks" , [])]
@@ -198,9 +203,13 @@ async def maybe_ping_later(self, ping_task: PingTask) -> None:
198
203
if not (channel := self .bot .get_channel (ping_task .channel_id )):
199
204
log .info ("Channel closed before we could ping." )
200
205
else :
206
+ channel : discord .TextChannel
201
207
try :
202
208
if await self .should_ping (channel ):
209
+ # Remove overwrites for off-duty mods, ping, then add back.
210
+ await channel .set_permissions (self .mod_team_role , overwrite = None )
203
211
await channel .send (self .config .ping_string )
212
+ await channel .edit (sync_permissions = True )
204
213
except discord .NotFound :
205
214
# Fail silently if the channel gets deleted during processing.
206
215
pass
0 commit comments