Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- registerPlugin({
- name: 'List',
- version: '0.1',
- description: 'List the tracks on the bot with the list command.',
- author: 'Monopolo11',
- backends: ['ts3', 'discord'],
- vars: [{
- name: 'admins',
- title: 'UIDs of users which have access to the command',
- type: 'strings',
- default: []
- }]
- }, (_, config, meta) => {
- const event = require('event')
- const engine = require('engine')
- const backend = require('backend')
- const format = require('format')
- const media = require('media')
- engine.log(`Loaded ${meta.name} v${meta.version} by ${meta.author}.`)
- event.on('load', () => {
- const command = require('command')
- if (!command) {
- engine.log('command.js library not found! Please download command.js to y$
- engine.log('command.js can be found here: https://github.com/Multivit4min$
- return;
- }
- command.createCommand('list')
- .alias('tracklist')
- .help('Lists the tracks on the server')
- .manual('Lists the tracks on the server')
- .checkPermission(allowAdminCommands)
- .addArgument(command.createArgument('string').setName('name').optional())
- .exec((/** @type {Client} */client, /** @type {object} */args, /** @type {(ms$
- let resp = format.bold('Tracks')
- media.getTracks().forEach(track => {
- engine.log(track.title)
- resp += track.title + '\n'
- })
- engine.log('salio del for')
- reply(resp)
- })
- })
- /**
- * Checks if a client is allowed to use admin commands.
- * @param {Client} client
- * @returns {boolean}
- */
- function allowAdminCommands(client) {
- switch (engine.getBackend()) {
- case "discord":
- return config.admins.includes(client.uid().split("/")[1])
- case "ts3":
- return config.admins.includes(client.uid())
- default:
- throw new Error(`Unknown backend ${engine.getBackend()}`)
- }
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement