mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
use switch case
This commit is contained in:
parent
149fe83dc0
commit
74efceebc5
1 changed files with 143 additions and 118 deletions
|
@ -135,132 +135,157 @@ module.exports = {
|
|||
trusted: 0,
|
||||
usage: '<play|playurl|stop|loop|list|skip|loop|nowplaying|queue> <song|all|current|off>',
|
||||
execute: function(bot, username, usernameraw, sender, prefix, args) {
|
||||
if (args[0] === 'play') {
|
||||
play(bot, args.slice(1));
|
||||
} else if (args[0] === 'playurl') {
|
||||
playUrl(bot, args.slice(1));
|
||||
} else if (args[0] === 'stop') {
|
||||
try {
|
||||
bot.tellraw('@a', {text: 'Cleared the song queue'});
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
bot.music.stop();
|
||||
} else if (args[0] === 'skip') {
|
||||
try {
|
||||
bot.tellraw('@a', [{text: 'Skipping '}, {text: bot.music.song.name, color: 'gold'}]);
|
||||
bot.music.skip();
|
||||
} catch (e) {
|
||||
throw new Error('No music is currently playing!');
|
||||
}
|
||||
} else if (args[0] === 'loop') {
|
||||
if (args[1] === 'off') {
|
||||
bot.music.loop = 0;
|
||||
bot.tellraw('@a', [{text: 'Looping is now '}, {text: 'disabled', color: 'red'}]);
|
||||
} else if (args[1] === 'current') {
|
||||
bot.music.loop = 1;
|
||||
bot.tellraw('@a', [{text: 'Now Looping '}, {text: song.name, color: 'gold'}]);
|
||||
} else if (args[1] === 'all') {
|
||||
bot.music.loop = 2;
|
||||
bot.tellraw('@a', {text: 'Now looping every song in the queue'});
|
||||
} else {
|
||||
switch (args[0]) {
|
||||
case 'play':
|
||||
play(bot, args.slice(1));
|
||||
case 'playurl':
|
||||
playUrl(bot, args.slice(1));
|
||||
case 'stop':
|
||||
try {
|
||||
bot.tellraw('@a', {text: 'Cleared the song queue'});
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
bot.music.stop();
|
||||
case 'skip':
|
||||
try {
|
||||
bot.tellraw('@a', [{text: 'Skipping '}, {text: bot.music.song.name, color: 'gold'}]);
|
||||
bot.music.skip();
|
||||
} catch (e) {
|
||||
throw new Error('No music is currently playing!');
|
||||
}
|
||||
case 'loop':
|
||||
switch (args[1]) {
|
||||
case 'off':
|
||||
bot.music.loop = 0;
|
||||
bot.tellraw('@a', [
|
||||
{
|
||||
text: 'Looping is now ',
|
||||
},
|
||||
{
|
||||
text: 'disabled',
|
||||
color: 'red',
|
||||
},
|
||||
]);
|
||||
case 'current':
|
||||
bot.music.loop = 1;
|
||||
bot.tellraw('@a', [
|
||||
{
|
||||
text: 'Now Looping ',
|
||||
},
|
||||
{
|
||||
text: song.name,
|
||||
color: 'gold',
|
||||
},
|
||||
]);
|
||||
case 'all':
|
||||
bot.music.loop = 2;
|
||||
bot.tellraw('@a', {
|
||||
text: 'Now looping every song in the queue',
|
||||
});
|
||||
default:
|
||||
throw new SyntaxError('Invalid argument');
|
||||
}
|
||||
case 'list':
|
||||
list(bot, false, null, prefix);
|
||||
case 'nowplaying':
|
||||
bot.tellraw('@a', [
|
||||
{
|
||||
text: 'Now playing ',
|
||||
},
|
||||
{
|
||||
text: bot.music.song.name,
|
||||
color: 'gold',
|
||||
},
|
||||
]);
|
||||
case 'queue':
|
||||
const queueWithName = [];
|
||||
bot.music.queue.forEach((song) => queueWithName.push(song.name));
|
||||
bot.tellraw('@a', [
|
||||
{
|
||||
text: 'Queue: ',
|
||||
color: 'green',
|
||||
},
|
||||
{
|
||||
text: queueWithName.join(', '),
|
||||
color: 'aqua',
|
||||
},
|
||||
]);
|
||||
default:
|
||||
throw new SyntaxError('Invalid argument');
|
||||
}
|
||||
} else if (args[0] === 'list') {
|
||||
list(bot, false, null, prefix);
|
||||
} else if (args[0] === 'nowplaying') {
|
||||
bot.tellraw('@a', [
|
||||
{
|
||||
text: 'Now playing ',
|
||||
},
|
||||
{
|
||||
text: bot.music.song.name,
|
||||
color: 'gold',
|
||||
},
|
||||
]);
|
||||
} else if (args[0] === 'queue') {
|
||||
const queueWithName = [];
|
||||
bot.music.queue.forEach((song) => queueWithName.push(song.name));
|
||||
bot.tellraw('@a', [
|
||||
{
|
||||
text: 'Queue: ',
|
||||
color: 'green',
|
||||
},
|
||||
{
|
||||
text: queueWithName.join(', '),
|
||||
color: 'aqua',
|
||||
},
|
||||
]);
|
||||
} else {
|
||||
throw new SyntaxError('Invalid argument');
|
||||
}
|
||||
},
|
||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||
if (args[0] === 'play') {
|
||||
play(bot, args.slice(1), true, channeldc);
|
||||
}
|
||||
if (args[0] === 'playurl') {
|
||||
playUrl(bot, args.slice(1), true, channeldc);
|
||||
}
|
||||
if (args[0] === 'stop') {
|
||||
try {
|
||||
const Embed = new MessageEmbed()
|
||||
switch (args[0]) {
|
||||
case 'play':
|
||||
play(bot, args.slice(1), true, channeldc);
|
||||
case 'playurl':
|
||||
playUrl(bot, args.slice(1), true, channeldc);
|
||||
case 'stop':
|
||||
try {
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Stop')
|
||||
.setDescription('Cleared the song queue');
|
||||
channeldc.send({embeds: [Embed]});
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
bot.music.stop();
|
||||
case 'skip':
|
||||
try {
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Skip')
|
||||
.setDescription(`Skipping ${bot.music.song.name}`);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
bot.music.skip();
|
||||
} catch (e) {
|
||||
throw new Error('No music is currently playing!');
|
||||
}
|
||||
case 'loop':
|
||||
let Embed;
|
||||
switch (args[1]) {
|
||||
case 'off':
|
||||
bot.music.loop = 0;
|
||||
Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Loop')
|
||||
.setDescription('Looping is now disabled');
|
||||
channeldc.send({embeds: [Embed]});
|
||||
case 'current':
|
||||
bot.music.loop = 1;
|
||||
Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Loop')
|
||||
.setDescription(`Now looping ${song.name}`);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
case 'all':
|
||||
bot.music.loop = 2;
|
||||
Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Loop')
|
||||
.setDescription('Now looping every song in the queue');
|
||||
channeldc.send({embeds: [Embed]});
|
||||
}
|
||||
case 'list':
|
||||
list(bot, true, channeldc, prefix);
|
||||
case 'nowplaying':
|
||||
Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Stop')
|
||||
.setDescription('Cleared the song queue');
|
||||
.setTitle('Now playing')
|
||||
.setDescription(`Now playing ${bot.music.song.name}`);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
bot.music.stop();
|
||||
}
|
||||
if (args[0] === 'skip') {
|
||||
try {
|
||||
const Embed = new MessageEmbed()
|
||||
case 'queue':
|
||||
const queueWithName = [];
|
||||
bot.music.queue.forEach((song) => queueWithName.push(song.name));
|
||||
Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Skip')
|
||||
.setDescription(`Skipping ${bot.music.song.name}`);
|
||||
.setTitle('Queue')
|
||||
.setDescription(queueWithName.join(', '));
|
||||
channeldc.send({embeds: [Embed]});
|
||||
bot.music.skip();
|
||||
} catch (e) {
|
||||
throw new Error('No music is currently playing!');
|
||||
}
|
||||
}
|
||||
if (args[0] === 'loop') {
|
||||
if (args[1] === 'off') {
|
||||
bot.music.loop = 0;
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Loop')
|
||||
.setDescription('Looping is now disabled');
|
||||
channeldc.send({embeds: [Embed]});
|
||||
}
|
||||
if (args[1] === 'current') {
|
||||
bot.music.loop = 1;
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Loop')
|
||||
.setDescription(`Now looping ${song.name}`);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
}
|
||||
if (args[1] === 'all') {
|
||||
bot.music.loop = 2;
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Loop')
|
||||
.setDescription('Now looping every song in the queue');
|
||||
channeldc.send({embeds: [Embed]});
|
||||
}
|
||||
}
|
||||
if (args[0] === 'list') {
|
||||
list(bot, true, channeldc, prefix);
|
||||
}
|
||||
if (args[0] === 'nowplaying') {
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Now playing')
|
||||
.setDescription(`Now playing ${bot.music.song.name}`);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
default:
|
||||
throw new SyntaxError('Invalid argument');
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue