Add files via upload

This commit is contained in:
2024-05-05 12:46:20 +02:00
committed by GitHub
parent 5a341a3281
commit 958c08269f
10 changed files with 234 additions and 100 deletions
+63 -23
View File
@@ -1,9 +1,7 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
@@ -38,7 +28,7 @@ module.exports = __toCommonJS(src_exports);
// src/stuff/error.ts
function ERROR() {
console.log(" ");
console.log(" ______ _____ _____ ____ _____ \r\n | ____| __ \\| __ \\ / __ \\| __ \\ \r\n | |__ | |__) | |__) | | | | |__) |\r\n | __| | _ /| _ /| | | | _ / \r\n | |____| | \\ \\| | \\ \\| |__| | | \\ \\ \r\n |______|_| \\_\\_| \\_\\\\____/|_| \\_\\");
console.error(" ______ _____ _____ ____ _____ \r\n | ____| __ \\| __ \\ / __ \\| __ \\ \r\n | |__ | |__) | |__) | | | | |__) |\r\n | __| | _ /| _ /| | | | _ / \r\n | |____| | \\ \\| | \\ \\| |__| | | \\ \\ \r\n |______|_| \\_\\_| \\_\\\\____/|_| \\_\\");
console.log(" ");
console.log("This error comes from the discord-audio-stream package!");
console.log("This error happens if you don't use the package right.");
@@ -48,8 +38,8 @@ function ERROR() {
}
// src/functions/start.ts
var import_fs = __toESM(require("fs"));
var import_node_path = require("path");
var Source = "";
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
function StreamStart({
imvci,
@@ -60,9 +50,10 @@ function StreamStart({
}) {
try {
let FileResource2 = function() {
let Audio = createAudioResource((0, import_node_path.join)(__dirname, Resource), { inlineVolume: true });
let Audio = createAudioResource((0, import_node_path.join)(__dirname, Source));
AudioPlayer.play(Audio);
joinVoiceChannel({
//Join the channel.
channelId: imvci,
guildId: igi,
adapterCreator: igv
@@ -71,6 +62,7 @@ function StreamStart({
let Audio = createAudioResource(Resource);
AudioPlayer.play(Audio);
joinVoiceChannel({
//Join the channel.
channelId: imvci,
guildId: igi,
adapterCreator: igv
@@ -78,23 +70,71 @@ function StreamStart({
};
var FileResource = FileResource2, LinkResource = LinkResource2;
const AudioPlayer = createAudioPlayer();
var URLPattern = new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$", "i");
if (type === "Link") {
LinkResource2();
} else if (type === "File") {
FileResource2();
} else if (type === "Analyze") {
if (import_fs.default.existsSync(Resource)) {
FileResource2();
} else {
if (URLPattern.test(Resource) === true) {
LinkResource2();
const result = new Promise((resolve2, reject) => {
resolve2("Play");
});
} else {
ERROR();
console.log("CODE: Resource isn't a Link!");
console.log(" ");
const result = new Promise((resolve2, reject) => {
resolve2("Unknown");
});
}
} else if (type === "File") {
if (Resource.startsWith(".") == true) {
Source = require(Resource);
FileResource2();
const result = new Promise((resolve2, reject) => {
resolve2("Play");
});
} else {
ERROR();
console.log("CODE: Resource isn't a File!");
console.log(" ");
const result = new Promise((resolve2, reject) => {
resolve2("Unknown");
});
}
} else if (type === "Analyze") {
if (Resource.startsWith(".") == true) {
Source = require(Resource);
FileResource2();
const result = new Promise((resolve2, reject) => {
resolve2("Play");
});
} else if (URLPattern.test(Resource) === true) {
LinkResource2();
const result = new Promise((resolve2, reject) => {
resolve2("Play");
});
} else {
ERROR();
console.log("CODE: Resource isn't a Link or a File!");
console.log(" ");
const result = new Promise((resolve2, reject) => {
resolve2("Unknown");
});
}
} else {
ERROR();
console.log("CODE: Unknown resource type!");
console.log(" ");
const result = new Promise((resolve2, reject) => {
resolve2("Unknown");
});
}
} catch (error) {
ERROR();
console.log("ERR:\n" + error);
console.log(">> ERR:\n" + error);
console.log(" ");
const result = new Promise((resolve2, reject) => {
resolve2("ERROR");
});
}
}
@@ -105,10 +145,10 @@ function StreamStop({
}) {
try {
const connection = getVoiceConnection(igi);
connection.disconnect();
connection.destroy();
} catch (error) {
ERROR();
console.log("ERR:\n" + error);
console.log(">> ERR:\n" + error);
console.log(" ");
}
}