mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-23 00:33:17 +00:00
Moved listStations into funcs folder
This commit is contained in:
parent
ec6ea7e839
commit
17132cd51a
@ -41,6 +41,7 @@ class RadioClient extends Client {
|
|||||||
this.funcs.loadState = require("./client/funcs/loadState.js");
|
this.funcs.loadState = require("./client/funcs/loadState.js");
|
||||||
this.funcs.searchStation = require("./client/funcs/searchStation.js");
|
this.funcs.searchStation = require("./client/funcs/searchStation.js");
|
||||||
this.funcs.play = require("./client/funcs/play.js");
|
this.funcs.play = require("./client/funcs/play.js");
|
||||||
|
this.funcs.listStations = require("./client/funcs/listStations.js");
|
||||||
|
|
||||||
console.log('RadioX ' + this.config.version);
|
console.log('RadioX ' + this.config.version);
|
||||||
console.log('Internet Radio to your Discord guild');
|
console.log('Internet Radio to your Discord guild');
|
||||||
|
@ -3,7 +3,7 @@ module.exports = {
|
|||||||
description: 'List radio stations',
|
description: 'List radio stations',
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'radio',
|
category: 'radio',
|
||||||
execute(interaction, client, Discord, command) {
|
execute(interaction, client, Discord) {
|
||||||
let message = {};
|
let message = {};
|
||||||
if(!client.stations) {
|
if(!client.stations) {
|
||||||
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
|
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
|
||||||
@ -13,49 +13,7 @@ module.exports = {
|
|||||||
const radio = client.radio.get(interaction.guild.id);
|
const radio = client.radio.get(interaction.guild.id);
|
||||||
|
|
||||||
if(radio){
|
if(radio){
|
||||||
let menu = [];
|
client.funcs.listStations(client, interaction);
|
||||||
|
|
||||||
let stations = new Array();
|
|
||||||
|
|
||||||
let options = new Array();
|
|
||||||
options[1] = new Array();
|
|
||||||
options[2] = new Array();
|
|
||||||
|
|
||||||
stations[1] = client.stations.slice(0,24).forEach(station => {
|
|
||||||
station = {
|
|
||||||
label: station.name,
|
|
||||||
description: station.owner,
|
|
||||||
value: station.name
|
|
||||||
};
|
|
||||||
options[1].push(station);
|
|
||||||
});
|
|
||||||
|
|
||||||
stations[2] = client.stations.slice(25).forEach(station => {
|
|
||||||
station = {
|
|
||||||
label: station.name,
|
|
||||||
description: station.owner,
|
|
||||||
value: station.name
|
|
||||||
};
|
|
||||||
options[2].push(station);
|
|
||||||
});
|
|
||||||
|
|
||||||
menu = new Discord.MessageActionRow()
|
|
||||||
.addComponents(
|
|
||||||
new Discord.MessageSelectMenu()
|
|
||||||
.setCustomId('play')
|
|
||||||
.setPlaceholder('Change station')
|
|
||||||
.addOptions(options[1])
|
|
||||||
.addOptions(options[2])
|
|
||||||
);
|
|
||||||
|
|
||||||
stations = null;
|
|
||||||
options = null;
|
|
||||||
|
|
||||||
interaction.reply({
|
|
||||||
content: '**Select station:**',
|
|
||||||
components: [menu],
|
|
||||||
ephemeral: true
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
let stations = `${client.stations.map(s => `**#** ${s.name}`).join('\n')}`
|
let stations = `${client.stations.map(s => `**#** ${s.name}`).join('\n')}`
|
||||||
const hashs = stations.split('**#**').length;
|
const hashs = stations.split('**#**').length;
|
||||||
|
@ -22,47 +22,7 @@ module.exports = {
|
|||||||
return interaction.reply(client.messageEmojis["error"] + message.errorToGetPlaylist);
|
return interaction.reply(client.messageEmojis["error"] + message.errorToGetPlaylist);
|
||||||
}
|
}
|
||||||
|
|
||||||
let stations = new Array();
|
client.funcs.listStations(client, interaction);
|
||||||
|
|
||||||
let options = new Array();
|
|
||||||
options[1] = new Array();
|
|
||||||
options[2] = new Array();
|
|
||||||
|
|
||||||
stations[1] = client.stations.slice(0,24).forEach(station => {
|
|
||||||
station = {
|
|
||||||
label: station.name,
|
|
||||||
description: station.owner,
|
|
||||||
value: station.name
|
|
||||||
};
|
|
||||||
options[1].push(station);
|
|
||||||
});
|
|
||||||
|
|
||||||
stations[2] = client.stations.slice(25).forEach(station => {
|
|
||||||
station = {
|
|
||||||
label: station.name,
|
|
||||||
description: station.owner,
|
|
||||||
value: station.name
|
|
||||||
};
|
|
||||||
options[2].push(station);
|
|
||||||
});
|
|
||||||
|
|
||||||
const menu = new Discord.MessageActionRow()
|
|
||||||
.addComponents(
|
|
||||||
new Discord.MessageSelectMenu()
|
|
||||||
.setCustomId('play')
|
|
||||||
.setPlaceholder('Nothing selected')
|
|
||||||
.addOptions(options[1])
|
|
||||||
.addOptions(options[2])
|
|
||||||
);
|
|
||||||
|
|
||||||
stations = null;
|
|
||||||
options = null;
|
|
||||||
|
|
||||||
return interaction.reply({
|
|
||||||
content: '**Select station:**',
|
|
||||||
components: [menu],
|
|
||||||
ephemeral: true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
let url = query ? query.replace(/<(.+)>/g, "$1") : "";
|
let url = query ? query.replace(/<(.+)>/g, "$1") : "";
|
||||||
const radio = client.radio.get(interaction.guild.id);
|
const radio = client.radio.get(interaction.guild.id);
|
||||||
@ -139,7 +99,7 @@ module.exports = {
|
|||||||
radio.station = station;
|
radio.station = station;
|
||||||
radio.textChannel = interaction.channel;
|
radio.textChannel = interaction.channel;
|
||||||
radio.startTime = date.getTime();
|
radio.startTime = date.getTime();
|
||||||
client.funcs.play(interaction, interaction.guild, client, url, Discord);
|
client.funcs.play(interaction, interaction.guild, client, url);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -165,7 +125,7 @@ module.exports = {
|
|||||||
construct.connection = connection;
|
construct.connection = connection;
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
construct.startTime = date.getTime();
|
construct.startTime = date.getTime();
|
||||||
client.funcs.play(interaction, interaction.guild, client, url, Discord);
|
client.funcs.play(interaction, interaction.guild, client, url);
|
||||||
|
|
||||||
client.datastore.checkEntry(interaction.guild.id);
|
client.datastore.checkEntry(interaction.guild.id);
|
||||||
construct.currentGuild = client.datastore.getEntry(interaction.guild.id);
|
construct.currentGuild = client.datastore.getEntry(interaction.guild.id);
|
||||||
|
45
src/client/funcs/listStations.js
Normal file
45
src/client/funcs/listStations.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import Discord from "discord.js";
|
||||||
|
|
||||||
|
module.exports = function (client, interaction){
|
||||||
|
let stations = new Array();
|
||||||
|
|
||||||
|
let options = new Array();
|
||||||
|
options[1] = new Array();
|
||||||
|
options[2] = new Array();
|
||||||
|
|
||||||
|
stations[1] = client.stations.slice(0,24).forEach(station => {
|
||||||
|
station = {
|
||||||
|
label: station.name,
|
||||||
|
description: station.owner,
|
||||||
|
value: station.name
|
||||||
|
};
|
||||||
|
options[1].push(station);
|
||||||
|
});
|
||||||
|
|
||||||
|
stations[2] = client.stations.slice(25).forEach(station => {
|
||||||
|
station = {
|
||||||
|
label: station.name,
|
||||||
|
description: station.owner,
|
||||||
|
value: station.name
|
||||||
|
};
|
||||||
|
options[2].push(station);
|
||||||
|
});
|
||||||
|
|
||||||
|
const menu = new Discord.MessageActionRow()
|
||||||
|
.addComponents(
|
||||||
|
new Discord.MessageSelectMenu()
|
||||||
|
.setCustomId('play')
|
||||||
|
.setPlaceholder('Nothing selected')
|
||||||
|
.addOptions(options[1])
|
||||||
|
.addOptions(options[2])
|
||||||
|
);
|
||||||
|
|
||||||
|
stations = null;
|
||||||
|
options = null;
|
||||||
|
|
||||||
|
return interaction.reply({
|
||||||
|
content: '**Select station:**',
|
||||||
|
components: [menu],
|
||||||
|
ephemeral: true
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user