Skip to content

Commit 682377f

Browse files
authored
feat: 🥅 Add error handling for missing emojis.json file in utils.py (#2889)
🥅 Add error handling for missing emojis.json file in utils.py
1 parent 76d930a commit 682377f

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

discord/utils.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import importlib.resources
3434
import itertools
3535
import json
36+
import logging
3637
import re
3738
import sys
3839
import types
@@ -100,14 +101,23 @@
100101
"filter_params",
101102
)
102103

104+
_log = logging.getLogger(__name__)
105+
103106
DISCORD_EPOCH = 1420070400000
104107

105-
with (
106-
importlib.resources.files(__package__)
107-
.joinpath("emojis.json")
108-
.open(encoding="utf-8") as f
109-
):
110-
EMOJIS_MAP = json.load(f)
108+
try:
109+
with (
110+
importlib.resources.files(__package__)
111+
.joinpath("emojis.json")
112+
.open(encoding="utf-8") as f
113+
):
114+
EMOJIS_MAP = json.load(f)
115+
except FileNotFoundError:
116+
_log.debug(
117+
"Couldn't find emojis.json. Is the package data missing? Discord emojis names will not work.",
118+
)
119+
EMOJIS_MAP = {}
120+
111121

112122
UNICODE_EMOJIS = set(EMOJIS_MAP.values())
113123

0 commit comments

Comments
 (0)