diff options
Diffstat (limited to 'server/src/commands')
| -rw-r--r-- | server/src/commands/voice/Play.ts | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/server/src/commands/voice/Play.ts b/server/src/commands/voice/Play.ts new file mode 100644 index 0000000..9ea335d --- /dev/null +++ b/server/src/commands/voice/Play.ts @@ -0,0 +1,52 @@ +import { Command } from 'discord-akairo'; +import { Message } from 'discord.js'; +import request from 'node-superfetch'; + +export default class PlayVoice extends Command { + public constructor() { + super('play', { + aliases: ['play'], + category: 'voice', + description: { + content: 'Gives you the bot\'s IP address.', + usage: '[song url/ name]', + examples: [ + '' + ] + }, + ratelimit: 3, + args: [ + { + id: 'song', + type: 'string' + } + ] + }); + } + + public async exec(msg: Message, { song }): Promise<Message> { + const { channel } = msg.member.voice; + + const serverQueue = this.client.queue.get(msg.guild.id); + if (!channel) return msg.reply('You need to join a voice channel first!'); //error + if (serverQueue && channel !== msg.guild.me.voice.channel) + return msg.reply(`You must be in the same channel as ${this.client.user}`); //error + + const permissions = channel.permissionsFor(msg.client.user); + if (!permissions.has('CONNECT')) + return msg.reply('Cannot connect to voice channel, missing permissions.'); + if (!permissions.has('SPEAK')) + return msg.reply('I cannto speak in this voice channel, make sure I have the proper permissions!'); + + const search = song; + const videoPattern = /^(https?:\/\/)?(www\.)?(m\.)?(youtube\.com|youtu\.?be)\/.+$/gi; + const playlistPattern = /^.*(list=)([^#\&\?]*).*/gi; + const scRegex = /^https?:\/\/(soundcloud\.com)\/(.*)$/; + const url = song; + const urlValid = videoPattern.test(song); + + if (!videoPattern.test(song) && playlistPattern.test(song)) { + return this.client.commandHandler.commandUtil. + } + } +}
\ No newline at end of file |