This commit is contained in:
MatteZ02
2020-03-02 21:38:42 +02:00
commit a96305e807
29 changed files with 599 additions and 0 deletions

16
commands/bug.js Normal file
View File

@ -0,0 +1,16 @@
module.exports = {
name: 'bug',
alias: 'none',
usage: '',
description: 'Report a bug',
onlyDev: false,
permission: 'none',
category: 'info',
async execute(msg, args, client, Discord, prefix) {
const embed = new Discord.MessageEmbed()
.setTitle(`Found a bug with ${client.user.username}?\nDM the core developer:`)
.setDescription(`Matte#0002\nOr join the support server: https://discord.gg/rvHuJtB`)
.setColor(client.config.embedColor);
msg.channel.send(embed);
},
};

31
commands/cmduses.js Normal file
View File

@ -0,0 +1,31 @@
module.exports = {
name: 'cmduses',
alias: 'none',
usage: '',
description: 'list all commands and how many times they\'ve been used',
onlyDev: true,
permission: 'dev',
category: 'info',
async execute(msg, args, client, Discord) {
const cmduses = [];
client.commands.forEach((value, key) => {
cmduses.push([key, value.uses]);
});
cmduses.sort((a, b) => {
return b[1] - a[1];
});
const cmdnamelength = Math.max(...cmduses.map(x => x[0].length)) + 4;
const numberlength = Math.max(...cmduses.map(x => x[1].toString().length), 4);
const markdownrows = ['Command' + ' '.repeat(cmdnamelength - 'command'.length) + ' '.repeat(numberlength - 'uses'.length) + 'Uses'];
cmduses.forEach(x => {
if (x[1] > 0) markdownrows.push(x[0] + '.'.repeat(cmdnamelength - x[0].length) + ' '.repeat(numberlength - x[1].toString().length) + x[1].toString());
});
const embed = new Discord.MessageEmbed();
embed
.setTitle('Musix Command Usage During Current Uptime')
.setDescription('```ml\n' + markdownrows.join('\n') + '\n```')
.setFooter('These statistics are from the current uptime.')
.setColor(client.config.embedColor);
msg.channel.send(embed);
},
};

24
commands/eval.js Normal file
View File

@ -0,0 +1,24 @@
module.exports = {
name: 'eval',
alias: 'e',
usage: '<code>',
description: 'Evaluation command. DEV ONLY!',
onlyDev: true,
permission: 'dev',
category: 'util',
async execute(msg, args, client, Discord, prefix) {
const radio = client.radio.get(msg.guild.id);
const input = msg.content.slice(prefix.length + 4);
let output;
try {
output = await eval(input);
} catch (error) {
output = error.toString();
}
const embed = new Discord.MessageEmbed()
.setTitle('Evaluation Command')
.setColor(client.config.embedColor)
.setDescription(`Input: \`\`\`js\n${input.replace(/; /g, ';').replace(/;/g, ';\n')}\n\`\`\`\nOutput: \`\`\`\n${output}\n\`\`\``);
return msg.channel.send(embed);
},
};

36
commands/help.js Normal file
View File

@ -0,0 +1,36 @@
module.exports = {
name: 'help',
alias: 'h',
usage: '<command(opt)>',
description: 'See the help for RadioX.',
onlyDev: false,
permission: 'none',
category: 'info',
execute(msg, args, client, Discord, prefix, command) {
if (args[1]) {
if (!client.commands.has(args[1]) || (client.commands.has(args[1]) && client.commands.get(args[1]).omitFromHelp === true && msg.guild.id !== '489083836240494593')) return msg.channel.send('That command does not exist');
const command = client.commands.get(args[1]);
const embed = new Discord.MessageEmbed()
.setTitle(`${client.global.db.guilds[msg.guild.id].prefix}${command.name} ${command.usage}`)
.setDescription(command.description)
.setFooter(`Command Alias: \`${command.alias}\``)
.setColor(client.config.embedColor)
msg.channel.send(embed);
} else {
const categories = [];
for (let i = 0; i < client.commands.size; i++) {
if (!categories.includes(client.commands.array()[i].category)) categories.push(client.commands.array()[i].category);
}
let commands = '';
for (let i = 0; i < categories.length; i++) {
commands += `**» ${categories[i].toUpperCase()}**\n${client.commands.filter(x => x.category === categories[i] && !x.omitFromHelp && !x.onlyDev).map(x => `\`${x.name}\``).join(', ')}\n`;
}
const embed = new Discord.MessageEmbed()
.setTitle(`${client.user.username} help:`)
.setDescription(commands)
.setFooter(`"${client.config.prefix}help <command>" to see more information about a command.`)
.setColor(client.config.embedColor)
msg.channel.send(embed);
}
}
};

16
commands/invite.js Normal file
View File

@ -0,0 +1,16 @@
module.exports = {
name: 'invite',
alias: 'i',
usage: '',
description: 'Invite RadioX.',
onlyDev: false,
permission: 'none',
category: 'info',
execute(msg, args, client, Discord, prefix) {
const embed = new Discord.MessageEmbed()
.setTitle(`Invite ${client.user.username} to your Discord server!`)
.setURL(client.config.invite)
.setColor(client.config.embedColor)
return msg.channel.send(embed);
}
};

24
commands/join.js Normal file
View File

@ -0,0 +1,24 @@
module.exports = {
name: 'join',
alias: 'j',
usage: '',
description: 'Make Musix join the channel your channel',
onlyDev: true,
permission: 'none',
category: 'util',
async execute(msg, args, client, Discord, prefix) {
try {
const radio = client.radio.get(msg.guild.id);
const voiceChannel = msg.member.voice.channel;
const connection = await voiceChannel.join();
if (radio) {
radio.connection = connection;
}
msg.channel.send(`<:green_check_mark:674265384777416705> Joined ${voiceChannel.name}!`);
} catch (error) {
client.radio.delete(msg.guild.id);
client.channels.fetch(client.config.debug_channel).send("Error with connecting to voice channel: " + error);
return msg.channel.send(`<:redx:674263474704220182> An error occured: ${error}`);
}
}
};

25
commands/nowplaying.js Normal file
View File

@ -0,0 +1,25 @@
module.exports = {
name: 'nowplaying',
alias: 'np',
usage: '',
description: 'See the currently playing song position and length.',
onlyDev: false,
permission: 'none',
category: 'music',
async execute(msg, args, client, Discord, prefix) {
const radio = client.radio.get(msg.guild.id);
if (!radio) return msg.channel.send('<:redx:674263474704220182> There is nothing playing.');
if (!radio.playing) return msg.channel.send('<:redx:674263474704220182> There is nothing playing.');
radio.time = radio.connection.dispatcher.streamTime;
let completed = (radio.time.toFixed(0));
const embed = new Discord.MessageEmbed()
.setTitle("__Now playing__")
.setDescription(`<a:aNotes:674602408105476106>**Now playing:** ${radio.url}\n\`${client.funcs.msToTime(completed, "hh:mm:ss")}\``)
.setFooter(`Queued by ${radio.songs[0].author.tag}`)
.setURL(radio.songs[0].url)
.setThumbnail(thumbnail._rejectionHandler0)
.setColor(client.config.embedColor)
return msg.channel.send(embed);
}
};

18
commands/pause.js Normal file
View File

@ -0,0 +1,18 @@
module.exports = {
name: 'pause',
alias: 'none',
usage: '',
description: 'Pause the currently playing music.',
onlyDev: false,
permission: 'MANAGE_MESSAGES',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
const radio = client.radio.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
if (radio.paused) return msg.channel.send('<:redx:674263474704220182> The music is already paused!');
radio.paused = true;
radio.connection.dispatcher.pause(true);
return msg.channel.send('<:pause:674685548610322462> Paused the music!');
}
}
};

29
commands/play.js Normal file
View File

@ -0,0 +1,29 @@
module.exports = {
name: 'play',
alias: 'p',
usage: '<song name>',
description: 'Play some music.',
onlyDev: false,
permission: 'none',
category: 'music',
async execute(msg, args, client, Discord, prefix) {
const searchString = args.slice(1).join(" ");
const url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
const radio = client.radio.get(msg.guild.id);
const voiceChannel = msg.member.voice.channel;
if (!radio) {
if (!msg.member.voice.channel) return msg.channel.send('<:redx:674263474704220182> I\'m sorry but you need to be in a voice channel to play music!');
} else {
if (voiceChannel !== radio.voiceChannel) return msg.channel.send('<:redx:674263474704220182> I\'m sorry but you need to be in the same voice channel as Musix to play music!');
}
if (!args[1]) return msg.channel.send('<:redx:674263474704220182> You need to use a link or search for a song!');
const permissions = voiceChannel.permissionsFor(msg.client.user);
if (!permissions.has('CONNECT')) {
return msg.channel.send('<:redx:674263474704220182> I cannot connect to your voice channel, make sure I have the proper permissions!');
}
if (!permissions.has('SPEAK')) {
return msg.channel.send('<:redx:674263474704220182> I cannot speak in your voice channel, make sure I have the proper permissions!');
}
return client.funcs.handleRadio(msg, voiceChannel, client, url);
}
};

30
commands/reload.js Normal file
View File

@ -0,0 +1,30 @@
const fs = require('fs');
const path = require('path')
module.exports = {
name: 'reload',
alias: 'none',
usage: '',
description: 'Reload all files',
onlyDev: true,
permission: 'none',
category: 'util',
async execute(msg, args, client, Discord, prefix, command) {
const commandFiles = fs.readdirSync(path.join(path.dirname(__dirname), 'commands')).filter(f => f.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./${file}`);
command.uses = 0;
client.commands.set(command.name, command);
client.commandAliases.set(command.alias, command);
}
const settingFiles = fs.readdirSync(path.join(path.dirname(__dirname), 'commands/settings')).filter(f => f.endsWith('.js'));
for (const file of settingFiles) {
const option = require(`./settings/${file}`);
client.settingCmd.set(option.name, option);
}
/*fs.readdirSync(path.join(__dirname, 'funcs')).forEach(filename => {
this.funcs[filename.slice(0, -3)] = require(`../struct/funcs/${filename}`);
});*/
msg.channel.send('All files reloaded!');
}
};

14
commands/restart.js Normal file
View File

@ -0,0 +1,14 @@
module.exports = {
name: 'restart',
alias: 'none',
usage: '',
description: 'Restart the bot',
onlyDev: true,
permission: 'none',
category: 'util',
async execute(msg, args, client, Discord, prefix, command) {
client.destroy();
require('../index.js');
msg.channel.send('restarted!');
}
};

18
commands/resume.js Normal file
View File

@ -0,0 +1,18 @@
module.exports = {
name: 'resume',
alias: 'none',
usage: '',
description: 'Resume the paused music.',
onlyDev: false,
permission: 'MANAGE_MESSAGES',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
const radio = client.radio.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
if (!radio.paused) return msg.channel.send('<:redx:674263474704220182> The music in not paused!');
radio.paused = false;
radio.connection.dispatcher.resume(true);
return msg.channel.send('<:resume:674685585478254603> Resumed the music!');
}
}
};

18
commands/stop.js Normal file
View File

@ -0,0 +1,18 @@
module.exports = {
name: 'stop',
description: 'Stop command.',
alias: 'none',
usage: '',
onlyDev: false,
permission: 'MANAGE_CHANNELS',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
const radio = client.radio.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) {
radio.songs = [];
radio.looping = false;
radio.connection.dispatcher.end('Stopped');
msg.channel.send('<:stop:674685626108477519> Stopped the music!')
}
}
};

23
commands/volume.js Normal file
View File

@ -0,0 +1,23 @@
module.exports = {
name: 'volume',
description: 'Volume command.',
alias: 'none',
usage: '<volume>',
cooldown: 5,
onlyDev: false,
permission: 'MANAGE_MESSAGES',
category: 'music',
execute(msg, args, client, Discord, prefix, command) {
const radio = client.radio.get(msg.guild.id);
if (!args[1] && radio) return msg.channel.send(`:loud_sound: The current volume is: **${radio.volume}**`);
const volume = parseFloat(args[1]);
if (client.funcs.check(client, msg, command)) {
if (isNaN(volume)) return msg.channel.send('<:redx:674263474704220182> I\'m sorry, But you need to enter a valid __number__.');
if (volume > 100) return msg.channel.send('<:redx:674263474704220182> The max volume is `100`!');
if (volume < 0) return msg.channel.send('<:redx:674263474704220182> The volume needs to be a positive number!');
radio.volume = volume;
radio.connection.dispatcher.setVolume(volume / 5);
return msg.channel.send(`<:volumehigh:674685637626167307> I set the volume to: **${volume}**`);
}
}
};