mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-27 09:35:35 -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') {
|
||||
const listed = Object.keys(cows);
|
||||
|
||||
let color = 'gold';
|
||||
let primary = true;
|
||||
const message = [];
|
||||
|
||||
listed.forEach((value) => {
|
||||
if (color === 'gold') {
|
||||
color = 'yellow';
|
||||
} else if (color === 'yellow') {
|
||||
color = 'gold';
|
||||
};
|
||||
message.push({
|
||||
text: value + ' ',
|
||||
color,
|
||||
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
|
||||
clickEvent: {
|
||||
action: 'suggest_command',
|
||||
value: `${prefix}cowsay ${value} `,
|
||||
|
|
|
@ -86,8 +86,14 @@ async function resolve(filepath) {
|
|||
return filepath;
|
||||
}
|
||||
|
||||
async function list(bot, discord, channeldc, prefix, selector) {
|
||||
const absolutePath = await resolve(SONGS_PATH);
|
||||
async function list(bot, discord, channeldc, prefix, selector, args) {
|
||||
try {
|
||||
let absolutePath;
|
||||
if (args[1]) absolutePath = await resolve(path.join(SONGS_PATH, args.slice(1).join(' ')));
|
||||
else absolutePath = await resolve(SONGS_PATH);
|
||||
|
||||
if (!absolutePath.includes('midis')) throw new Error('bro trying to hack my server?!/1?!');
|
||||
|
||||
const listed = await fileList(absolutePath);
|
||||
|
||||
if (discord) {
|
||||
|
@ -99,21 +105,17 @@ async function list(bot, discord, channeldc, prefix, selector) {
|
|||
return;
|
||||
}
|
||||
|
||||
let color = 'gold';
|
||||
let primary = true;
|
||||
const message = [];
|
||||
|
||||
listed.forEach((value) => {
|
||||
if (color === 'gold') {
|
||||
color = 'yellow';
|
||||
} else if (color === 'yellow') {
|
||||
color = 'gold';
|
||||
};
|
||||
for (const value of listed) {
|
||||
const isFile = (await fs.lstat(path.join(absolutePath, value))).isFile();
|
||||
message.push({
|
||||
text: value + ' ',
|
||||
color,
|
||||
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
|
||||
clickEvent: {
|
||||
action: 'suggest_command',
|
||||
value: `${prefix}music play ${value}`,
|
||||
value: `${prefix}music ${isFile ? 'play' : 'list'} ${path.join(args.slice(1).join(' '), value)}`,
|
||||
},
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
|
@ -123,10 +125,14 @@ async function list(bot, discord, channeldc, prefix, selector) {
|
|||
'\n',
|
||||
{text: 'Click here to suggest the command!', color: 'green'},
|
||||
],
|
||||
}});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
bot.tellraw(selector, message);
|
||||
} catch (e) {
|
||||
bot.tellraw(selector, {text: e.toString(), color: 'red'});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -139,7 +145,7 @@ module.exports = {
|
|||
'<playurl> <url>',
|
||||
'<stop>',
|
||||
'<loop> <all|current|off>',
|
||||
'<list>',
|
||||
'<list> [directory]',
|
||||
'<skip>',
|
||||
'<nowplaying>',
|
||||
'<queue>',
|
||||
|
@ -205,7 +211,7 @@ module.exports = {
|
|||
}
|
||||
break;
|
||||
case 'list':
|
||||
list(bot, false, null, prefix, selector);
|
||||
list(bot, false, null, prefix, selector, args);
|
||||
break;
|
||||
case 'nowplaying':
|
||||
bot.tellraw(selector, [
|
||||
|
|
Loading…
Reference in a new issue