mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-23 09:13:18 +00:00
Update multiple commands
This commit is contained in:
parent
6d22dda0ae
commit
c7ddc6ec5b
@ -7,7 +7,7 @@ module.exports = {
|
|||||||
execute(interaction, client) {
|
execute(interaction, client) {
|
||||||
let message = {};
|
let message = {};
|
||||||
|
|
||||||
if(!client.stations) {
|
if(!client.stations.list) {
|
||||||
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
|
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: client.messageEmojis["error"] + message.errorToGetPlaylist,
|
content: client.messageEmojis["error"] + message.errorToGetPlaylist,
|
||||||
@ -20,7 +20,7 @@ module.exports = {
|
|||||||
if(radio && !client.config.maintenanceMode){
|
if(radio && !client.config.maintenanceMode){
|
||||||
client.funcs.listStations(client, interaction);
|
client.funcs.listStations(client, interaction);
|
||||||
} else {
|
} else {
|
||||||
let stations = `${client.stations.map(s => `**#** ${s.name}`).join('\n')}`
|
let stations = `${client.stations.list.map(s => `**#** ${s.name}`).join('\n')}`
|
||||||
const hashs = stations.split('**#**').length;
|
const hashs = stations.split('**#**').length;
|
||||||
for (let i = 0; i < hashs; i++) {
|
for (let i = 0; i < hashs; i++) {
|
||||||
stations = stations.replace('**#**', `**${i + 1}.**`);
|
stations = stations.replace('**#**', `**${i + 1}.**`);
|
||||||
|
@ -111,14 +111,14 @@ module.exports = {
|
|||||||
case "4":
|
case "4":
|
||||||
client.config.maintenanceMode = true;
|
client.config.maintenanceMode = true;
|
||||||
client.user.setStatus('idle');
|
client.user.setStatus('idle');
|
||||||
client.funcs.saveRadios(client);
|
client.radio.save(client);
|
||||||
client.user.setStatus('online');
|
client.user.setStatus('online');
|
||||||
client.config.maintenanceMode = false;
|
client.config.maintenanceMode = false;
|
||||||
break;
|
break;
|
||||||
case "5":
|
case "5":
|
||||||
client.config.maintenanceMode = true;
|
client.config.maintenanceMode = true;
|
||||||
client.user.setStatus('idle');
|
client.user.setStatus('idle');
|
||||||
client.funcs.restoreRadios(client, guilds);
|
client.radio.restore(client, guilds);
|
||||||
client.user.setStatus('online');
|
client.user.setStatus('online');
|
||||||
client.config.maintenanceMode = false;
|
client.config.maintenanceMode = false;
|
||||||
break;
|
break;
|
||||||
@ -131,17 +131,13 @@ module.exports = {
|
|||||||
break;
|
break;
|
||||||
case "7":
|
case "7":
|
||||||
try {
|
try {
|
||||||
client.funcs.logger('Stations', 'Started fetching list – ' + client.config.stationslistUrl);
|
client.stations.fetch({
|
||||||
client.stations = await fetch(client.config.stationslistUrl)
|
url: client.config.stationslistUrl
|
||||||
.then(client.funcs.checkFetchStatus)
|
});
|
||||||
.then(response => response.json());
|
|
||||||
|
|
||||||
client.funcs.logger('Stations', 'Successfully fetched list');
|
|
||||||
|
|
||||||
client.streamer.refresh(client);
|
client.streamer.refresh(client);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
client.funcs.logger('Stations', 'Fetching list failed');
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "8":
|
case "8":
|
||||||
@ -167,7 +163,7 @@ module.exports = {
|
|||||||
client.streamer = new Streamer();
|
client.streamer = new Streamer();
|
||||||
client.streamer.init(client);
|
client.streamer.init(client);
|
||||||
|
|
||||||
client.funcs.restoreRadios(client, guilds);
|
client.radio.restore(client, guilds);
|
||||||
client.user.setStatus('online');
|
client.user.setStatus('online');
|
||||||
client.config.maintenanceMode = false;
|
client.config.maintenanceMode = false;
|
||||||
}
|
}
|
||||||
@ -183,7 +179,7 @@ module.exports = {
|
|||||||
client.config.maintenanceMode = true;
|
client.config.maintenanceMode = true;
|
||||||
|
|
||||||
client.user.setStatus('idle');
|
client.user.setStatus('idle');
|
||||||
client.funcs.saveRadios(client);
|
client.funcs.save(client);
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
if(client.radio.size == 0 && client.config.streamerMode == "auto" && client.config.maintenanceMode){
|
if(client.radio.size == 0 && client.config.streamerMode == "auto" && client.config.maintenanceMode){
|
||||||
@ -191,7 +187,7 @@ module.exports = {
|
|||||||
client.streamer = new Streamer();
|
client.streamer = new Streamer();
|
||||||
client.streamer.init(client);
|
client.streamer.init(client);
|
||||||
|
|
||||||
client.funcs.restoreRadios(client, guilds);
|
client.radio.restore(client, guilds);
|
||||||
client.user.setStatus('online');
|
client.user.setStatus('online');
|
||||||
client.config.maintenanceMode = false;
|
client.config.maintenanceMode = false;
|
||||||
}
|
}
|
||||||
|
@ -6,17 +6,17 @@ module.exports = {
|
|||||||
if (client.funcs.check(client, interaction, command)) {
|
if (client.funcs.check(client, interaction, command)) {
|
||||||
const radio = client.radio.get(interaction.guild.id);
|
const radio = client.radio.get(interaction.guild.id);
|
||||||
|
|
||||||
let index = client.stations.findIndex(station => station.name == radio.station.name) + 1;
|
let index = client.stations.list.findIndex(station => station.name == radio.station.name) + 1;
|
||||||
if(index == client.stations.length) index = 0;
|
if(index == client.stations.list.length) index = 0;
|
||||||
|
|
||||||
let station = client.stations[index];
|
let station = client.stations.list[index];
|
||||||
|
|
||||||
if(!station) return interaction.reply({
|
if(!station) return interaction.reply({
|
||||||
content: client.messageEmojis["error"] + client.messages.noSearchResults,
|
content: client.messageEmojis["error"] + client.messages.noSearchResults,
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
});
|
});
|
||||||
|
|
||||||
client.funcs.statisticsUpdate(client, interaction.guild, radio);
|
client.statistics.update(client, interaction.guild, radio);
|
||||||
|
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
radio.station = station;
|
radio.station = station;
|
||||||
|
@ -21,7 +21,7 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!client.stations) {
|
if(!client.stations.list) {
|
||||||
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
|
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: client.messageEmojis["error"] + message.errorToGetPlaylist,
|
content: client.messageEmojis["error"] + message.errorToGetPlaylist,
|
||||||
@ -71,20 +71,20 @@ module.exports = {
|
|||||||
ephemeral: true
|
ephemeral: true
|
||||||
});
|
});
|
||||||
} else if (!isNaN(number)) {
|
} else if (!isNaN(number)) {
|
||||||
if (number > client.stations.length - 1) {
|
if (number > client.stations.list.length - 1) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: client.messageEmojis["error"] + client.messages.wrongStationNumber,
|
content: client.messageEmojis["error"] + client.messages.wrongStationNumber,
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
station = client.stations[number];
|
station = client.stations.list[number];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (query.length < 3) return interaction.reply({
|
if (query.length < 3) return interaction.reply({
|
||||||
content: client.messageEmojis["error"] + client.messages.tooShortSearch,
|
content: client.messageEmojis["error"] + client.messages.tooShortSearch,
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
});
|
});
|
||||||
const sstation = await client.funcs.searchStation(query, client);
|
const sstation = await client.stations.search(query, client);
|
||||||
if (!sstation) return interaction.reply({
|
if (!sstation) return interaction.reply({
|
||||||
content: client.messageEmojis["error"] + client.messages.noSearchResults,
|
content: client.messageEmojis["error"] + client.messages.noSearchResults,
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
@ -93,7 +93,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (radio) {
|
if (radio) {
|
||||||
client.funcs.statisticsUpdate(client, interaction.guild, radio);
|
client.statistics.update(client, interaction.guild, radio);
|
||||||
|
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
radio.station = station;
|
radio.station = station;
|
||||||
|
@ -6,17 +6,17 @@ module.exports = {
|
|||||||
if (client.funcs.check(client, interaction, command)) {
|
if (client.funcs.check(client, interaction, command)) {
|
||||||
const radio = client.radio.get(interaction.guild.id);
|
const radio = client.radio.get(interaction.guild.id);
|
||||||
|
|
||||||
let index = client.stations.findIndex(station => station.name == radio.station.name) - 1;
|
let index = client.stations.list.findIndex(station => station.name == radio.station.name) - 1;
|
||||||
if(index == -1) index = client.stations.length - 1;
|
if(index == -1) index = client.stations.list.length - 1;
|
||||||
|
|
||||||
let station = client.stations[index];
|
let station = client.stations.list[index];
|
||||||
|
|
||||||
if(!station) return interaction.reply({
|
if(!station) return interaction.reply({
|
||||||
content: client.messageEmojis["error"] + client.messages.noSearchResults,
|
content: client.messageEmojis["error"] + client.messages.noSearchResults,
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
});
|
});
|
||||||
|
|
||||||
client.funcs.statisticsUpdate(client, interaction.guild, radio);
|
client.statistics.update(client, interaction.guild, radio);
|
||||||
|
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
radio.station = station;
|
radio.station = station;
|
||||||
|
@ -7,12 +7,12 @@ module.exports = {
|
|||||||
category: 'info',
|
category: 'info',
|
||||||
execute(interaction, client) {
|
execute(interaction, client) {
|
||||||
let message = {};
|
let message = {};
|
||||||
let stations = client.stations;
|
let stations = client.stations.list;
|
||||||
let currentGuild = client.datastore.getEntry(interaction.guild.id);
|
let currentGuild = client.datastore.getEntry(interaction.guild.id);
|
||||||
let global = client.datastore.getEntry("global");
|
let global = client.datastore.getEntry("global");
|
||||||
let statistics = "";
|
let statistics = "";
|
||||||
|
|
||||||
if(!client.stations) {
|
if(!client.stations.list) {
|
||||||
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
|
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: client.messageEmojis["error"] + message.errorToGetPlaylist,
|
content: client.messageEmojis["error"] + message.errorToGetPlaylist,
|
||||||
|
@ -7,7 +7,7 @@ module.exports = {
|
|||||||
async execute(interaction, client, command) {
|
async execute(interaction, client, command) {
|
||||||
if (client.funcs.check(client, interaction, command)) {
|
if (client.funcs.check(client, interaction, command)) {
|
||||||
const radio = client.radio.get(interaction.guild.id);
|
const radio = client.radio.get(interaction.guild.id);
|
||||||
client.funcs.statisticsUpdate(client, interaction.guild, radio);
|
client.statistics.update(client, interaction.guild, radio);
|
||||||
radio.connection?.destroy();
|
radio.connection?.destroy();
|
||||||
client.funcs.logger('Radio', interaction.guild.id + " / " + 'Stop');
|
client.funcs.logger('Radio', interaction.guild.id + " / " + 'Stop');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user