2020-03-02 19:38:42 +00:00
|
|
|
module.exports = {
|
|
|
|
name: 'stop',
|
|
|
|
description: 'Stop command.',
|
2020-03-09 11:28:52 +00:00
|
|
|
alias: 's',
|
2020-03-02 19:38:42 +00:00
|
|
|
usage: '',
|
2020-03-08 14:54:57 +00:00
|
|
|
permission: 'none',
|
2020-03-02 19:38:42 +00:00
|
|
|
category: 'music',
|
2020-03-22 15:10:46 +00:00
|
|
|
execute(msg, args, client, Discord, command) {
|
2020-03-02 19:38:42 +00:00
|
|
|
const radio = client.radio.get(msg.guild.id);
|
2020-03-12 09:59:05 +00:00
|
|
|
if (client.funcs.check(client, msg, command)) {
|
2020-04-01 13:58:08 +00:00
|
|
|
statisticsUpdate(client, msg.guild, radio);
|
2020-03-12 09:59:05 +00:00
|
|
|
radio.connection.dispatcher.destroy();
|
|
|
|
radio.voiceChannel.leave();
|
|
|
|
client.radio.delete(msg.guild.id);
|
2020-03-15 01:30:15 +00:00
|
|
|
msg.channel.send(client.messageEmojis["stop"] + client.messages.stop);
|
2020-03-12 09:59:05 +00:00
|
|
|
}
|
2020-03-02 19:38:42 +00:00
|
|
|
}
|
2020-04-01 13:58:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function statisticsUpdate(client, guild, radio) {
|
|
|
|
client.datastore.checkEntry(guild.id);
|
|
|
|
radio.currentGuild = client.datastore.getEntry(guild.id);
|
|
|
|
if(!radio.currentGuild.statistics[radio.station.name]){
|
|
|
|
radio.currentGuild.statistics[radio.station.name] = {};
|
|
|
|
radio.currentGuild.statistics[radio.station.name].time = 0;
|
|
|
|
radio.currentGuild.statistics[radio.station.name].used = 0;
|
|
|
|
client.datastore.updateEntry(guild, radio.currentGuild);
|
|
|
|
}
|
|
|
|
|
|
|
|
radio.currentGuild.statistics[radio.station.name].time = parseInt(radio.currentGuild.statistics[radio.station.name].time)+parseInt(radio.connection.dispatcher.streamTime.toFixed(0));
|
|
|
|
radio.currentGuild.statistics[radio.station.name].used = parseInt(radio.currentGuild.statistics[radio.station.name].used)+1;
|
|
|
|
client.datastore.updateEntry(guild, radio.currentGuild);
|
|
|
|
}
|