Muzika z internetu a souboru, yoyoyo
This commit is contained in:
parent
7d59b73064
commit
fb352dbe91
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ res/customAliasy.json
|
|||||||
zaznamy.dlog
|
zaznamy.dlog
|
||||||
zvuky/priVstupu
|
zvuky/priVstupu
|
||||||
logs
|
logs
|
||||||
|
.data
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.57.0",
|
"version": "3001.58.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.57.0",
|
"version": "3001.58.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/voice": "^0.16.1",
|
"@discordjs/voice": "^0.16.1",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.57.0",
|
"version": "3001.58.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/"
|
||||||
|
|||||||
@ -2,14 +2,20 @@
|
|||||||
|
|
||||||
import { AudioPlayerStatus, VoiceConnectionStatus } from "@discordjs/voice";
|
import { AudioPlayerStatus, VoiceConnectionStatus } from "@discordjs/voice";
|
||||||
import { Client } from "discord.js";
|
import { Client } from "discord.js";
|
||||||
import { search, soundcloud, stream, validate, video_basic_info } from "play-dl";
|
import { search, spotify, stream, validate, video_basic_info } from "play-dl";
|
||||||
import { emouty } from "../utils/emotes";
|
import { emouty } from "../utils/emotes";
|
||||||
import { Modul } from "../utils/types";
|
import { Modul } from "../utils/types";
|
||||||
import { adminLog, log } from "../utils/utils";
|
import { adminLog, log } from "../utils/utils";
|
||||||
import { getConn, novejJoin, novejPlay, Priority, stopPlayer } from "../utils/voice";
|
import { getConn, Hratelny, novejJoin, novejPlay, Priority, stopPlayer } from "../utils/voice";
|
||||||
import { array, record, safeParse, string } from "valibot";
|
import { array, record, safeParse, string } from "valibot";
|
||||||
|
|
||||||
const guildy = new Map<string, { kju: { name: string; url: string; }[]; loop: boolean; }>();
|
type QueueItem = {
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
special?: true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const guildy = new Map<string, { kju: QueueItem[]; loop: boolean; }>();
|
||||||
|
|
||||||
const searchScema = array(record(string(), string()));
|
const searchScema = array(record(string(), string()));
|
||||||
|
|
||||||
@ -19,8 +25,15 @@ async function playNext(guildId: string, seek?: number) {
|
|||||||
const kju = guilda.kju;
|
const kju = guilda.kju;
|
||||||
const item = kju[0];
|
const item = kju[0];
|
||||||
|
|
||||||
|
let coZahrat: Hratelny;
|
||||||
|
if (!item.special) {
|
||||||
const src = await stream(item.url, { seek });
|
const src = await stream(item.url, { seek });
|
||||||
novejPlay(guildId, { src: src.stream, volume: 1, type: src.type }, Priority.Music)
|
coZahrat = { src: src.stream, volume: 1, type: src.type };
|
||||||
|
} else {
|
||||||
|
coZahrat = item.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
novejPlay(guildId, coZahrat, Priority.Music)
|
||||||
.then(state => {
|
.then(state => {
|
||||||
if (state.status != AudioPlayerStatus.Idle) return;
|
if (state.status != AudioPlayerStatus.Idle) return;
|
||||||
|
|
||||||
@ -51,12 +64,32 @@ const exp: Modul = {
|
|||||||
if (!kanel) return "nejsi ve vojsu ty kkt";
|
if (!kanel) return "nejsi ve vojsu ty kkt";
|
||||||
|
|
||||||
const guildId = mes.guildId!;
|
const guildId = mes.guildId!;
|
||||||
const ajtem = { name: "", url: "" };
|
const ajtem: QueueItem = { name: "", url: "" };
|
||||||
|
|
||||||
const druh = await validate(txt);
|
const druh = await validate(txt);
|
||||||
if (druh && druh != "search") {
|
const soubor = mes.attachments.first();
|
||||||
if (druh != "yt_video" && druh != "so_track") return "tuto neumim zahrat";
|
if (soubor) {
|
||||||
|
ajtem.name = soubor.name;
|
||||||
|
ajtem.url = soubor.url;
|
||||||
|
ajtem.special = true;
|
||||||
|
mes.channel.send(`zahraju \`${soubor.name}\``);
|
||||||
|
} else if (txt == "") return "co mam zahrat??";
|
||||||
|
else if (!druh) {
|
||||||
|
ajtem.name = `nejaka picovina ot ${mes.author}`;
|
||||||
|
ajtem.url = txt;
|
||||||
|
ajtem.special = true;
|
||||||
|
mes.channel.send(`zkusim to zahrat`);
|
||||||
|
}
|
||||||
|
else if (druh == "search" || druh == "sp_track") {
|
||||||
|
const msg = mes.channel.send("hledam");
|
||||||
|
const hledacek = druh == "search" ? txt : (await spotify(txt)).name;
|
||||||
|
const hledani = await search(hledacek, { limit: 1 });
|
||||||
|
if (!hledani[0]) return "nic sem nenašel";
|
||||||
|
ajtem.url = hledani[0].url;
|
||||||
|
ajtem.name = hledani[0].title!;
|
||||||
|
msg.then(m => void m.edit(`zahraju \`${ajtem.name}\``));
|
||||||
|
} else if (druh == "yt_video") {
|
||||||
ajtem.url = txt;
|
ajtem.url = txt;
|
||||||
if (druh == "yt_video") {
|
|
||||||
try {
|
try {
|
||||||
const video = await video_basic_info(txt);
|
const video = await video_basic_info(txt);
|
||||||
ajtem.name = video.video_details.title!;
|
ajtem.name = video.video_details.title!;
|
||||||
@ -68,19 +101,7 @@ const exp: Modul = {
|
|||||||
adminLog(client, "video nemá název");
|
adminLog(client, "video nemá název");
|
||||||
}
|
}
|
||||||
mes.channel.send(`zahraju \`${ajtem.name}\``);
|
mes.channel.send(`zahraju \`${ajtem.name}\``);
|
||||||
} else {
|
} else return "tuto neumim zahrat";
|
||||||
const sound = await soundcloud(txt);
|
|
||||||
ajtem.name = sound.name;
|
|
||||||
mes.channel.send(`zahraju \`${ajtem.name}\``);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const msg = mes.channel.send("hledam");
|
|
||||||
const hledani = await search(txt, { limit: 1 });
|
|
||||||
if (!hledani[0]) return "nic sem nenašel";
|
|
||||||
ajtem.url = hledani[0].url;
|
|
||||||
ajtem.name = hledani[0].title!;
|
|
||||||
msg.then(m => void m.edit(`zahraju \`${ajtem.name}\``));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!guildy.has(guildId)) {
|
if (!guildy.has(guildId)) {
|
||||||
guildy.set(guildId, { kju: [], loop: false });
|
guildy.set(guildId, { kju: [], loop: false });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user