mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-23 03:13:20 +00:00
removed some unnecessary variables and general clean up
This commit is contained in:
parent
093549770d
commit
011e221748
@ -5,7 +5,7 @@ module.exports = {
|
|||||||
description: 'Report a bug',
|
description: 'Report a bug',
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'info',
|
category: 'info',
|
||||||
async execute(msg, args, client, Discord, prefix) {
|
async execute(msg, args, client, Discord, command) {
|
||||||
let message = {};
|
let message = {};
|
||||||
|
|
||||||
message.bugTitle = client.messages.bugTitle.replace("%client.user.username%", client.user.username);
|
message.bugTitle = client.messages.bugTitle.replace("%client.user.username%", client.user.username);
|
||||||
|
@ -5,7 +5,7 @@ module.exports = {
|
|||||||
description: 'See the help for RadioX.',
|
description: 'See the help for RadioX.',
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'info',
|
category: 'info',
|
||||||
execute(msg, args, client, Discord, prefix, command) {
|
execute(msg, args, client, Discord, command) {
|
||||||
let message = {};
|
let message = {};
|
||||||
|
|
||||||
if (args[1]) {
|
if (args[1]) {
|
||||||
|
@ -5,7 +5,7 @@ module.exports = {
|
|||||||
description: 'Invite RadioX.',
|
description: 'Invite RadioX.',
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'info',
|
category: 'info',
|
||||||
execute(msg, args, client, Discord, prefix) {
|
execute(msg, args, client, Discord, command) {
|
||||||
let message = {};
|
let message = {};
|
||||||
message.inviteTitle = client.messages.inviteTitle.replace("%client.user.username%", client.user.username);
|
message.inviteTitle = client.messages.inviteTitle.replace("%client.user.username%", client.user.username);
|
||||||
const embed = new Discord.MessageEmbed()
|
const embed = new Discord.MessageEmbed()
|
||||||
|
@ -5,7 +5,7 @@ module.exports = {
|
|||||||
description: 'List radio stations.',
|
description: 'List radio stations.',
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'info',
|
category: 'info',
|
||||||
execute(msg, args, client, Discord, prefix) {
|
execute(msg, args, client, Discord, command) {
|
||||||
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;
|
||||||
for (let i = 0; i < hashs; i++) {
|
for (let i = 0; i < hashs; i++) {
|
||||||
|
@ -5,12 +5,11 @@ module.exports = {
|
|||||||
description: 'See the currently playing song position and length.',
|
description: 'See the currently playing song position and length.',
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
async execute(msg, args, client, Discord, prefix) {
|
async execute(msg, args, client, Discord, command) {
|
||||||
let message = {};
|
let message = {};
|
||||||
const radio = client.radio.get(msg.guild.id);
|
const radio = client.radio.get(msg.guild.id);
|
||||||
if (!radio || !radio.playing) return msg.channel.send('There is nothing playing.');
|
if (!radio) return msg.channel.send('There is nothing playing.');
|
||||||
radio.time = radio.connection.dispatcher.streamTime;
|
const completed = (radio.connection.dispatcher.streamTime.toFixed(0));
|
||||||
const completed = (radio.time.toFixed(0));
|
|
||||||
|
|
||||||
message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name);
|
message.nowplayingDescription = client.messages.nowplayingDescription.replace("%radio.station.name%", radio.station.name);
|
||||||
message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.owner);
|
message.nowplayingDescription = message.nowplayingDescription.replace("%radio.station.owner%", radio.station.owner);
|
||||||
|
@ -5,7 +5,7 @@ module.exports = {
|
|||||||
description: 'Play some music.',
|
description: 'Play some music.',
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
async execute(msg, args, client, Discord, prefix) {
|
async execute(msg, args, client, Discord, command) {
|
||||||
let url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
|
let url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
|
||||||
const radio = client.radio.get(msg.guild.id);
|
const radio = client.radio.get(msg.guild.id);
|
||||||
const voiceChannel = msg.member.voice.channel;
|
const voiceChannel = msg.member.voice.channel;
|
||||||
@ -44,7 +44,7 @@ module.exports = {
|
|||||||
if (radio) {
|
if (radio) {
|
||||||
radio.connection.dispatcher.destroy();
|
radio.connection.dispatcher.destroy();
|
||||||
radio.station = station;
|
radio.station = station;
|
||||||
radio.textChannel = msg.channel;
|
radio.textChannel = msg.channel;
|
||||||
play(msg.guild, client, url);
|
play(msg.guild, client, url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -53,10 +53,8 @@ module.exports = {
|
|||||||
textChannel: msg.channel,
|
textChannel: msg.channel,
|
||||||
voiceChannel: voiceChannel,
|
voiceChannel: voiceChannel,
|
||||||
connection: null,
|
connection: null,
|
||||||
playing: false,
|
|
||||||
station: station,
|
station: station,
|
||||||
volume: client.config.volume,
|
volume: 5,
|
||||||
time: null
|
|
||||||
};
|
};
|
||||||
client.radio.set(msg.guild.id, construct);
|
client.radio.set(msg.guild.id, construct);
|
||||||
|
|
||||||
@ -71,7 +69,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
function play(guild, client, url) {
|
function play(guild, client, url) {
|
||||||
let message = {};
|
let message = {};
|
||||||
const radio = client.radio.get(guild.id);
|
const radio = client.radio.get(guild.id);
|
||||||
|
|
||||||
const dispatcher = radio.connection
|
const dispatcher = radio.connection
|
||||||
@ -82,10 +80,6 @@ function play(guild, client, url) {
|
|||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
dispatcher.on('start', () => {
|
|
||||||
dispatcher.player.streamingData.pausedTime = 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
dispatcher.on('error', error => {
|
dispatcher.on('error', error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
radio.voiceChannel.leave();
|
radio.voiceChannel.leave();
|
||||||
@ -95,10 +89,8 @@ function play(guild, client, url) {
|
|||||||
|
|
||||||
dispatcher.setVolume(radio.volume / 10);
|
dispatcher.setVolume(radio.volume / 10);
|
||||||
|
|
||||||
message.play = client.messages.play.replace("%radio.station.name%", radio.station.name);
|
message.play = client.messages.play.replace("%radio.station.name%", radio.station.name);
|
||||||
radio.textChannel.send(client.messageEmojis["play"] + message.play);
|
radio.textChannel.send(client.messageEmojis["play"] + message.play);
|
||||||
radio.playing = true;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function searchStation(key, client) {
|
function searchStation(key, client) {
|
||||||
|
@ -5,7 +5,7 @@ module.exports = {
|
|||||||
usage: '',
|
usage: '',
|
||||||
permission: 'none',
|
permission: 'none',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
execute(msg, args, client, Discord, prefix, command) {
|
execute(msg, args, client, Discord, command) {
|
||||||
const radio = client.radio.get(msg.guild.id);
|
const radio = client.radio.get(msg.guild.id);
|
||||||
if (client.funcs.check(client, msg, command)) {
|
if (client.funcs.check(client, msg, command)) {
|
||||||
radio.connection.dispatcher.destroy();
|
radio.connection.dispatcher.destroy();
|
||||||
|
@ -5,14 +5,14 @@ module.exports = {
|
|||||||
usage: '<volume>',
|
usage: '<volume>',
|
||||||
permission: 'MANAGE_MESSAGES',
|
permission: 'MANAGE_MESSAGES',
|
||||||
category: 'music',
|
category: 'music',
|
||||||
execute(msg, args, client, Discord, prefix, command) {
|
execute(msg, args, client, Discord, command) {
|
||||||
let message = {};
|
let message = {};
|
||||||
const radio = client.radio.get(msg.guild.id);
|
const radio = client.radio.get(msg.guild.id);
|
||||||
|
|
||||||
if (!args[1] && radio) {
|
if (!args[1] && radio) {
|
||||||
message.currentVolume = client.messages.currentVolume.replace("%radio.volume%", radio.volume)
|
message.currentVolume = client.messages.currentVolume.replace("%radio.volume%", radio.volume)
|
||||||
return msg.channel.send(message.currentVolume);
|
return msg.channel.send(message.currentVolume);
|
||||||
}
|
}
|
||||||
const volume = parseFloat(args[1]);
|
const volume = parseFloat(args[1]);
|
||||||
if (client.funcs.check(client, msg, command)) {
|
if (client.funcs.check(client, msg, command)) {
|
||||||
if (isNaN(volume)) return msg.channel.send(client.messages.invalidVolume);
|
if (isNaN(volume)) return msg.channel.send(client.messages.invalidVolume);
|
||||||
@ -20,7 +20,7 @@ module.exports = {
|
|||||||
if (volume < 0) return msg.channel.send(client.messages.negativeVolume);
|
if (volume < 0) return msg.channel.send(client.messages.negativeVolume);
|
||||||
radio.volume = volume;
|
radio.volume = volume;
|
||||||
radio.connection.dispatcher.setVolume(volume / 5);
|
radio.connection.dispatcher.setVolume(volume / 5);
|
||||||
message.newVolume = client.messages.newVolume.replace("%volume%", volume);
|
message.newVolume = client.messages.newVolume.replace("%volume%", volume);
|
||||||
return msg.channel.send(message.newVolume);
|
return msg.channel.send(message.newVolume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,5 @@ module.exports = {
|
|||||||
|
|
||||||
//Settings
|
//Settings
|
||||||
prefix: process.env.PREFIX || "rx>",
|
prefix: process.env.PREFIX || "rx>",
|
||||||
volume: 5
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,13 @@ module.exports = {
|
|||||||
if (!msg.content.startsWith(prefix)) return;
|
if (!msg.content.startsWith(prefix)) return;
|
||||||
if (!args[0]) return;
|
if (!args[0]) return;
|
||||||
const commandName = args[0].toLowerCase();
|
const commandName = args[0].toLowerCase();
|
||||||
|
if (commandName === 'none') return;
|
||||||
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName);
|
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName);
|
||||||
if (!command && msg.content !== `${prefix}`) return;
|
if (!command && msg.content !== `${prefix}`) return;
|
||||||
const permissions = msg.channel.permissionsFor(msg.client.user);
|
const permissions = msg.channel.permissionsFor(msg.client.user);
|
||||||
if (!permissions.has('EMBED_LINKS')) return msg.channel.send(client.messages.noPermsEmbed);
|
if (!permissions.has('EMBED_LINKS')) return msg.channel.send(client.messages.noPermsEmbed);
|
||||||
try {
|
try {
|
||||||
command.uses++;
|
command.execute(msg, args, client, Discord, command);
|
||||||
command.execute(msg, args, client, Discord, prefix, command);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
msg.reply(client.messages.runningCommandFailed);
|
msg.reply(client.messages.runningCommandFailed);
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
@ -32,6 +32,6 @@ module.exports = {
|
|||||||
.then(res => res.json());
|
.then(res => res.json());
|
||||||
}, 3600000);
|
}, 3600000);
|
||||||
|
|
||||||
require(`../struct/emojis.js`).execute(client, Discord);
|
require(`../struct/emojis.js`).execute(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,8 +7,6 @@ module.exports = {
|
|||||||
if (!radio) return;
|
if (!radio) return;
|
||||||
if (newState.member.id === client.user.id && oldState.member.id === client.user.id) {
|
if (newState.member.id === client.user.id && oldState.member.id === client.user.id) {
|
||||||
if (newState.channel === null) {
|
if (newState.channel === null) {
|
||||||
radio.songs = [];
|
|
||||||
radio.looping = false;
|
|
||||||
return client.radio.delete(newState.guild.id);
|
return client.radio.delete(newState.guild.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,8 +16,6 @@ module.exports = {
|
|||||||
const connection = await oldState.channel.join();
|
const connection = await oldState.channel.join();
|
||||||
return radio.connection = connection;
|
return radio.connection = connection;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
radio.songs = [];
|
|
||||||
radio.looping = false;
|
|
||||||
radio.connection.dispatcher.destroy();
|
radio.connection.dispatcher.destroy();
|
||||||
radio.voiceChannel.leave();
|
radio.voiceChannel.leave();
|
||||||
client.radio.delete(msg.guild.id);
|
client.radio.delete(msg.guild.id);
|
||||||
@ -36,8 +32,6 @@ module.exports = {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!radio) return;
|
if (!radio) return;
|
||||||
if (radio.voiceChannel.members.size === 1) {
|
if (radio.voiceChannel.members.size === 1) {
|
||||||
radio.songs = [];
|
|
||||||
radio.looping = false;
|
|
||||||
radio.connection.dispatcher.destroy();
|
radio.connection.dispatcher.destroy();
|
||||||
radio.voiceChannel.leave();
|
radio.voiceChannel.leave();
|
||||||
client.radio.delete(newState.guild.id);
|
client.radio.delete(newState.guild.id);
|
||||||
|
@ -2,11 +2,11 @@ module.exports = function (client, msg, command) {
|
|||||||
let message = {};
|
let message = {};
|
||||||
const radio = client.radio.get(msg.guild.id);
|
const radio = client.radio.get(msg.guild.id);
|
||||||
const permissions = msg.channel.permissionsFor(msg.author);
|
const permissions = msg.channel.permissionsFor(msg.author);
|
||||||
if (!radio || !radio.playing){
|
if (!radio) {
|
||||||
msg.channel.send(client.messageEmojis["x"] + client.messages.notPlaying);
|
msg.channel.send(client.messageEmojis["x"] + client.messages.notPlaying);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (msg.member.voice.channel !== radio.voiceChannel){
|
if (msg.member.voice.channel !== radio.voiceChannel) {
|
||||||
msg.channel.send(client.messageEmojis["x"] + client.messages.wrongVoiceChannel);
|
msg.channel.send(client.messageEmojis["x"] + client.messages.wrongVoiceChannel);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ module.exports = class extends Client {
|
|||||||
this.commandAliases = new Collection();
|
this.commandAliases = new Collection();
|
||||||
this.radio = new Map();
|
this.radio = new Map();
|
||||||
this.funcs = {};
|
this.funcs = {};
|
||||||
this.dispatcher = {};
|
|
||||||
this.config = require('../config.js');
|
this.config = require('../config.js');
|
||||||
this.messages = require('./messages.js');
|
this.messages = require('./messages.js');
|
||||||
this.funcs.check = require('./check.js');
|
this.funcs.check = require('./check.js');
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'emojis',
|
name: 'emojis',
|
||||||
async execute(client, Discord) {
|
async execute(client) {
|
||||||
let customEmojis = {
|
let customEmojis = {
|
||||||
list: "<:RadioXList:688541155519889482>",
|
list: "<:RadioXList:688541155519889482>",
|
||||||
play: "<:RadioXPlay:688541155712827458>",
|
play: "<:RadioXPlay:688541155712827458>",
|
||||||
@ -17,10 +17,10 @@ module.exports = {
|
|||||||
|
|
||||||
client.messageEmojis = {};
|
client.messageEmojis = {};
|
||||||
|
|
||||||
for(customEmojiName in customEmojis){
|
for (customEmojiName in customEmojis) {
|
||||||
customEmojiID = customEmojis[customEmojiName].replace(/[^0-9]+/g, '');
|
customEmojiID = customEmojis[customEmojiName].replace(/[^0-9]+/g, '');
|
||||||
customEmoji = client.emojis.cache.get(customEmojiID);
|
customEmoji = client.emojis.cache.get(customEmojiID);
|
||||||
if(customEmoji){
|
if (customEmoji) {
|
||||||
client.messageEmojis[customEmojiName] = customEmojis[customEmojiName];
|
client.messageEmojis[customEmojiName] = customEmojis[customEmojiName];
|
||||||
} else {
|
} else {
|
||||||
client.messageEmojis[customEmojiName] = fallbackEmojis[customEmojiName];
|
client.messageEmojis[customEmojiName] = fallbackEmojis[customEmojiName];
|
||||||
|
Loading…
Reference in New Issue
Block a user