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,7 +5,7 @@ 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);

View File

@ -5,7 +5,7 @@ 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]) {

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,7 +5,7 @@ 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++) {

View File

@ -5,12 +5,11 @@ 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);

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;
@ -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);
@ -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();
@ -97,8 +91,6 @@ function play(guild, client, url) {
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,7 +5,7 @@ module.exports = {
usage: '<volume>',
permission: 'MANAGE_MESSAGES',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
execute(msg, args, client, Discord, command) {
let message = {};
const radio = client.radio.get(msg.guild.id);

View File

@ -18,6 +18,5 @@ module.exports = {
//Settings
prefix: process.env.PREFIX || "rx>",
volume: 5
}

View File

@ -7,13 +7,13 @@ module.exports = {
if (!msg.content.startsWith(prefix)) return;
if (!args[0]) return;
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);
if (!command && msg.content !== `${prefix}`) return;
const permissions = msg.channel.permissionsFor(msg.client.user);
if (!permissions.has('EMBED_LINKS')) return msg.channel.send(client.messages.noPermsEmbed);
try {
command.uses++;
command.execute(msg, args, client, Discord, prefix, command);
command.execute(msg, args, client, Discord, command);
} catch (error) {
msg.reply(client.messages.runningCommandFailed);
console.error(error);

View File

@ -32,6 +32,6 @@ module.exports = {
.then(res => res.json());
}, 3600000);
require(`../struct/emojis.js`).execute(client, Discord);
require(`../struct/emojis.js`).execute(client);
}
}

View File

@ -7,8 +7,6 @@ module.exports = {
if (!radio) return;
if (newState.member.id === client.user.id && oldState.member.id === client.user.id) {
if (newState.channel === null) {
radio.songs = [];
radio.looping = false;
return client.radio.delete(newState.guild.id);
}
@ -18,8 +16,6 @@ module.exports = {
const connection = await oldState.channel.join();
return radio.connection = connection;
} catch (error) {
radio.songs = [];
radio.looping = false;
radio.connection.dispatcher.destroy();
radio.voiceChannel.leave();
client.radio.delete(msg.guild.id);
@ -36,8 +32,6 @@ module.exports = {
setTimeout(() => {
if (!radio) return;
if (radio.voiceChannel.members.size === 1) {
radio.songs = [];
radio.looping = false;
radio.connection.dispatcher.destroy();
radio.voiceChannel.leave();
client.radio.delete(newState.guild.id);

View File

@ -2,7 +2,7 @@ module.exports = function (client, msg, command) {
let message = {};
const radio = client.radio.get(msg.guild.id);
const permissions = msg.channel.permissionsFor(msg.author);
if (!radio || !radio.playing){
if (!radio) {
msg.channel.send(client.messageEmojis["x"] + client.messages.notPlaying);
return false;
}

View File

@ -14,7 +14,6 @@ module.exports = class extends Client {
this.commandAliases = new Collection();
this.radio = new Map();
this.funcs = {};
this.dispatcher = {};
this.config = require('../config.js');
this.messages = require('./messages.js');
this.funcs.check = require('./check.js');

View File

@ -1,6 +1,6 @@
module.exports = {
name: 'emojis',
async execute(client, Discord) {
async execute(client) {
let customEmojis = {
list: "<:RadioXList:688541155519889482>",
play: "<:RadioXPlay:688541155712827458>",