very better music
This commit is contained in:
parent
1cf36fe516
commit
be76adf056
2006
package-lock.json
generated
2006
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",
|
"name": "denim_3001",
|
||||||
"version": "3001.37.1",
|
"version": "3001.38.0",
|
||||||
"description": "Toto je velmi kvalitní bot.",
|
"description": "Toto je velmi kvalitní bot.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "https://github.com/Histmy/Denim-Bot/"
|
"url": "https://github.com/Histmy/Denim-Bot/"
|
||||||
@ -13,16 +13,14 @@
|
|||||||
"author": "Histmy + det-fys",
|
"author": "Histmy + det-fys",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/opus": "github:discordjs/opus",
|
|
||||||
"@discordjs/voice": "^0.8.0",
|
"@discordjs/voice": "^0.8.0",
|
||||||
"discord.js": "^13.6.0",
|
"discord.js": "^13.6.0",
|
||||||
"js-levenshtein": "^1.1.6",
|
"js-levenshtein": "^1.1.6",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
|
"opusscript": "^0.0.8",
|
||||||
|
"play-dl": "^1.9.2",
|
||||||
"tweetnacl": "^1.0.3",
|
"tweetnacl": "^1.0.3",
|
||||||
"ws": "^8.5.0",
|
"ws": "^8.5.0"
|
||||||
"yt-search": "^2.10.3",
|
|
||||||
"ytdl": "^1.4.1",
|
|
||||||
"ytdl-core": "^4.10.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/js-levenshtein": "^1.1.1",
|
"@types/js-levenshtein": "^1.1.1",
|
||||||
|
|||||||
@ -1,17 +1,35 @@
|
|||||||
// Tady bude muzika, vole
|
// 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 { Modul } from "../utils/types";
|
||||||
import { joinVoice, play } from "../utils/utils";
|
import { joinVoice, play } from "../utils/utils";
|
||||||
|
|
||||||
const exp: Modul = {
|
const exp: Modul = {
|
||||||
more_komandy: {
|
more_komandy: {
|
||||||
zahraj: async (mes, url) => {
|
zahraj: async (mes, txt) => {
|
||||||
if (!ytdl.validateURL(url)) return "tuto neni validni youtube url a to je zatim jedini co hodlam hrat";
|
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;
|
const kanel = mes.member?.voice.channel;
|
||||||
if (!kanel) return "nejsi ve vojsu ty kkt";
|
if (!kanel) return "nejsi ve vojsu ty kkt";
|
||||||
const { conn } = await joinVoice(kanel);
|
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;
|
const { prev, conn } = obj;
|
||||||
if (!timeouty[mes.guildId!]) {
|
if (!timeouty[mes.guildId!]) {
|
||||||
vypocitatCas(conn);
|
vypocitatCas(conn);
|
||||||
conn.on("stateChange", (_, now) => {
|
conn.on<"stateChange">("stateChange", (_, now) => {
|
||||||
if (now.status !== VoiceConnectionStatus.Disconnected && now.status !== VoiceConnectionStatus.Destroyed) return;
|
if (now.status !== VoiceConnectionStatus.Disconnected && now.status !== VoiceConnectionStatus.Destroyed) return;
|
||||||
clearTimeout(timeouty[mes.guildId!]);
|
clearTimeout(timeouty[mes.guildId!]);
|
||||||
delete 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 { Client, ClientEvents, ClientPresenceStatusData, Message, MessageOptions, User } from "discord.js";
|
||||||
import { EventEmitter } from "events";
|
import { EventEmitter } from "events";
|
||||||
|
import { Readable } from "node:stream";
|
||||||
|
|
||||||
type OutputRunFunkce = string | MessageOptions | void;
|
type OutputRunFunkce = string | MessageOptions | void;
|
||||||
|
|
||||||
@ -68,8 +69,9 @@ export interface ZmenovejObjekt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface MuzikaFace {
|
export interface MuzikaFace {
|
||||||
name: string;
|
name: string | Readable;
|
||||||
volume: number;
|
volume: number;
|
||||||
|
type?: StreamType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type KomandNaExport = {
|
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 { Client, Guild, StageChannel, VoiceChannel } from "discord.js";
|
||||||
import { once } from "events";
|
import { once } from "events";
|
||||||
import { JoinHovna, MuzikaFace, SRecord } from "./types";
|
import { JoinHovna, MuzikaFace, SRecord } from "./types";
|
||||||
@ -100,6 +100,7 @@ export async function joinVoice(channel: VoiceChannel | StageChannel | string, g
|
|||||||
|
|
||||||
if (!prev) {
|
if (!prev) {
|
||||||
const player = createAudioPlayer();
|
const player = createAudioPlayer();
|
||||||
|
player.on("error", e => console.log("chyba pri hrani", e));
|
||||||
pripojeni[guildId] = conn.subscribe(player)!;
|
pripojeni[guildId] = conn.subscribe(player)!;
|
||||||
conn.on("error", e => {
|
conn.on("error", e => {
|
||||||
if (e.message.startsWith("Cannot perform IP discovery")) return;
|
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) => {
|
const makeAudioPlayer = (co: string | MuzikaFace | Readable) => {
|
||||||
if (typeof co == "string" || co instanceof Readable) return createAudioResource(co);
|
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);
|
res.volume?.setVolume(co.volume);
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user