VoiceStateManager.js (867B)
1 'use strict'; 2 3 const BaseManager = require('./BaseManager'); 4 const VoiceState = require('../structures/VoiceState'); 5 6 /** 7 * Manages API methods for VoiceStates and stores their cache. 8 * @extends {BaseManager} 9 */ 10 class VoiceStateManager extends BaseManager { 11 constructor(guild, iterable) { 12 super(guild.client, iterable, VoiceState); 13 /** 14 * The guild this manager belongs to 15 * @type {Guild} 16 */ 17 this.guild = guild; 18 } 19 20 /** 21 * The cache of this manager 22 * @type {Collection<Snowflake, VoiceState>} 23 * @name VoiceStateManager#cache 24 */ 25 26 add(data, cache = true) { 27 const existing = this.cache.get(data.user_id); 28 if (existing) return existing._patch(data); 29 30 const entry = new VoiceState(this.guild, data); 31 if (cache) this.cache.set(data.user_id, entry); 32 return entry; 33 } 34 } 35 36 module.exports = VoiceStateManager;