mirror of
https://github.com/evennia/evennia.git
synced 2026-03-30 04:27:16 +02:00
Fix #3716: Guard Discord member nick access and fall back to author name
Signed-off-by: Skitter Bot <skitterx+bot@users.noreply.github.com>
This commit is contained in:
parent
3761a7cb21
commit
344c97b341
1 changed files with 10 additions and 3 deletions
|
|
@ -534,10 +534,17 @@ class DiscordClient(WebSocketClientProtocol, _BASE_SESSION_CLASS):
|
|||
if "guild_id" in data:
|
||||
# message received to a Discord channel
|
||||
keywords["type"] = "channel"
|
||||
author = data["member"]["nick"] or data["author"]["username"]
|
||||
author_id = data["author"]["id"]
|
||||
member = data.get("member", {}) or {}
|
||||
author_info = data.get("author", {}) or {}
|
||||
# Prefer guild nickname; fall back to global_name, then username
|
||||
author = (
|
||||
member.get("nick")
|
||||
or author_info.get("global_name")
|
||||
or author_info.get("username")
|
||||
)
|
||||
author_id = author_info.get("id") or data["author"]["id"]
|
||||
keywords["sender"] = (author_id, author)
|
||||
keywords["guild_id"] = data["guild_id"]
|
||||
keywords["guild_id"] = data.get("guild_id")
|
||||
|
||||
else:
|
||||
# message sent directly to the bot account via DM
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue