mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 18:54:55 -05:00
change list + list directory
This commit is contained in:
parent
a0e6c90ef3
commit
fbece8a406
2 changed files with 46 additions and 45 deletions
|
@ -11,18 +11,13 @@ module.exports = {
|
||||||
if (args[0]==='list') {
|
if (args[0]==='list') {
|
||||||
const listed = Object.keys(cows);
|
const listed = Object.keys(cows);
|
||||||
|
|
||||||
let color = 'gold';
|
let primary = true;
|
||||||
const message = [];
|
const message = [];
|
||||||
|
|
||||||
listed.forEach((value) => {
|
listed.forEach((value) => {
|
||||||
if (color === 'gold') {
|
|
||||||
color = 'yellow';
|
|
||||||
} else if (color === 'yellow') {
|
|
||||||
color = 'gold';
|
|
||||||
};
|
|
||||||
message.push({
|
message.push({
|
||||||
text: value + ' ',
|
text: value + ' ',
|
||||||
color,
|
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: 'suggest_command',
|
action: 'suggest_command',
|
||||||
value: `${prefix}cowsay ${value} `,
|
value: `${prefix}cowsay ${value} `,
|
||||||
|
|
|
@ -86,47 +86,53 @@ async function resolve(filepath) {
|
||||||
return filepath;
|
return filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function list(bot, discord, channeldc, prefix, selector) {
|
async function list(bot, discord, channeldc, prefix, selector, args) {
|
||||||
const absolutePath = await resolve(SONGS_PATH);
|
try {
|
||||||
const listed = await fileList(absolutePath);
|
let absolutePath;
|
||||||
|
if (args[1]) absolutePath = await resolve(path.join(SONGS_PATH, args.slice(1).join(' ')));
|
||||||
|
else absolutePath = await resolve(SONGS_PATH);
|
||||||
|
|
||||||
if (discord) {
|
if (!absolutePath.includes('midis')) throw new Error('bro trying to hack my server?!/1?!');
|
||||||
const Embed = new MessageEmbed()
|
|
||||||
.setColor('#FFFF00')
|
|
||||||
.setTitle('Songs')
|
|
||||||
.setDescription(listed.join(', '));
|
|
||||||
channeldc.send({embeds: [Embed]});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let color = 'gold';
|
const listed = await fileList(absolutePath);
|
||||||
const message = [];
|
|
||||||
|
|
||||||
listed.forEach((value) => {
|
if (discord) {
|
||||||
if (color === 'gold') {
|
const Embed = new MessageEmbed()
|
||||||
color = 'yellow';
|
.setColor('#FFFF00')
|
||||||
} else if (color === 'yellow') {
|
.setTitle('Songs')
|
||||||
color = 'gold';
|
.setDescription(listed.join(', '));
|
||||||
|
channeldc.send({embeds: [Embed]});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let primary = true;
|
||||||
|
const message = [];
|
||||||
|
|
||||||
|
for (const value of listed) {
|
||||||
|
const isFile = (await fs.lstat(path.join(absolutePath, value))).isFile();
|
||||||
|
message.push({
|
||||||
|
text: value + ' ',
|
||||||
|
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
|
||||||
|
clickEvent: {
|
||||||
|
action: 'suggest_command',
|
||||||
|
value: `${prefix}music ${isFile ? 'play' : 'list'} ${path.join(args.slice(1).join(' '), value)}`,
|
||||||
|
},
|
||||||
|
hoverEvent: {
|
||||||
|
action: 'show_text',
|
||||||
|
contents: [
|
||||||
|
{text: 'Name: ', color: 'white'},
|
||||||
|
{text: value, color: 'gold'},
|
||||||
|
'\n',
|
||||||
|
{text: 'Click here to suggest the command!', color: 'green'},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
message.push({
|
|
||||||
text: value + ' ',
|
|
||||||
color,
|
|
||||||
clickEvent: {
|
|
||||||
action: 'suggest_command',
|
|
||||||
value: `${prefix}music play ${value}`,
|
|
||||||
},
|
|
||||||
hoverEvent: {
|
|
||||||
action: 'show_text',
|
|
||||||
contents: [
|
|
||||||
{text: 'Name: ', color: 'white'},
|
|
||||||
{text: value, color: 'gold'},
|
|
||||||
'\n',
|
|
||||||
{text: 'Click here to suggest the command!', color: 'green'},
|
|
||||||
],
|
|
||||||
}});
|
|
||||||
});
|
|
||||||
|
|
||||||
bot.tellraw(selector, message);
|
bot.tellraw(selector, message);
|
||||||
|
} catch (e) {
|
||||||
|
bot.tellraw(selector, {text: e.toString(), color: 'red'});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -139,7 +145,7 @@ module.exports = {
|
||||||
'<playurl> <url>',
|
'<playurl> <url>',
|
||||||
'<stop>',
|
'<stop>',
|
||||||
'<loop> <all|current|off>',
|
'<loop> <all|current|off>',
|
||||||
'<list>',
|
'<list> [directory]',
|
||||||
'<skip>',
|
'<skip>',
|
||||||
'<nowplaying>',
|
'<nowplaying>',
|
||||||
'<queue>',
|
'<queue>',
|
||||||
|
@ -205,7 +211,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'list':
|
case 'list':
|
||||||
list(bot, false, null, prefix, selector);
|
list(bot, false, null, prefix, selector, args);
|
||||||
break;
|
break;
|
||||||
case 'nowplaying':
|
case 'nowplaying':
|
||||||
bot.tellraw(selector, [
|
bot.tellraw(selector, [
|
||||||
|
|
Loading…
Reference in a new issue