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,8 +86,14 @@ 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 {
|
||||||
|
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);
|
const listed = await fileList(absolutePath);
|
||||||
|
|
||||||
if (discord) {
|
if (discord) {
|
||||||
|
@ -99,21 +105,17 @@ async function list(bot, discord, channeldc, prefix, selector) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let color = 'gold';
|
let primary = true;
|
||||||
const message = [];
|
const message = [];
|
||||||
|
|
||||||
listed.forEach((value) => {
|
for (const value of listed) {
|
||||||
if (color === 'gold') {
|
const isFile = (await fs.lstat(path.join(absolutePath, value))).isFile();
|
||||||
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}music play ${value}`,
|
value: `${prefix}music ${isFile ? 'play' : 'list'} ${path.join(args.slice(1).join(' '), value)}`,
|
||||||
},
|
},
|
||||||
hoverEvent: {
|
hoverEvent: {
|
||||||
action: 'show_text',
|
action: 'show_text',
|
||||||
|
@ -123,10 +125,14 @@ async function list(bot, discord, channeldc, prefix, selector) {
|
||||||
'\n',
|
'\n',
|
||||||
{text: 'Click here to suggest the command!', color: 'green'},
|
{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