diff --git a/package-lock.json b/package-lock.json index 0055cd1..9eeee1e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "denim_3001", - "version": "3001.24.0", + "version": "3001.25.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "denim_3001", - "version": "3001.24.0", + "version": "3001.25.0", "license": "ISC", "dependencies": { "@discordjs/opus": "github:discordjs/opus", diff --git a/package.json b/package.json index 41ea690..a107dd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "denim_3001", - "version": "3001.24.0", + "version": "3001.25.0", "description": "Toto je velmi kvalitní bot.", "repository": { "url": "https://github.com/Histmy/Denim-Bot/" diff --git a/src/modules/muzika.ts b/src/modules/muzika.ts new file mode 100644 index 0000000..b5404cc --- /dev/null +++ b/src/modules/muzika.ts @@ -0,0 +1,17 @@ +// Tady bude muzika, vole + +import { Message } from "discord.js"; +import * as ytdl from "ytdl-core"; +import { joinVoice, play } from "../utils/utils"; + +module.exports = { + more_komandy: { + zahraj: async (url: string, mes: Message) => { + if (!ytdl.validateURL(url)) return "tuto neni validni youtube url a to je zatim jedini co hodlam hrat"; + const kanel = mes.member?.voice.channel; + if (!kanel) return "nejsi ve vojsu ty kkt"; + const { conn } = await joinVoice(kanel, mes.guild!); + play(conn, ytdl(url)); + } + } +}; diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 49e8704..6db986c 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -3,6 +3,7 @@ import { Guild, StageChannel, VoiceChannel } from "discord.js"; import { once } from "events"; import { MuzikaFace } from "./types"; import { existsSync } from "fs"; +import { Readable } from "node:stream"; const pripojeni: Record = {}; @@ -97,14 +98,14 @@ export const joinVoice = async (channel: VoiceChannel | StageChannel | string, g return { conn, prev }; }; -const makeAudioPlayer = (co: string | MuzikaFace) => { - if (typeof co === "string") return createAudioResource(co); +const makeAudioPlayer = (co: string | MuzikaFace | Readable) => { + if (typeof co == "string" || co instanceof Readable) return createAudioResource(co); const res = createAudioResource(co.name, { inlineVolume: true }); res.volume?.setVolume(co.volume); return res; }; -export const play = (conn: VoiceConnection, co: string | string[] | MuzikaFace | MuzikaFace[]) => new Promise(async (res, rej) => { +export const play = (conn: VoiceConnection, co: string | string[] | MuzikaFace | MuzikaFace[] | Readable) => new Promise(async (res, rej) => { if (conn.state.status !== VoiceConnectionStatus.Ready) return rej("conn není ready"); const player = pripojeni[conn.joinConfig.guildId].player;