mirror of
https://github.com/spacebarchat/client.git
synced 2024-11-25 11:42:30 +01:00
Implement GuildMemberAdd/Remove
This commit is contained in:
parent
f86cd60771
commit
29715321c8
@ -10,7 +10,9 @@ import {
|
||||
GatewayGuild,
|
||||
GatewayGuildCreateDispatchData,
|
||||
GatewayGuildDeleteDispatchData,
|
||||
GatewayGuildMemberAddDispatchData,
|
||||
GatewayGuildMemberListUpdateDispatchData,
|
||||
GatewayGuildMemberRemoveDispatchData,
|
||||
GatewayGuildModifyDispatchData,
|
||||
GatewayHeartbeat,
|
||||
GatewayHelloData,
|
||||
@ -115,6 +117,8 @@ export default class GatewayConnectionStore {
|
||||
this.dispatchHandlers.set(GatewayDispatchEvents.GuildCreate, this.onGuildCreate);
|
||||
this.dispatchHandlers.set(GatewayDispatchEvents.GuildUpdate, this.onGuildUpdate);
|
||||
this.dispatchHandlers.set(GatewayDispatchEvents.GuildDelete, this.onGuildDelete);
|
||||
this.dispatchHandlers.set(GatewayDispatchEvents.GuildMemberAdd, this.onGuildMemberAdd);
|
||||
this.dispatchHandlers.set(GatewayDispatchEvents.GuildMemberRemove, this.onGuildMemberRemove);
|
||||
this.dispatchHandlers.set(GatewayDispatchEvents.GuildMemberListUpdate, this.onGuildMemberListUpdate);
|
||||
|
||||
this.dispatchHandlers.set(GatewayDispatchEvents.ChannelCreate, this.onChannelCreate);
|
||||
@ -520,6 +524,26 @@ export default class GatewayConnectionStore {
|
||||
});
|
||||
};
|
||||
|
||||
private onGuildMemberAdd = (data: GatewayGuildMemberAddDispatchData) => {
|
||||
this.logger.debug("Received GuildMemberAdd event");
|
||||
const guild = this.app.guilds.get(data.guild_id);
|
||||
if (!guild) {
|
||||
this.logger.warn(`[GuildMemberAdd] Guild ${data.guild_id} not found for member ${data.user?.id}`);
|
||||
return;
|
||||
}
|
||||
guild.members.add(data);
|
||||
};
|
||||
|
||||
private onGuildMemberRemove = (data: GatewayGuildMemberRemoveDispatchData) => {
|
||||
this.logger.debug("Received GuildMemberRemove event");
|
||||
const guild = this.app.guilds.get(data.guild_id);
|
||||
if (!guild) {
|
||||
this.logger.warn(`[GuildMemberRemove] Guild ${data.guild_id} not found for member ${data.user.id}`);
|
||||
return;
|
||||
}
|
||||
guild.members.remove(data.user.id);
|
||||
};
|
||||
|
||||
private onGuildMemberListUpdate = (data: GatewayGuildMemberListUpdateDispatchData) => {
|
||||
this.logger.debug("Received GuildMemberListUpdate event");
|
||||
const { guild_id } = data;
|
||||
|
Loading…
Reference in New Issue
Block a user