Example #1
0
File: Music.js Project: pyraxo/haru
 this._validator = setInterval(() => {
   for (const gid of this.states.keys()) {
     if (!this._client.guilds.has(gid)) {
       this.states.delete(gid)
     }
   }
 }, 120000)
Example #2
0
File: Music.js Project: pyraxo/haru
 bindChannel (guildID, textChannelID) {
   this.states.set(guildID, {
     channel: textChannelID,
     state: null,
     skip: [],
     clear: [],
     shuffle: [],
     volume: 2
   })
 }
Example #3
0
File: Music.js Project: pyraxo/haru
  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
  }
Example #4
0
File: Music.js Project: pyraxo/haru
 modifyState (guildID, stateName, value) {
   let state = this.getState(guildID)
   if (typeof state !== 'object') return
   state[stateName] = value
   this.states.set(guildID, state)
 }
Example #5
0
File: Music.js Project: pyraxo/haru
 getState (guildID) {
   return this.states.get(guildID)
 }
Example #6
0
File: Music.js Project: pyraxo/haru
 unbindChannel (guildID) {
   this.states.delete(guildID)
 }