Check client.stations exists in list, nowplaying and play commands.

This commit is contained in:
Christer Warén 2020-04-04 06:49:57 +03:00
parent 75ff8fa34b
commit e8080fb205
3 changed files with 14 additions and 1 deletions

View File

@ -6,6 +6,11 @@ module.exports = {
permission: 'none',
category: 'info',
execute(msg, args, client, Discord, command) {
let message = {};
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return msg.channel.send(client.messageEmojis["error"] + message.errorToGetPlaylist);
}
let stations = `${client.stations.map(s => `**#** ${s.name}`).join('\n')}`
const hashs = stations.split('**#**').length;
for (let i = 0; i < hashs; i++) {

View File

@ -9,6 +9,10 @@ module.exports = {
let message = {};
const radio = client.radio.get(msg.guild.id);
if (!radio) return msg.channel.send('There is nothing playing.');
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return msg.channel.send(client.messageEmojis["error"] + message.errorToGetPlaylist);
}
const completed = (radio.connection.dispatcher.streamTime.toFixed(0));
message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name);

View File

@ -6,6 +6,7 @@ module.exports = {
permission: 'none',
category: 'music',
async execute(msg, args, client, Discord, command) {
let message = {};
let url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
const radio = client.radio.get(msg.guild.id);
const voiceChannel = msg.member.voice.channel;
@ -14,7 +15,10 @@ module.exports = {
} else {
if (voiceChannel !== radio.voiceChannel) return msg.channel.send(client.messageEmojis["error"] + client.messages.wrongVoiceChannel);
}
if(!client.stations) return msg.channel.send(client.messageEmojis["error"] + client.messages.errorToGetPlaylist);
if(!client.stations) {
message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
return msg.channel.send(client.messageEmojis["error"] + message.errorToGetPlaylist);
}
if (!args[1]) return msg.channel.send(client.messages.noQuery);
const permissions = voiceChannel.permissionsFor(msg.client.user);
if (!permissions.has('CONNECT')) {