summaryrefslogtreecommitdiff
path: root/protocols/Discord/src/dispatch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Discord/src/dispatch.cpp')
-rw-r--r--protocols/Discord/src/dispatch.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp
index fe581e61b9..e28f6f70d2 100644
--- a/protocols/Discord/src/dispatch.cpp
+++ b/protocols/Discord/src/dispatch.cpp
@@ -34,6 +34,7 @@ static handlers[] = // these structures must me sorted alphabetically
{ L"GUILD_CREATE", &CDiscordProto::OnCommandGuildCreate },
{ L"GUILD_DELETE", &CDiscordProto::OnCommandGuildDelete },
{ L"GUILD_MEMBER_REMOVE", &CDiscordProto::OnCommandGuildRemoveMember },
+ { L"GUILD_MEMBER_UPDATE", &CDiscordProto::OnCommandGuildUpdateMember },
{ L"GUILD_SYNC", &CDiscordProto::OnCommandGuildSync },
{ L"MESSAGE_ACK", &CDiscordProto::OnCommandMessageAck },
@@ -260,6 +261,34 @@ void CDiscordProto::OnCommandGuildRemoveMember(const JSONNode &pRoot)
}
}
+void CDiscordProto::OnCommandGuildUpdateMember(const JSONNode &pRoot)
+{
+ SnowFlake guildId = ::getId(pRoot["guild_id"]);
+ CMStringW wszUserId = pRoot["user"]["id"].as_mstring();
+ CMStringW wszUserNick = pRoot["nick"].as_mstring(), wszOldNick;
+
+ for (int i = 0; i < arUsers.getCount(); i++) {
+ CDiscordUser &pUser = arUsers[i];
+ if (pUser.guildId != guildId)
+ continue;
+
+ SESSION_INFO *si = pci->SM_FindSession(pUser.wszUsername, m_szModuleName);
+ if (si != nullptr) {
+ USERINFO *ui = pci->UM_FindUser(si->pUsers, wszUserId);
+ if (ui != nullptr)
+ wszOldNick = ui->pszNick;
+ }
+
+ GCDEST gcd = { m_szModuleName, pUser.wszUsername, GC_EVENT_NICK };
+ GCEVENT gce = { &gcd };
+ gce.ptszUID = wszUserId;
+ gce.ptszNick = wszOldNick;
+ gce.ptszText = wszUserNick;
+ Chat_Event(&gce);
+ }
+}
+
+
/////////////////////////////////////////////////////////////////////////////////////////
// reading a new message