eximiabots-radiox/src/client/commands/next.js

34 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-09-04 23:12:43 +00:00
module.exports = {
name: 'next',
description: 'Next Station',
category: 'radio',
2021-09-05 00:37:03 +00:00
async execute(interaction, client, command) {
if (client.funcs.check(client, interaction, command)) {
const radio = client.radio.get(interaction.guild.id);
2021-09-05 01:42:11 +00:00
2021-09-05 02:41:13 +00:00
let index = client.stations.findIndex(station => station.name == radio.station.name) + 1;
if(index == client.stations.length) index = 0;
let station = client.stations[index];
if(!station) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.noSearchResults,
ephemeral: true
});
interaction.deferUpdate();
let url = station.stream[station.stream.default];
2021-09-05 01:42:11 +00:00
client.funcs.statisticsUpdate(client, interaction.guild, radio);
radio.audioPlayer.stop();
let date = new Date();
radio.station = station;
radio.textChannel = interaction.channel;
radio.startTime = date.getTime();
2021-09-05 02:41:13 +00:00
client.funcs.play(null, interaction.guild, client, url);
2021-09-05 01:42:11 +00:00
2021-09-04 23:12:43 +00:00
}
}
}