From 8eb4c8a6c06f672cb50efae5ea30215d465000af Mon Sep 17 00:00:00 2001 From: Max Isom Date: Tue, 10 Mar 2020 11:58:09 -0500 Subject: Basic play functionality --- src/commands/play.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/commands/play.ts (limited to 'src/commands') diff --git a/src/commands/play.ts b/src/commands/play.ts new file mode 100644 index 0000000..cf23d60 --- /dev/null +++ b/src/commands/play.ts @@ -0,0 +1,21 @@ +import {CommandHandler} from '../interfaces'; +import {getMostPopularVoiceChannel} from '../utils/channels'; +import getYouTubeStream from '../utils/get-youtube-stream'; + +const play: CommandHandler = { + name: 'play', + description: 'plays a song', + execute: async (msg, args) => { + const url = args[0]; + + const channel = getMostPopularVoiceChannel(msg.guild!); + + const conn = await channel.join(); + + const stream = await getYouTubeStream(url); + + conn.play(stream, {type: 'webm/opus'}); + } +}; + +export default play; -- cgit v1.2.3