guillaumearnx
Member
Hello, I want to create a random command with SinusBot
I've tried differents methods but none works
Error for random1 is :
2020-05-16T21:16:04+02:00 [ command:41:14] TypeError: Cannot read property 'play' of undefined at command.createCommand.help.manual.checkPermission.exec (sinusbot-commands:408:69)
2020-05-16T21:16:04+02:00 [ command:41:14] This is _probably_ an Error with a Script which is using command.js!
2020-05-16T21:16:04+02:00 [ command:41:14] guillaumearnx (689576146765086830/629786143906594828) used $random
Error for random2 is :
2020-05-16T21:16:08+02:00 [ command:41:14] guillaumearnx (689576146765086830/629786143906594828) used $random2
I've tried differents methods but none works
JavaScript:
command.createCommand('random')
.help('Play a random track')
.manual('Play a random track.')
.checkPermission(requirePrivileges(PLAYBACK))
.exec((client, args, reply, ev) => {
var musicos = media.getTracks();
var indexation = require('helpers').getRandom(musicos.length);
let track = media.getTrackByID(musicos[indexation].uuid).play();
reply(`Playing ${formatTrack(track)}`);
successReaction(ev, reply);
});
command.createCommand('random2')
.help('Play a random track')
.manual('Play a random track.')
.checkPermission(requirePrivileges(PLAYBACK))
.exec((client, args, reply, ev) => {
var tracks = media.getTracks();
var track = require('helpers').getRandom(tracks.length);
/*reply(`Playing ${formatTrack(track)}`);*/
successReaction(ev, reply);
});
2020-05-16T21:16:04+02:00 [ command:41:14] TypeError: Cannot read property 'play' of undefined at command.createCommand.help.manual.checkPermission.exec (sinusbot-commands:408:69)
2020-05-16T21:16:04+02:00 [ command:41:14] This is _probably_ an Error with a Script which is using command.js!
2020-05-16T21:16:04+02:00 [ command:41:14] guillaumearnx (689576146765086830/629786143906594828) used $random
Error for random2 is :
2020-05-16T21:16:08+02:00 [ command:41:14] guillaumearnx (689576146765086830/629786143906594828) used $random2