X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=music.js;fp=music.js;h=745c5491033c251f40a2aa5669f6ae0703e14c04;hb=9ebd0d19063ab4e94052c531668cb0d7f5e90497;hp=0000000000000000000000000000000000000000;hpb=3c1e0fa1156b237504567989509cd4e77430d069;p=furrybot-discord.git diff --git a/music.js b/music.js new file mode 100644 index 0000000..745c549 --- /dev/null +++ b/music.js @@ -0,0 +1,26 @@ +const ytdl = require("ytdl-core") +const voice = require("@discordjs/voice") + +module.exports = { + play: { + func: (msg, url) => { + const channel = msg.member.voice.channel + + if (! channel) + return msg.reply("Join a voice channel you fucking moron") + + const conn = voice.joinVoiceChannel({ + channelId: channel.id, + guildId: channel.guild.id, + adapterCreator: channel.guild.voiceAdapterCreator, + }) + + const stream = ytdl(url.join(" "), {filter: "audioonly"}) + const resource = voice.createAudioResource(stream, {inputType: voice.StreamType.Arbitrary}) + const player = voice.createAudioPlayer() + + player.play(resource) + conn.subscribe(player) + } + } +}