1
1
import arrow
2
+ import ics
2
3
import nextcord
4
+ from nextcord import ScheduledEventEntityType
3
5
4
6
from .calendar import get_next_meeting
5
7
from .config import CORE_DEVS_CHANNEL_ID , NOTES_LINK
6
- from .database import add_notification_for_date , get_notification_for_date
8
+ from .database import (
9
+ add_notification_for_date ,
10
+ add_scheduled_event_for_date ,
11
+ get_notification_for_date ,
12
+ get_scheduled_event_for_date ,
13
+ )
7
14
from .date_utils import add_localized_times_to_embed
8
15
9
16
17
+ async def add_schedule_event (next_meeting : ics .Event , guild : nextcord .Guild ):
18
+ scheduled_event = get_scheduled_event_for_date (next_meeting .begin .isoformat ())
19
+
20
+ if not scheduled_event :
21
+ event_channel = guild .get_channel (928750531906789480 )
22
+ assert isinstance (event_channel , nextcord .channel .VoiceChannel )
23
+
24
+ event = await guild .create_scheduled_event (
25
+ name = "Strawberry Monthly Meeting 🍓" ,
26
+ channel = event_channel ,
27
+ start_time = next_meeting .begin .datetime ,
28
+ entity_type = ScheduledEventEntityType .voice ,
29
+ )
30
+
31
+ add_scheduled_event_for_date (next_meeting .begin .isoformat (), event .id )
32
+
33
+
10
34
async def find_next_event_and_notify_core_team (client : nextcord .Client ):
11
35
next_meeting = get_next_meeting ()
12
36
@@ -21,12 +45,12 @@ async def find_next_event_and_notify_core_team(client: nextcord.Client):
21
45
event_date = next_meeting .begin .isoformat ()
22
46
notification = get_notification_for_date (event_date , "core_devs" )
23
47
24
- if not notification :
25
- channel = client .get_channel (CORE_DEVS_CHANNEL_ID )
26
-
27
- assert isinstance (channel , nextcord .channel .TextChannel )
48
+ channel = client .get_channel (CORE_DEVS_CHANNEL_ID )
49
+ assert isinstance (channel , nextcord .channel .TextChannel )
28
50
51
+ if not notification :
29
52
embed = nextcord .Embed (color = 5814783 )
53
+
30
54
add_localized_times_to_embed (embed , next_meeting .begin )
31
55
32
56
message = await channel .send (
@@ -39,3 +63,5 @@ async def find_next_event_and_notify_core_team(client: nextcord.Client):
39
63
await message .add_reaction ("✅" )
40
64
41
65
add_notification_for_date (event_date , message .id , "core_devs" )
66
+
67
+ await add_schedule_event (next_meeting , channel .guild )
0 commit comments