Add files via upload
This commit is contained in:
@@ -16,7 +16,7 @@ Pease create a bug post on github or write [`fraujulian`](https://discord.com/us
|
||||
|
||||
## 📝 Usage
|
||||
|
||||
### Install Package
|
||||
### Install package
|
||||
```
|
||||
npm i discord-audio-stream
|
||||
```
|
||||
@@ -27,7 +27,7 @@ or
|
||||
yarn add discord-audio-stream
|
||||
```
|
||||
|
||||
### Start Audio Stream
|
||||
### Code Snippet - Start
|
||||
```js
|
||||
const Audio = require("discord-audio-stream");
|
||||
|
||||
@@ -40,7 +40,7 @@ Audio.StreamStart({
|
||||
})
|
||||
```
|
||||
|
||||
### Stop Audio Stream
|
||||
### Code Snippet - Stop
|
||||
```js
|
||||
const Audio = require("discord-audio-stream");
|
||||
|
||||
@@ -51,4 +51,4 @@ Audio.StreamStart({
|
||||
|
||||
## 🤝 Enjoy the package?
|
||||
|
||||
Give it a star ⭐ on github or [donate](https://buymeacoffee.com/fraujuliannn) a hot chocolate!
|
||||
Give it a star ⭐ on [github](https://github.com/FrauJulian/discord-audio-stream) or [donate](https://buymeacoffee.com/fraujuliannn) a hot chocolate!
|
||||
Vendored
+63
-23
@@ -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(" ");
|
||||
}
|
||||
}
|
||||
|
||||
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(" ");
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+13
-19
@@ -1,23 +1,24 @@
|
||||
{
|
||||
"name": "discord-audio-stream",
|
||||
"version": "0.0.3",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "discord-audio-stream",
|
||||
"version": "0.0.3",
|
||||
"version": "0.1.0",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"@discordjs/voice": "^0.16.1",
|
||||
"discord.js": "^14.14.1",
|
||||
"ffmpeg": "^0.0.4",
|
||||
"ffmpeg-static": "^5.2.0",
|
||||
"fs": "^0.0.1-security",
|
||||
"libsodium-wrappers": "^0.7.13",
|
||||
"opusscript": "^0.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ejs": "^3.1.5",
|
||||
"@types/node": "^20.12.8",
|
||||
"tsup": "^8.0.2",
|
||||
"typescript": "^5.4.5"
|
||||
}
|
||||
@@ -873,6 +874,12 @@
|
||||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/ejs": {
|
||||
"version": "3.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.5.tgz",
|
||||
"integrity": "sha512-nv+GSx77ZtXiJzwKdsASqi+YQ5Z7vwHsTP0JY2SiQgjGckkBRKZnk8nIM+7oUZ1VCtuTz0+By4qVR7fqzp/Dfg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
|
||||
@@ -880,9 +887,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.12.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz",
|
||||
"integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==",
|
||||
"version": "20.12.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.8.tgz",
|
||||
"integrity": "sha512-NU0rJLJnshZWdE/097cdCBbyW1h4hEg0xpovcoAQYHl8dnEyp/NAOiE45pvc+Bd1Dt+2r94v2eGFpQJ4R7g+2w==",
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
}
|
||||
@@ -1315,14 +1322,6 @@
|
||||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/ffmpeg": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/ffmpeg/-/ffmpeg-0.0.4.tgz",
|
||||
"integrity": "sha512-3TgWUJJlZGQn+crJFyhsO/oNeRRnGTy6GhgS98oUCIfZrOW5haPPV7DUfOm3xJcHr5q3TJpjk2GudPutrNisRA==",
|
||||
"dependencies": {
|
||||
"when": ">= 0.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/ffmpeg-static": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ffmpeg-static/-/ffmpeg-static-5.2.0.tgz",
|
||||
@@ -2437,11 +2436,6 @@
|
||||
"webidl-conversions": "^4.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/when": {
|
||||
"version": "3.7.8",
|
||||
"resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz",
|
||||
"integrity": "sha512-5cZ7mecD3eYcMiCH4wtRPA5iFJZ50BJYDfckI5RRpQiktMiYTcn0ccLTZOvcbBume+1304fQztxeNzNS9Gvrnw=="
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
|
||||
+5
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "discord-audio-stream",
|
||||
"version": "0.0.3",
|
||||
"version": "0.1.0",
|
||||
"description": "🖼️ NPM Package to stream any audio link on discord.",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
@@ -15,7 +15,8 @@
|
||||
"keywords": [
|
||||
"discordjs-v14",
|
||||
"stream",
|
||||
"audio"
|
||||
"audio",
|
||||
"music"
|
||||
],
|
||||
"author": "FrauJulian | Julian Lechner",
|
||||
"license": "BSD-3-Clause",
|
||||
@@ -24,13 +25,14 @@
|
||||
},
|
||||
"homepage": "https://github.com/FrauJulian/discord-audio-stream#readme",
|
||||
"devDependencies": {
|
||||
"@types/ejs": "^3.1.5",
|
||||
"@types/node": "^20.12.8",
|
||||
"tsup": "^8.0.2",
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@discordjs/voice": "^0.16.1",
|
||||
"discord.js": "^14.14.1",
|
||||
"ffmpeg": "^0.0.4",
|
||||
"ffmpeg-static": "^5.2.0",
|
||||
"fs": "^0.0.1-security",
|
||||
"libsodium-wrappers": "^0.7.13",
|
||||
|
||||
+70
-32
@@ -1,8 +1,9 @@
|
||||
import { StartProps } from "../stuff/types";
|
||||
import { ERROR } from "../stuff/error";
|
||||
import fs from "fs";
|
||||
|
||||
import { join } from "node:path";
|
||||
import { AudioPlayer } from "@discordjs/voice";
|
||||
|
||||
let Source = "";
|
||||
|
||||
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
|
||||
|
||||
@@ -17,52 +18,89 @@ export function StreamStart({
|
||||
//Create AudioPlayer variable.
|
||||
const AudioPlayer = createAudioPlayer();
|
||||
|
||||
//File Resource
|
||||
//Play function for file resource.
|
||||
function FileResource() {
|
||||
|
||||
let Audio = createAudioResource(join(__dirname, Resource), { inlineVolume: true });
|
||||
AudioPlayer.play(Audio);
|
||||
let Audio = createAudioResource(join(__dirname, Source)); //Fetch stream File.
|
||||
AudioPlayer.play(Audio); //Set AudioPlayer to resource File.
|
||||
|
||||
joinVoiceChannel({
|
||||
joinVoiceChannel({ //Join the channel.
|
||||
channelId: imvci,
|
||||
guildId: igi,
|
||||
adapterCreator: igv
|
||||
}).subscribe(AudioPlayer);
|
||||
}).subscribe(AudioPlayer); //AudioPlayer start playing audio.
|
||||
}
|
||||
|
||||
//Link Resource
|
||||
//Play function for link resource.
|
||||
function LinkResource() {
|
||||
let Audio = createAudioResource(Resource);
|
||||
AudioPlayer.play(Audio);
|
||||
let Audio = createAudioResource(Resource); //Fetch stream Link.
|
||||
AudioPlayer.play(Audio); //Set AudioPlayer to resource Link.
|
||||
|
||||
joinVoiceChannel({
|
||||
joinVoiceChannel({ //Join the channel.
|
||||
channelId: imvci,
|
||||
guildId: igi,
|
||||
adapterCreator: igv
|
||||
}).subscribe(AudioPlayer)
|
||||
}).subscribe(AudioPlayer) //AudioPlayer start playing audio.
|
||||
}
|
||||
|
||||
//If the type is "Link".
|
||||
if (type === "Link") {
|
||||
LinkResource();
|
||||
//If the type is "File".
|
||||
} else if (type === "File") {
|
||||
FileResource();
|
||||
//If the type is "Analyze".
|
||||
} else if (type === "Analyze") {
|
||||
if (fs.existsSync(Resource)) { //Check if Resource is a file and exist.
|
||||
FileResource();
|
||||
} else { //If Resoure is not a file or doesn't exist.
|
||||
LinkResource();
|
||||
//URL Pattern to test if the resource is a link.
|
||||
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") { //If the type is "Link".
|
||||
|
||||
if (URLPattern.test(Resource) === true) { //Check if Link is a URL.
|
||||
|
||||
LinkResource(); //Run LinkResource function.
|
||||
|
||||
} else { //If resource is not a link.
|
||||
ERROR(); //Run ERROR function.
|
||||
console.log("CODE: Resource isn't a Link!") //"Error Code" usefull for help people.
|
||||
console.log(" ") //Placeholder xD
|
||||
}
|
||||
} else {
|
||||
//If no valid value is specified.
|
||||
ERROR();
|
||||
|
||||
} else if (type === "File") { //If the type is "File".
|
||||
if (Resource.startsWith(".") == true) { //Check if the resource file exist.
|
||||
|
||||
Source = require(Resource); //Set Source variable to Audio File.
|
||||
FileResource(); //Run FileResource function.
|
||||
|
||||
} else { //If resource is not a file.
|
||||
ERROR(); //Run ERROR function.
|
||||
console.log("CODE: Resource isn't a File!") //"Error Code" usefull for help people.
|
||||
console.log(" ") //Placeholder xD
|
||||
}
|
||||
|
||||
} else if (type === "Analyze") { //If the type is "Analyze".
|
||||
|
||||
if (Resource.startsWith(".") == true) { //Check if the resource file exist.
|
||||
|
||||
Source = require(Resource); //Set Source variable to Audio File.
|
||||
FileResource(); //Run FileResource function.
|
||||
|
||||
} else if (URLPattern.test(Resource) === true) { //Check if Link is a URL.
|
||||
|
||||
LinkResource(); //Run LinkResource function.
|
||||
|
||||
} else { //If resource is not a link or file.
|
||||
ERROR(); //Run ERROR function.
|
||||
console.log("CODE: Resource isn't a Link or a File!") //"Error Code" usefull for help people.
|
||||
console.log(" ") //Placeholder xD
|
||||
}
|
||||
|
||||
} else { //If no valid value is specified.
|
||||
ERROR(); //Run ERROR function.
|
||||
console.log("CODE: Unknown resource type!") //"Error Code" usefull for help people.
|
||||
console.log(" ") //Placeholder xD
|
||||
}
|
||||
} catch (error) {
|
||||
//If syntax is wrong.
|
||||
ERROR();
|
||||
console.log("ERR:\n" + error);
|
||||
console.log(" ");
|
||||
|
||||
} catch (error) { //If syntax is wrong.
|
||||
ERROR(); //Run ERROR function.
|
||||
console.log(">> ERR:\n" + error); //Log the Error
|
||||
console.log(" "); //Placeholder xD
|
||||
}
|
||||
};
|
||||
@@ -14,8 +14,8 @@ export function StreamStop({
|
||||
connection.destroy();
|
||||
|
||||
} catch (error) {
|
||||
ERROR();
|
||||
console.log("ERR:\n" + error);
|
||||
console.log(" ");
|
||||
ERROR(); //Run ERROR function.
|
||||
console.log(">> ERR:\n" + error); //Log the Error
|
||||
console.log(" "); //Placeholder xD
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
//Export Start and Stop Function
|
||||
export * from "./functions/start";
|
||||
export * from "./functions/stop";
|
||||
export * from "./functions/stop";
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
//ERROR Message
|
||||
export 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.");
|
||||
|
||||
+11
-1
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"allowJs": true,
|
||||
"noImplicitAny": true,
|
||||
"esModuleInterop": true,
|
||||
"strictNullChecks": true,
|
||||
@@ -8,10 +9,19 @@
|
||||
"moduleResolution": "Node",
|
||||
"module": "CommonJS",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"jsx": "react",
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"outDir": "dist"
|
||||
"outDir": "dist",
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
},
|
||||
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user