Skip to content

Commit f6e5ed8

Browse files
committed
refactor: replace Path with importlib.resources for loading emojis.json
1 parent d8c9f0c commit f6e5ed8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

discord/partial_emoji.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,20 @@
2525

2626
from __future__ import annotations
2727

28+
import importlib.resources
2829
import json
2930
import re
30-
from pathlib import Path
3131
from typing import TYPE_CHECKING, Any, TypedDict, TypeVar
3232

3333
from . import utils
3434
from .asset import Asset, AssetMixin
3535
from .errors import InvalidArgument
3636

37-
EMOJIS_MAP_PATH = Path(__file__).parent / "emojis.json"
38-
39-
with EMOJIS_MAP_PATH.open("r", encoding="utf-8") as f:
37+
with (
38+
importlib.resources.files(__package__)
39+
.joinpath("emojis.json")
40+
.open(encoding="utf-8") as f
41+
):
4042
EMOJIS_MAP = json.load(f)
4143

4244
__all__ = ("PartialEmoji",)

0 commit comments

Comments
 (0)