mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44: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') {
|
||||
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,47 +86,53 @@ async function resolve(filepath) {
|
|||
return filepath;
|
||||
}
|
||||
|
||||
async function list(bot, discord, channeldc, prefix, selector) {
|
||||
const absolutePath = await resolve(SONGS_PATH);
|
||||
const listed = await fileList(absolutePath);
|
||||
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 (discord) {
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Songs')
|
||||
.setDescription(listed.join(', '));
|
||||
channeldc.send({embeds: [Embed]});
|
||||
return;
|
||||
}
|
||||
if (!absolutePath.includes('midis')) throw new Error('bro trying to hack my server?!/1?!');
|
||||
|
||||
let color = 'gold';
|
||||
const message = [];
|
||||
const listed = await fileList(absolutePath);
|
||||
|
||||
listed.forEach((value) => {
|
||||
if (color === 'gold') {
|
||||
color = 'yellow';
|
||||
} else if (color === 'yellow') {
|
||||
color = 'gold';
|
||||
if (discord) {
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Songs')
|
||||
.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 = {
|
||||
|
@ -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