removed stations memory leak

This commit is contained in:
MatteZ02 2020-03-09 01:31:24 +02:00
parent 6e11029461
commit 148ce79316
3 changed files with 13 additions and 19 deletions

View File

@ -2,6 +2,7 @@ const { Client, Collection } = require('discord.js');
const Discord = require('discord.js');
const fs = require('fs');
const path = require('path');
const fetch = require('node-fetch');
const events = '../events/';
module.exports = class extends Client {
@ -29,6 +30,9 @@ module.exports = class extends Client {
this.commandAliases.set(command.alias, command);
}
client.stations = fetch('https://gitea.cwinfo.org/cwchristerw/radio/raw/branch/master/playlist.json')
.then(res => res.json());
this.on('ready', () => {
require(`${events}ready`).execute(this, Discord);
});

View File

@ -1,7 +1,6 @@
module.exports = async function (guild, client, station) {
const radio = client.radio.get(guild.id);
const stations = await client.funcs.radiostations();
let url = "";
if (isNaN(station)) {
@ -9,12 +8,12 @@ module.exports = async function (guild, client, station) {
return radio.textChannel.send('<:redx:674263474704220182> An error has occured while playing radio!');
}
if(station-1 > stations.length-1){
if (station - 1 > client.stations.length - 1) {
radio.voiceChannel.leave();
return radio.textChannel.send('<:redx:674263474704220182> An error has occured while playing radio!');
}
url = stations[station-1].stream[stations[station-1].stream.default];
url = client.stations[station - 1].stream[client.stations[station - 1].stream.default];
if (!url) {
radio.voiceChannel.leave();

View File

@ -1,9 +0,0 @@
module.exports = async function () {
const fetch = require('node-fetch');
let data = fetch('https://gitea.cwinfo.org/cwchristerw/radio/raw/branch/master/playlist.json')
.then(res => res.json());
return data;
}