rewrite na js bo rust jest zjebany
This commit is contained in:
19
src/commands/help.ts
Normal file
19
src/commands/help.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { CacheType, ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
const name = "help"
|
||||
|
||||
function register() {
|
||||
return new SlashCommandBuilder()
|
||||
.setName(name)
|
||||
.setDescription('Pomoc')
|
||||
}
|
||||
|
||||
async function execute(interaction: ChatInputCommandInteraction<CacheType>) {
|
||||
await interaction.reply('Jak ci się kurwa nie podoba to tutaj proszę o pull requesty https://gitea.papryk.com/Papryk/dj-spangebob');
|
||||
}
|
||||
|
||||
export default {
|
||||
name,
|
||||
register,
|
||||
execute
|
||||
}
|
||||
8
src/commands/index.ts
Normal file
8
src/commands/index.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import ping from "./ping"
|
||||
import play from "./play"
|
||||
|
||||
export const commands: {[key: string]: Command} = {
|
||||
ping,
|
||||
play,
|
||||
}
|
||||
|
||||
21
src/commands/join.ts
Normal file
21
src/commands/join.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { CacheType, ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js';
|
||||
import { connectToChannel } from '../util/helpers';
|
||||
import { joinVoiceChannel } from '@discordjs/voice';
|
||||
|
||||
const name = "ping"
|
||||
|
||||
function register() {
|
||||
return new SlashCommandBuilder()
|
||||
.setName(name)
|
||||
.setDescription('Replies with Pong!')
|
||||
}
|
||||
|
||||
async function execute(message: ChatInputCommandInteraction<CacheType>) {
|
||||
const channelId = "515300847790325790"
|
||||
}
|
||||
|
||||
export default {
|
||||
name,
|
||||
register,
|
||||
execute
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub mod play;
|
||||
20
src/commands/ping.ts
Normal file
20
src/commands/ping.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { CacheType, ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js';
|
||||
|
||||
const name = "ping"
|
||||
|
||||
function register() {
|
||||
return new SlashCommandBuilder()
|
||||
.setName(name)
|
||||
.setDescription('Replies with Pong!')
|
||||
}
|
||||
|
||||
async function execute(interaction: ChatInputCommandInteraction<CacheType>) {
|
||||
console.log(interaction.member)
|
||||
await interaction.reply('Pong!');
|
||||
}
|
||||
|
||||
export default {
|
||||
name,
|
||||
register,
|
||||
execute
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
use serenity::all::{Context, GuildId};
|
||||
use serenity::builder::{CreateCommand, CreateCommandOption};
|
||||
use serenity::model::application::{CommandOptionType, ResolvedOption, ResolvedValue};
|
||||
use songbird::Call;
|
||||
use songbird::driver::opus::ffi;
|
||||
use songbird::input::{self, AudioStream, Input};
|
||||
use std::env;
|
||||
use std::process::Command;
|
||||
|
||||
use crate::audio::downloader::get_audio;
|
||||
|
||||
pub async fn run(options: &[ResolvedOption<'_>], ctx: Context) -> String {
|
||||
if let Some(ResolvedOption {
|
||||
value: ResolvedValue::String(url),
|
||||
..
|
||||
}) = options.first()
|
||||
{
|
||||
let path = get_audio(url.to_string());
|
||||
let manager = songbird::get(&ctx).await.unwrap().clone();
|
||||
|
||||
let guild_id = GuildId::new(
|
||||
env::var("GUILD_ID")
|
||||
.expect("Expected GUILD_ID in environment")
|
||||
.parse()
|
||||
.expect("GUILD_ID must be an integer"),
|
||||
);
|
||||
if let Some(handler_lock) = manager.get(guild_id) {
|
||||
let mut handler = handler_lock.lock().await;
|
||||
let src = ffi
|
||||
let _ = handler.play_input();
|
||||
}
|
||||
|
||||
format!("{}", url)
|
||||
} else {
|
||||
"Please provide a valid url".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn register() -> CreateCommand {
|
||||
CreateCommand::new("play")
|
||||
.description("A play command")
|
||||
.add_option(
|
||||
CreateCommandOption::new(CommandOptionType::String, "url", "song to look for")
|
||||
.required(true),
|
||||
)
|
||||
}
|
||||
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