very better music
This commit is contained in:
parent
1cf36fe516
commit
be76adf056
2012
package-lock.json
generated
2012
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "denim_3001",
|
||||
"version": "3001.37.1",
|
||||
"version": "3001.38.0",
|
||||
"description": "Toto je velmi kvalitní bot.",
|
||||
"repository": {
|
||||
"url": "https://github.com/Histmy/Denim-Bot/"
|
||||
@ -13,16 +13,14 @@
|
||||
"author": "Histmy + det-fys",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@discordjs/opus": "github:discordjs/opus",
|
||||
"@discordjs/voice": "^0.8.0",
|
||||
"discord.js": "^13.6.0",
|
||||
"js-levenshtein": "^1.1.6",
|
||||
"node-fetch": "^2.6.1",
|
||||
"opusscript": "^0.0.8",
|
||||
"play-dl": "^1.9.2",
|
||||
"tweetnacl": "^1.0.3",
|
||||
"ws": "^8.5.0",
|
||||
"yt-search": "^2.10.3",
|
||||
"ytdl": "^1.4.1",
|
||||
"ytdl-core": "^4.10.1"
|
||||
"ws": "^8.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-levenshtein": "^1.1.1",
|
||||
|
||||
@ -1,17 +1,35 @@
|
||||
// Tady bude muzika, vole
|
||||
|
||||
import ytdl from "ytdl-core";
|
||||
import { search, soundcloud, stream, validate, video_basic_info } from "play-dl";
|
||||
import { Modul } from "../utils/types";
|
||||
import { joinVoice, play } from "../utils/utils";
|
||||
|
||||
const exp: Modul = {
|
||||
more_komandy: {
|
||||
zahraj: async (mes, url) => {
|
||||
if (!ytdl.validateURL(url)) return "tuto neni validni youtube url a to je zatim jedini co hodlam hrat";
|
||||
zahraj: async (mes, txt) => {
|
||||
let url: string;
|
||||
const druh = await validate(txt);
|
||||
if (druh && druh != "search") {
|
||||
if (druh != "yt_video" && druh != "so_track") return "tuto neumim zahrat";
|
||||
url = txt;
|
||||
if (druh == "yt_video") {
|
||||
video_basic_info(url).then(v => mes.channel.send(`hraju \`${v.video_details.title}\``));
|
||||
} else {
|
||||
soundcloud(url).then(s => mes.channel.send(`hraju \`${s.name}\``));
|
||||
}
|
||||
} else {
|
||||
const msg = mes.channel.send("hledam");
|
||||
const hledani = await search(txt, { limit: 1 });
|
||||
url = hledani[0].url;
|
||||
msg.then(m => m.edit(`hraju \`${hledani[0].title}\``));
|
||||
}
|
||||
|
||||
const kanel = mes.member?.voice.channel;
|
||||
if (!kanel) return "nejsi ve vojsu ty kkt";
|
||||
const { conn } = await joinVoice(kanel);
|
||||
play(conn, ytdl(url).on("error", e => console.log("error pri hrani muziky", e)));
|
||||
|
||||
const src = await stream(url);
|
||||
play(conn, { name: src.stream, volume: 1, type: src.type });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -77,7 +77,7 @@ const exp: Modul = {
|
||||
const { prev, conn } = obj;
|
||||
if (!timeouty[mes.guildId!]) {
|
||||
vypocitatCas(conn);
|
||||
conn.on("stateChange", (_, now) => {
|
||||
conn.on<"stateChange">("stateChange", (_, now) => {
|
||||
if (now.status !== VoiceConnectionStatus.Disconnected && now.status !== VoiceConnectionStatus.Destroyed) return;
|
||||
clearTimeout(timeouty[mes.guildId!]);
|
||||
delete timeouty[mes.guildId!];
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { VoiceConnection } from "@discordjs/voice";
|
||||
import { StreamType, VoiceConnection } from "@discordjs/voice";
|
||||
import { Client, ClientEvents, ClientPresenceStatusData, Message, MessageOptions, User } from "discord.js";
|
||||
import { EventEmitter } from "events";
|
||||
import { Readable } from "node:stream";
|
||||
|
||||
type OutputRunFunkce = string | MessageOptions | void;
|
||||
|
||||
@ -68,8 +69,9 @@ export interface ZmenovejObjekt {
|
||||
}
|
||||
|
||||
export interface MuzikaFace {
|
||||
name: string;
|
||||
name: string | Readable;
|
||||
volume: number;
|
||||
type?: StreamType;
|
||||
}
|
||||
|
||||
export type KomandNaExport = {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { AudioPlayerStatus, AudioResource, createAudioPlayer, createAudioResource, entersState, getVoiceConnection, joinVoiceChannel, PlayerSubscription, VoiceConnection, VoiceConnectionStatus } from "@discordjs/voice";
|
||||
import { AudioPlayerStatus, AudioResource, createAudioPlayer, createAudioResource, entersState, getVoiceConnection, joinVoiceChannel, PlayerSubscription, StreamType, VoiceConnection, VoiceConnectionStatus } from "@discordjs/voice";
|
||||
import { Client, Guild, StageChannel, VoiceChannel } from "discord.js";
|
||||
import { once } from "events";
|
||||
import { JoinHovna, MuzikaFace, SRecord } from "./types";
|
||||
@ -100,6 +100,7 @@ export async function joinVoice(channel: VoiceChannel | StageChannel | string, g
|
||||
|
||||
if (!prev) {
|
||||
const player = createAudioPlayer();
|
||||
player.on("error", e => console.log("chyba pri hrani", e));
|
||||
pripojeni[guildId] = conn.subscribe(player)!;
|
||||
conn.on("error", e => {
|
||||
if (e.message.startsWith("Cannot perform IP discovery")) return;
|
||||
@ -112,7 +113,7 @@ export async function joinVoice(channel: VoiceChannel | StageChannel | string, g
|
||||
|
||||
const makeAudioPlayer = (co: string | MuzikaFace | Readable) => {
|
||||
if (typeof co == "string" || co instanceof Readable) return createAudioResource(co);
|
||||
const res = createAudioResource(co.name, { inlineVolume: true });
|
||||
const res = createAudioResource(co.name, { inlineVolume: true, inputType: co.type || StreamType.Arbitrary });
|
||||
res.volume?.setVolume(co.volume);
|
||||
return res;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user