mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 18:54: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,
|
trusted: 0,
|
||||||
usage: '<play|playurl|stop|loop|list|skip|loop|nowplaying|queue> <song|all|current|off>',
|
usage: '<play|playurl|stop|loop|list|skip|loop|nowplaying|queue> <song|all|current|off>',
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args) {
|
execute: function(bot, username, usernameraw, sender, prefix, args) {
|
||||||
if (args[0] === 'play') {
|
switch (args[0]) {
|
||||||
play(bot, args.slice(1));
|
case 'play':
|
||||||
} else if (args[0] === 'playurl') {
|
play(bot, args.slice(1));
|
||||||
playUrl(bot, args.slice(1));
|
case 'playurl':
|
||||||
} else if (args[0] === 'stop') {
|
playUrl(bot, args.slice(1));
|
||||||
try {
|
case 'stop':
|
||||||
bot.tellraw('@a', {text: 'Cleared the song queue'});
|
try {
|
||||||
} catch (e) {
|
bot.tellraw('@a', {text: 'Cleared the song queue'});
|
||||||
return;
|
} catch (e) {
|
||||||
}
|
return;
|
||||||
bot.music.stop();
|
}
|
||||||
} else if (args[0] === 'skip') {
|
bot.music.stop();
|
||||||
try {
|
case 'skip':
|
||||||
bot.tellraw('@a', [{text: 'Skipping '}, {text: bot.music.song.name, color: 'gold'}]);
|
try {
|
||||||
bot.music.skip();
|
bot.tellraw('@a', [{text: 'Skipping '}, {text: bot.music.song.name, color: 'gold'}]);
|
||||||
} catch (e) {
|
bot.music.skip();
|
||||||
throw new Error('No music is currently playing!');
|
} catch (e) {
|
||||||
}
|
throw new Error('No music is currently playing!');
|
||||||
} else if (args[0] === 'loop') {
|
}
|
||||||
if (args[1] === 'off') {
|
case 'loop':
|
||||||
bot.music.loop = 0;
|
switch (args[1]) {
|
||||||
bot.tellraw('@a', [{text: 'Looping is now '}, {text: 'disabled', color: 'red'}]);
|
case 'off':
|
||||||
} else if (args[1] === 'current') {
|
bot.music.loop = 0;
|
||||||
bot.music.loop = 1;
|
bot.tellraw('@a', [
|
||||||
bot.tellraw('@a', [{text: 'Now Looping '}, {text: song.name, color: 'gold'}]);
|
{
|
||||||
} else if (args[1] === 'all') {
|
text: 'Looping is now ',
|
||||||
bot.music.loop = 2;
|
},
|
||||||
bot.tellraw('@a', {text: 'Now looping every song in the queue'});
|
{
|
||||||
} else {
|
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');
|
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) {
|
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||||
if (args[0] === 'play') {
|
switch (args[0]) {
|
||||||
play(bot, args.slice(1), true, channeldc);
|
case 'play':
|
||||||
}
|
play(bot, args.slice(1), true, channeldc);
|
||||||
if (args[0] === 'playurl') {
|
case 'playurl':
|
||||||
playUrl(bot, args.slice(1), true, channeldc);
|
playUrl(bot, args.slice(1), true, channeldc);
|
||||||
}
|
case 'stop':
|
||||||
if (args[0] === 'stop') {
|
try {
|
||||||
try {
|
const Embed = new MessageEmbed()
|
||||||
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')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Stop')
|
.setTitle('Now playing')
|
||||||
.setDescription('Cleared the song queue');
|
.setDescription(`Now playing ${bot.music.song.name}`);
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({embeds: [Embed]});
|
||||||
} catch (e) {
|
case 'queue':
|
||||||
return;
|
const queueWithName = [];
|
||||||
}
|
bot.music.queue.forEach((song) => queueWithName.push(song.name));
|
||||||
bot.music.stop();
|
Embed = new MessageEmbed()
|
||||||
}
|
|
||||||
if (args[0] === 'skip') {
|
|
||||||
try {
|
|
||||||
const Embed = new MessageEmbed()
|
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Skip')
|
.setTitle('Queue')
|
||||||
.setDescription(`Skipping ${bot.music.song.name}`);
|
.setDescription(queueWithName.join(', '));
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({embeds: [Embed]});
|
||||||
bot.music.skip();
|
default:
|
||||||
} catch (e) {
|
throw new SyntaxError('Invalid argument');
|
||||||
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]});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue