aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/play.ts21
1 files changed, 21 insertions, 0 deletions
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;