this._validator = setInterval(() => { for (const gid of this.states.keys()) { if (!this._client.guilds.has(gid)) { this.states.delete(gid) } } }, 120000)
bindChannel (guildID, textChannelID) { this.states.set(guildID, { channel: textChannelID, state: null, skip: [], clear: [], shuffle: [], volume: 2 }) }
unload () { for (const [guildID, state] of this.states.entries()) { let conn = this._client.voiceConnections.get(guildID) if (!conn) continue conn.removeAllListeners() if (conn.playing) conn.stopPlaying() conn.disconnect() if (state.channel) { this.send(state.channel, ':information_source: | {{terminated}}') } } clearInterval(this._validator) delete this._validator for (const ws in this._ws) { this._ws[ws].removeAllListeners() } delete this.streamInfo delete this._ws }
modifyState (guildID, stateName, value) { let state = this.getState(guildID) if (typeof state !== 'object') return state[stateName] = value this.states.set(guildID, state) }
getState (guildID) { return this.states.get(guildID) }
unbindChannel (guildID) { this.states.delete(guildID) }