rewrite na js bo rust jest zjebany
This commit is contained in:
49
src/commands/play.ts
Normal file
49
src/commands/play.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user