Skip to content

Commit 49a78c1

Browse files
committed
Migrate to nextcord
1 parent 14e82a4 commit 49a78c1

File tree

6 files changed

+215
-94
lines changed

6 files changed

+215
-94
lines changed

poetry.lock

Lines changed: 200 additions & 79 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ license = "MIT"
1111

1212
[tool.poetry.dependencies]
1313
python = "^3.10"
14-
"discord.py" = "^1.7.3"
1514
aiocron = "^1.8"
1615
ics = "^0.7"
1716
httpx = "^0.21.3"
1817
python-dotenv = "^0.19.2"
18+
nextcord = "^2.0.0-alpha.6"
1919

2020
[tool.poetry.dev-dependencies]
2121
black = "^21.12b0"

src/bot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22

3-
import discord
3+
import nextcord
44

55
from src.database import (
66
add_notification_for_date,
@@ -13,7 +13,7 @@
1313
from .meeting import find_next_event_and_notify_core_team
1414

1515

16-
class StrawberryDiscordClient(discord.Client):
16+
class StrawberryDiscordClient(nextcord.Client):
1717
def __init__(self, *args, **kwargs):
1818
super().__init__(*args, **kwargs)
1919

@@ -42,9 +42,9 @@ async def on_raw_reaction_add(self, reaction):
4242

4343
channel = client.get_channel(GENERAL_CHANNEL_ID)
4444

45-
assert channel
45+
assert isinstance(channel, nextcord.channel.TextChannel)
4646

47-
embed = discord.Embed(color=5814783)
47+
embed = nextcord.Embed(color=5814783)
4848
add_localized_times_to_embed(embed, notification.date)
4949

5050
message = await channel.send(

src/database.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
class Notification(NamedTuple):
2525
date: arrow.Arrow
26-
discord_message_id: str
26+
discord_message_id: int
2727

2828

2929
def get_notification_for_date(date: str, notification_type: str) -> Notification | None:
@@ -38,13 +38,13 @@ def get_notification_for_date(date: str, notification_type: str) -> Notification
3838
if row:
3939
date, message_id = row
4040

41-
return Notification(date=arrow.get(date), discord_message_id=message_id)
41+
return Notification(date=arrow.get(date), discord_message_id=int(message_id))
4242

4343
return None
4444

4545

4646
def add_notification_for_date(
47-
date: str, discord_message_id: str, notification_type: str
47+
date: str, discord_message_id: int, notification_type: str
4848
) -> None:
4949
cursor.execute(
5050
"INSERT INTO meeting_notifications "
@@ -69,6 +69,6 @@ def get_notification_for_discord_message_id(
6969
if row:
7070
date, message_id = row
7171

72-
return Notification(date=arrow.get(date), discord_message_id=message_id)
72+
return Notification(date=arrow.get(date), discord_message_id=int(message_id))
7373

7474
return None

src/date_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import arrow
2-
import discord
2+
import nextcord
33

44
LOCATIONS = {
55
"🇬🇧 London": "Europe/London",
@@ -8,7 +8,7 @@
88
}
99

1010

11-
def add_localized_times_to_embed(embed: discord.Embed, date: arrow.Arrow) -> None:
11+
def add_localized_times_to_embed(embed: nextcord.Embed, date: arrow.Arrow) -> None:
1212
for location, timezone in LOCATIONS.items():
1313
embed.add_field(
1414
name=location,

src/meeting.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import arrow
2-
import discord
2+
import nextcord
33

44
from .calendar import get_next_meeting
55
from .config import CORE_DEVS_CHANNEL_ID, NOTES_LINK
66
from .database import add_notification_for_date, get_notification_for_date
77
from .date_utils import add_localized_times_to_embed
88

99

10-
async def find_next_event_and_notify_core_team(client: discord.Client):
10+
async def find_next_event_and_notify_core_team(client: nextcord.Client):
1111
next_meeting = get_next_meeting()
1212

1313
if not next_meeting:
@@ -24,9 +24,9 @@ async def find_next_event_and_notify_core_team(client: discord.Client):
2424
if not notification:
2525
channel = client.get_channel(CORE_DEVS_CHANNEL_ID)
2626

27-
assert channel
27+
assert isinstance(channel, nextcord.channel.TextChannel)
2828

29-
embed = discord.Embed(color=5814783)
29+
embed = nextcord.Embed(color=5814783)
3030
add_localized_times_to_embed(embed, next_meeting.begin)
3131

3232
message = await channel.send(

0 commit comments

Comments
 (0)