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

40 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-09-04 23:12:43 +00:00
module.exports = {
2021-09-04 23:54:56 +00:00
name: 'prev',
2021-09-04 23:12:43 +00:00
description: 'Previous Station',
category: 'radio',
2021-09-05 02:41:22 +00:00
async execute(interaction, client, command) {
2021-09-05 00:37:03 +00:00
if (client.funcs.check(client, interaction, command)) {
const radio = client.radio.get(interaction.guild.id);
2021-09-05 02:41:22 +00:00
let index = client.stations.findIndex(station => station.name == radio.station.name) - 1;
if(index == -1) index = client.stations.length - 1;
let station = client.stations[index];
if(!station) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.noSearchResults,
ephemeral: true
});
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();
2021-09-09 09:44:50 +00:00
2021-09-05 01:42:11 +00:00
let date = new Date();
radio.station = station;
radio.textChannel = interaction.channel;
radio.startTime = date.getTime();
2021-09-09 09:44:50 +00:00
2021-09-06 19:35:21 +00:00
if(interaction.isCommand()) {
client.funcs.play(interaction, interaction.guild, client, url);
}
if(interaction.isButton()) {
interaction.deferUpdate();
client.funcs.play(null, interaction.guild, client, url);
}
2021-09-05 01:42:11 +00:00
2021-09-04 23:12:43 +00:00
}
}
2021-09-09 09:44:50 +00:00
}