15
src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js
Normal file
15
src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
const { Events } = require('../../../util/Constants');
|
||||
module.exports = (client, packet) => {
|
||||
/**
|
||||
* Emitted whenever a recipient is added from a group DM.
|
||||
* @event Client#channelRecipientAdd
|
||||
* @param {PartialGroupDMChannel} channel Group DM channel
|
||||
* @param {User} user User
|
||||
*/
|
||||
const channel = client.channels.cache.get(packet.d.channel_id);
|
||||
if (!channel) return;
|
||||
channel._recipients = channel._recipients.push(packet.d.user);
|
||||
const user = client.users._add(packet.d.user);
|
||||
client.emit(Events.CHANNEL_RECIPIENT_ADD, channel, user);
|
||||
};
|
15
src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js
Normal file
15
src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
const { Events } = require('../../../util/Constants');
|
||||
module.exports = (client, packet) => {
|
||||
/**
|
||||
* Emitted whenever a recipient is removed from a group DM.
|
||||
* @event Client#channelRecipientRemove
|
||||
* @param {PartialGroupDMChannel} channel Group DM channel
|
||||
* @param {User} user User
|
||||
*/
|
||||
const channel = client.channels.cache.get(packet.d.channel_id);
|
||||
if (!channel) return;
|
||||
channel._recipients = channel._recipients.filter(r => r !== packet.d.user.id);
|
||||
const user = client.users._add(packet.d.user);
|
||||
client.emit(Events.CHANNEL_RECIPIENT_REMOVE, channel, user);
|
||||
};
|
@@ -4,6 +4,7 @@ const { Events, RelationshipTypes } = require('../../../util/Constants');
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
client.relationships.cache.delete(data.id);
|
||||
client.user.friendNicknames.delete(data.id);
|
||||
/**
|
||||
* Emitted whenever a relationship is delete.
|
||||
* @event Client#relationshipRemove
|
||||
|
18
src/client/websocket/handlers/RELATIONSHIP_UPDATE.js
Normal file
18
src/client/websocket/handlers/RELATIONSHIP_UPDATE.js
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
const { Events, RelationshipTypes } = require('../../../util/Constants');
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
client.relationships.cache.set(data.id, data.type);
|
||||
/**
|
||||
* Emitted whenever a relationship is updated.
|
||||
* @event Client#relationshipUpdate
|
||||
* @param {Snowflake} user The userID that was updated
|
||||
* @param {RelationshipTypes} type The new relationship type
|
||||
* @param {Object} data The raw data
|
||||
*/
|
||||
if ('nickname' in data) {
|
||||
client.user.friendNicknames.set(data.id, data.nickname);
|
||||
}
|
||||
client.emit(Events.RELATIONSHIP_UPDATE, data.id, RelationshipTypes[data.type], data);
|
||||
};
|
@@ -5,6 +5,7 @@ const handlers = Object.fromEntries([
|
||||
['RESUMED', require('./RESUMED')],
|
||||
['RELATIONSHIP_ADD', require('./RELATIONSHIP_ADD')],
|
||||
['RELATIONSHIP_REMOVE', require('./RELATIONSHIP_REMOVE')],
|
||||
['RELATIONSHIP_UPDATE', require('./RELATIONSHIP_UPDATE')],
|
||||
['APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE', require('./APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE')],
|
||||
['APPLICATION_COMMAND_CREATE', require('./APPLICATION_COMMAND_CREATE')],
|
||||
['APPLICATION_COMMAND_DELETE', require('./APPLICATION_COMMAND_DELETE')],
|
||||
@@ -34,6 +35,8 @@ const handlers = Object.fromEntries([
|
||||
['CHANNEL_DELETE', require('./CHANNEL_DELETE')],
|
||||
['CHANNEL_UPDATE', require('./CHANNEL_UPDATE')],
|
||||
['CHANNEL_PINS_UPDATE', require('./CHANNEL_PINS_UPDATE')],
|
||||
['CHANNEL_RECIPIENT_ADD', require('./CHANNEL_RECIPIENT_ADD')],
|
||||
['CHANNEL_RECIPIENT_REMOVE', require('./CHANNEL_RECIPIENT_REMOVE')],
|
||||
['MESSAGE_ACK', require('./MESSAGE_ACK')],
|
||||
['MESSAGE_CREATE', require('./MESSAGE_CREATE')],
|
||||
['MESSAGE_DELETE', require('./MESSAGE_DELETE')],
|
||||
|
Reference in New Issue
Block a user