From 19795ef927c98e30c7d4c48b1167d0ae63844a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=83=9C=E6=9C=88?= <277073121@qq.com> Date: Sun, 14 Apr 2024 15:51:20 +0000 Subject: [PATCH] :sparkles: InteractionCreateEvent add `get_user_id` --- nonebot/adapters/discord/event.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nonebot/adapters/discord/event.py b/nonebot/adapters/discord/event.py index 35c0014..e9ba262 100644 --- a/nonebot/adapters/discord/event.py +++ b/nonebot/adapters/discord/event.py @@ -624,6 +624,12 @@ class InteractionCreateEvent(NoticeEvent, InteractionCreate): __type__ = EventType.INTERACTION_CREATE + @override + def get_user_id(self) -> str: + if not self.user: + raise ValueError("Event has no context!") + return str(self.user.id) + class PingInteractionEvent(InteractionCreateEvent): type: Literal[InteractionType.PING]