Add files via upload
This commit is contained in:
Vendored
+63
-13
@@ -16,7 +16,7 @@ var __dirname = /* @__PURE__ */ getDirname();
|
||||
// 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.");
|
||||
@@ -26,8 +26,8 @@ function ERROR() {
|
||||
}
|
||||
|
||||
// src/functions/start.ts
|
||||
import fs from "fs";
|
||||
import { join } from "node:path";
|
||||
var Source = "";
|
||||
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = __require("@discordjs/voice");
|
||||
function StreamStart({
|
||||
imvci,
|
||||
@@ -38,9 +38,10 @@ function StreamStart({
|
||||
}) {
|
||||
try {
|
||||
let FileResource2 = function() {
|
||||
let Audio = createAudioResource(join(__dirname, Resource), { inlineVolume: true });
|
||||
let Audio = createAudioResource(join(__dirname, Source));
|
||||
AudioPlayer.play(Audio);
|
||||
joinVoiceChannel({
|
||||
//Join the channel.
|
||||
channelId: imvci,
|
||||
guildId: igi,
|
||||
adapterCreator: igv
|
||||
@@ -49,6 +50,7 @@ function StreamStart({
|
||||
let Audio = createAudioResource(Resource);
|
||||
AudioPlayer.play(Audio);
|
||||
joinVoiceChannel({
|
||||
//Join the channel.
|
||||
channelId: imvci,
|
||||
guildId: igi,
|
||||
adapterCreator: igv
|
||||
@@ -56,23 +58,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 (fs.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");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,10 +133,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(" ");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user