mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
Add ChannelPinsUpdate event
This commit is contained in:
@@ -38,6 +38,7 @@ class WebSocketPacketManager {
|
||||
this.register(Constants.WSEvents.MESSAGE_UPDATE, 'MessageUpdate');
|
||||
this.register(Constants.WSEvents.VOICE_SERVER_UPDATE, 'VoiceServerUpdate');
|
||||
this.register(Constants.WSEvents.MESSAGE_DELETE_BULK, 'MessageDeleteBulk');
|
||||
this.register(Constants.WSEvents.CHANNEL_PINS_UPDATE, 'ChannelPinsUpdate');
|
||||
}
|
||||
|
||||
get client() {
|
||||
|
||||
38
src/client/websocket/packets/handlers/ChannelPinsUpdate.js
Normal file
38
src/client/websocket/packets/handlers/ChannelPinsUpdate.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const AbstractHandler = require('./AbstractHandler');
|
||||
const Constants = require('../../../../util/Constants');
|
||||
|
||||
/*
|
||||
{ t: 'CHANNEL_PINS_UPDATE',
|
||||
s: 666,
|
||||
op: 0,
|
||||
d:
|
||||
{ last_pin_timestamp: '2016-08-28T17:37:13.171774+00:00',
|
||||
channel_id: '314866471639044027' } }
|
||||
*/
|
||||
|
||||
class ChannelPinsUpdate extends AbstractHandler {
|
||||
|
||||
handle(packet) {
|
||||
const data = packet.d;
|
||||
const client = this.packetManager.client;
|
||||
|
||||
const channel = client.channels.get(data.channel_id);
|
||||
const time = new Date(data.last_pin_timestamp);
|
||||
|
||||
if (channel && time) {
|
||||
return client.emit(Constants.Events.CHANNEL_PINS_UPDATE, channel, time);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever the pins of a Channel are updated. Due to the nature of the WebSocket event, not much information
|
||||
* can be provided easily here - you need to manually check the pins yourself.
|
||||
*
|
||||
* @event Client#channelPinsUpdate
|
||||
* @param {Channel} channel The channel that the pins update occured in
|
||||
* @param {Date} time the time of the pins update
|
||||
*/
|
||||
|
||||
module.exports = ChannelPinsUpdate;
|
||||
@@ -165,6 +165,7 @@ exports.Events = {
|
||||
RECONNECTING: 'reconnecting',
|
||||
GUILD_MEMBER_SPEAKING: 'guildMemberSpeaking',
|
||||
MESSAGE_BULK_DELETE: 'messageDeleteBulk',
|
||||
CHANNEL_PINS_UPDATE: 'channelPinsUpdate',
|
||||
};
|
||||
|
||||
exports.WSEvents = {
|
||||
@@ -195,6 +196,7 @@ exports.WSEvents = {
|
||||
FRIEND_REMOVE: 'RELATIONSHIP_REMOVE',
|
||||
VOICE_SERVER_UPDATE: 'VOICE_SERVER_UPDATE',
|
||||
MESSAGE_DELETE_BULK: 'MESSAGE_DELETE_BULK',
|
||||
CHANNEL_PINS_UPDATE: 'CHANNEL_PINS_UPDATE',
|
||||
};
|
||||
|
||||
const PermissionFlags = exports.PermissionFlags = {
|
||||
|
||||
Reference in New Issue
Block a user