removed some unnecessary variables and general clean up

This commit is contained in:
MatteZ02
2020-03-22 17:10:46 +02:00
committed by Christer Warén
parent 093549770d
commit 011e221748
15 changed files with 42 additions and 59 deletions

View File

@ -5,13 +5,13 @@ module.exports = {
description: 'Report a bug',
permission: 'none',
category: 'info',
async execute(msg, args, client, Discord, prefix) {
async execute(msg, args, client, Discord, command) {
let message = {};
message.bugTitle = client.messages.bugTitle.replace("%client.user.username%", client.user.username);
message.bugDescription = client.messages.bugDescription.replace("%client.developers%", client.developers);
message.bugDescription = message.bugDescription.replace("%client.config.supportGuild%", client.config.supportGuild);
const embed = new Discord.MessageEmbed()
.setTitle(message.bugTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/686296221433725076.png")
@ -19,6 +19,6 @@ module.exports = {
.setDescription(message.bugDescription)
.setFooter('EximiaBots by Warén Media', 'https://cdn.discordapp.com/emojis/687022937978568760.png');
msg.channel.send(embed);
},
};

View File

@ -5,19 +5,19 @@ module.exports = {
description: 'See the help for RadioX.',
permission: 'none',
category: 'info',
execute(msg, args, client, Discord, prefix, command) {
execute(msg, args, client, Discord, command) {
let message = {};
if (args[1]) {
if (!client.commands.has(args[1]) || (client.commands.has(args[1]) && client.commands.get(args[1]).omitFromHelp === true)) return msg.channel.send('That command does not exist');
const command = client.commands.get(args[1]);
message.helpCommandTitle = client.messages.helpCommandTitle.replace("%client.config.prefix%", client.config.prefix);
message.helpCommandTitle = message.helpCommandTitle.replace("%command.name%", command.name);
message.helpCommandTitle = message.helpCommandTitle.replace("%command.usage%", command.usage);
message.helpCommandDescription = client.messages.helpCommandDescription.replace("%command.description%", command.description);
message.helpCommandDescription = message.helpCommandDescription.replace("%command.alias%", command.alias);
const embed = new Discord.MessageEmbed()
.setTitle(message.helpCommandTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/686296221433725076.png")
@ -34,11 +34,11 @@ module.exports = {
for (let i = 0; i < categories.length; i++) {
commands += `**» ${categories[i].toUpperCase()}**\n${client.commands.filter(x => x.category === categories[i] && !x.omitFromHelp).map(x => `\`${x.name}\``).join(', ')}\n`;
}
message.helpTitle = client.messages.helpTitle.replace("%client.user.username%", client.user.username);
message.helpDescription = client.messages.helpDescription.replace("%commands%", commands);
message.helpDescription = message.helpDescription.replace("%client.config.prefix%", client.config.prefix);
const embed = new Discord.MessageEmbed()
.setTitle(message.helpTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/686296221433725076.png")

View File

@ -5,7 +5,7 @@ module.exports = {
description: 'Invite RadioX.',
permission: 'none',
category: 'info',
execute(msg, args, client, Discord, prefix) {
execute(msg, args, client, Discord, command) {
let message = {};
message.inviteTitle = client.messages.inviteTitle.replace("%client.user.username%", client.user.username);
const embed = new Discord.MessageEmbed()

View File

@ -5,13 +5,13 @@ module.exports = {
description: 'List radio stations.',
permission: 'none',
category: 'info',
execute(msg, args, client, Discord, prefix) {
execute(msg, args, client, Discord, command) {
let stations = `${client.stations.map(s => `**#** ${s.name}`).join('\n')}`
const hashs = stations.split('**#**').length;
for (let i = 0; i < hashs; i++) {
stations = stations.replace('**#**', `**${i + 1}**`);
}
const embed = new Discord.MessageEmbed()
.setTitle(client.messages.listTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["list"].replace(/[^0-9]+/g, ''))

View File

@ -5,17 +5,16 @@ module.exports = {
description: 'See the currently playing song position and length.',
permission: 'none',
category: 'music',
async execute(msg, args, client, Discord, prefix) {
async execute(msg, args, client, Discord, command) {
let message = {};
const radio = client.radio.get(msg.guild.id);
if (!radio || !radio.playing) return msg.channel.send('There is nothing playing.');
radio.time = radio.connection.dispatcher.streamTime;
const completed = (radio.time.toFixed(0));
if (!radio) return msg.channel.send('There is nothing playing.');
const completed = (radio.connection.dispatcher.streamTime.toFixed(0));
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("%msToTime(completed, \"hh:mm:ss\")%", msToTime(completed, "hh:mm:ss"));
const embed = new Discord.MessageEmbed()
.setTitle(client.messages.nowplayingTitle)
.setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["play"].replace(/[^0-9]+/g, ''))

View File

@ -5,7 +5,7 @@ module.exports = {
description: 'Play some music.',
permission: 'none',
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") : "";
const radio = client.radio.get(msg.guild.id);
const voiceChannel = msg.member.voice.channel;
@ -44,7 +44,7 @@ module.exports = {
if (radio) {
radio.connection.dispatcher.destroy();
radio.station = station;
radio.textChannel = msg.channel;
radio.textChannel = msg.channel;
play(msg.guild, client, url);
return;
}
@ -53,10 +53,8 @@ module.exports = {
textChannel: msg.channel,
voiceChannel: voiceChannel,
connection: null,
playing: false,
station: station,
volume: client.config.volume,
time: null
volume: 5,
};
client.radio.set(msg.guild.id, construct);
@ -71,7 +69,7 @@ module.exports = {
}
};
function play(guild, client, url) {
let message = {};
let message = {};
const radio = client.radio.get(guild.id);
const dispatcher = radio.connection
@ -82,10 +80,6 @@ function play(guild, client, url) {
return;
});
dispatcher.on('start', () => {
dispatcher.player.streamingData.pausedTime = 0;
});
dispatcher.on('error', error => {
console.error(error);
radio.voiceChannel.leave();
@ -95,10 +89,8 @@ function play(guild, client, url) {
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.playing = true;
};
function searchStation(key, client) {

View File

@ -5,7 +5,7 @@ module.exports = {
usage: '',
permission: 'none',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
execute(msg, args, client, Discord, command) {
const radio = client.radio.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
radio.connection.dispatcher.destroy();

View File

@ -5,14 +5,14 @@ module.exports = {
usage: '<volume>',
permission: 'MANAGE_MESSAGES',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
let message = {};
execute(msg, args, client, Discord, command) {
let message = {};
const radio = client.radio.get(msg.guild.id);
if (!args[1] && radio) {
message.currentVolume = client.messages.currentVolume.replace("%radio.volume%", radio.volume)
return msg.channel.send(message.currentVolume);
}
message.currentVolume = client.messages.currentVolume.replace("%radio.volume%", radio.volume)
return msg.channel.send(message.currentVolume);
}
const volume = parseFloat(args[1]);
if (client.funcs.check(client, msg, command)) {
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);
radio.volume = volume;
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);
}
}