Skip to content

Commit 2a9c16f

Browse files
committed
chore: split into 2 weekly messages in diff channels
1 parent 033a0f1 commit 2a9c16f

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

.example.env.dev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
TOKEN= # your dev bot's token
33
REACTION_MESSAGE_ID= # the message id of the message users need to react to to get roles in the dev server
44
REACTION_ROLE_ID= # the role id of the role that a user will get for reacting to the message id will the given reaction
5+
PUBLIC_REMINDER_CHANNEL_ID= # the id of the channel the public landing reminder will be sent in
6+
PUBLIC_REMINDER_START= # the unix timestamp of when the public landing reminders start, and continue from on a weekly basis
57
VOUCH_REMINDER_CHANNEL_ID= # the id of the channel the message reminding users about vouching should be sent to
68
VOUCH_REMINDER_START= # the unix timestamp of when the vouch reminders start, and continue from on a weekly basis
79
SERVER_ACCESS_ROLE_ID = # the id of the role that users get for server access

.example.env.prod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
TOKEN= # your prod bot's token
33
REACTION_MESSAGE_ID= # the message id of the message users need to react to to get roles in the prod server
44
REACTION_ROLE_ID= # the role id of the role that a user will get for reacting to the message id will the given reaction
5+
PUBLIC_REMINDER_CHANNEL_ID= # the id of the channel the public landing reminder will be sent in
6+
PUBLIC_REMINDER_START= # the unix timestamp of when the public landing reminders start, and continue from on a weekly basis
57
VOUCH_REMINDER_CHANNEL_ID= # the id of the channel the message reminding users about vouching should be sent to
68
VOUCH_REMINDER_START= # the unix timestamp of when the vouch reminders start, and continue from on a weekly basis
79
SERVER_ACCESS_ROLE_ID = # the id of the role that users get for server access

mask_bloc_bot.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
TOKEN = os.getenv("TOKEN")
55
REACTION_MESSAGE_ID = os.getenv("REACTION_MESSAGE_ID")
66
REACTION_ROLE_ID = os.getenv("REACTION_ROLE_ID")
7+
PUBLIC_REMINDER_CHANNEL_ID = os.getenv("PUBLIC_REMINDER_CHANNEL_ID")
8+
PUBLIC_REMINDER_START = os.getenv("PUBLIC_REMINDER_START")
79
VOUCH_REMINDER_CHANNEL_ID = os.getenv("VOUCH_REMINDER_CHANNEL_ID")
810
VOUCH_REMINDER_START = os.getenv("VOUCH_REMINDER_START")
911
SERVER_ACCESS_ROLE_ID = os.getenv("SERVER_ACCESS_ROLE_ID")
@@ -20,12 +22,13 @@
2022
:star: Take your time exploring our server. Starting with the channels under the Main folder 📂 might be good.
2123
📌 Look through pinned posts for important info."""
2224

23-
WEEKLY_MESSAGE = """
25+
PUBLIC_REMINDER_MESSAGE = """
2426
Hi everyone! If you're waiting to get access to the full server, please don't say who invited you or post an intro yet.
2527
26-
To get access, you need to react to the server guidelines post https://discord.com/channels/1073227549867520101/1200982159826108456/1200983315730145443, and the person who invited you needs to vouch for you in a private channel. One of the mods will then give you access manually. Thanks!
28+
To get access, you need to react to the server guidelines post https://discord.com/channels/1073227549867520101/1200982159826108456/1200983315730145443, and the person who invited you needs to vouch for you in a priv"""
2729

28-
Also - reminder to please vouch for folks in the welcome and introductions channel!"""
30+
VOUCH_REMINDER_MESSAGE = """
31+
Reminder to please vouch for folks in the welcome and introductions channel!"""
2932

3033
logger = logging.getLogger('discord')
3134

@@ -66,10 +69,17 @@ async def on_error(event, *args, **kwargs):
6669
# TASKS
6770

6871
@tasks.loop(seconds=SECONDS_IN_HOUR) # will run again after this time elapses *and* the previous execution has completed
69-
async def weekly_message():
72+
async def public_weekly_message():
73+
seconds_until_next_reminder = SECONDS_IN_WEEK - ((int(time.time()) - int(PUBLIC_REMINDER_START)) % SECONDS_IN_WEEK)
74+
if seconds_until_next_reminder <= SECONDS_IN_HOUR:
75+
await client.get_channel(int(PUBLIC_REMINDER_CHANNEL_ID)).send(PUBLIC_REMINDER_MESSAGE)
76+
logger.info("Sent public reminder message")
77+
78+
@tasks.loop(seconds=SECONDS_IN_HOUR) # will run again after this time elapses *and* the previous execution has completed
79+
async def vouch_weekly_message():
7080
seconds_until_next_reminder = SECONDS_IN_WEEK - ((int(time.time()) - int(VOUCH_REMINDER_START)) % SECONDS_IN_WEEK)
7181
if seconds_until_next_reminder <= SECONDS_IN_HOUR:
72-
await client.get_channel(int(VOUCH_REMINDER_CHANNEL_ID)).send(WEEKLY_MESSAGE)
73-
logger.info("Sent reminder message")
82+
await client.get_channel(int(VOUCH_REMINDER_CHANNEL_ID)).send(VOUCH_REMINDER_MESSAGE)
83+
logger.info("Sent vouch reminder message")
7484

7585
client.run(TOKEN)

0 commit comments

Comments
 (0)