rewrite na js bo rust jest zjebany

This commit is contained in:
Patryk Koreń
2025-12-26 18:31:14 +01:00
parent 7b72b15caa
commit 375779de9c
23 changed files with 1259 additions and 3827 deletions

49
src/commands/play.ts Normal file
View File

@@ -0,0 +1,49 @@
import { CacheType, ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js';
import { connectToChannel, playSong } from '../util/helpers';
import { player } from '../main';
import { get_audio } from '../util/downloader';
const name = "play"
function register() {
return new SlashCommandBuilder()
.setName(name)
.setDescription('YT')
.addStringOption((option) => option.setName("url")
.setDescription("YT url")
.setRequired(true))
}
async function execute(interaction: ChatInputCommandInteraction<CacheType>) {
try {
// await interaction.reply(`${interaction}`);
const member = await interaction.guild?.members.fetch(interaction.user.id);
if (!member) throw new Error("ale chuj")
const voiceChannel = member.voice.channel;
if (!voiceChannel) throw new Error("ale chuj 2")
const connection = await connectToChannel(voiceChannel);
connection.subscribe(player);
await interaction.reply('https://gitea.papryk.com/Papryk/dj-spangebob pull requesty milewidziane XD');
const url = interaction.options.getString("url")!;
const path = await get_audio(url)
// const path = "/home/patryk/Papryk/dbot/data/Kino - Summer is ending Кино - Кончится лето [6VqiMQoMXmw].opus"
console.log(path)
await playSong(player, path);
} catch (error) {
/**
* The song isn't ready to play for some reason :(
*/
console.error(error);
await interaction.reply('Coś poszło nie tak :/');
}
}
export default {
name,
register,
execute
}