Add files via upload
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
BSD 3-Clause License
|
||||||
|
|
||||||
|
Copyright (c) 2024, Julian Lechner
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of the copyright holder nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
# Discord Audio Stream
|
||||||
|
|
||||||
|
[](http://npmjs.org/package/discord-audio-stream)
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
<p>This NPM package was created to make it easier to stream audio to Discord.</p>
|
||||||
|
<p>There is a security feature of discord that stops the stream of audio after some time. This problem can be solved by disconnecting the Discord channel every 1.5 hours for 2 seconds and then reconnecting the channel. (If you use this package!) I recommend using a database to store the data e.g. MySQL, SQLite, json file and other database types.</p>
|
||||||
|
<p>The package does not fix this error yet. However, it is currently being worked on!</p>
|
||||||
|
|
||||||
|
**This module is designed to work with [discord.js](https://discord.js.org/#/) v14. This package doesn't support older versions!**
|
||||||
|
|
||||||
|
## 👋 Support
|
||||||
|
|
||||||
|
Pease create a bug post on github or write [`fraujulian`](https://discord.com/users/860206216893693973) on discord!
|
||||||
|
|
||||||
|
## 📝 Usage
|
||||||
|
|
||||||
|
### Install package
|
||||||
|
```bash
|
||||||
|
npm i discord-audio-stream
|
||||||
|
```
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn add discord-audio-stream
|
||||||
|
```
|
||||||
|
|
||||||
|
### Code Snippet - Start
|
||||||
|
```js
|
||||||
|
const Audio = require("discord-audio-stream");
|
||||||
|
|
||||||
|
Audio.StreamStart({
|
||||||
|
imvci: 0, //Voice Channel ID e.g. interaction.member.voice.channel.id
|
||||||
|
igi: 0, //Guild ID e.g. interaction.guild.id
|
||||||
|
igv: 0, //Bot Voice Adapter e.g. interaction.guild.voiceAdapterCreator
|
||||||
|
type: "", //Choose the Stream resource - File or Link or Analyze
|
||||||
|
Resource: "", //Link to File e.g. ../assets/Stream.mp3 or Link to Audio Stream
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Code Snippet - Stop
|
||||||
|
```js
|
||||||
|
const Audio = require("discord-audio-stream");
|
||||||
|
|
||||||
|
Audio.StreamStart({
|
||||||
|
igi: 0, //Guild ID e.g. interaction.guild.id
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🤝 Enjoy the package?
|
||||||
|
|
||||||
|
Give it a star ⭐ on [github](https://github.com/FrauJulian/discord-audio-stream) or [donate](https://buymeacoffee.com/fraujuliannn) a hot chocolate!
|
||||||
Vendored
+17
@@ -0,0 +1,17 @@
|
|||||||
|
type startParameters = {
|
||||||
|
imvci: number;
|
||||||
|
igi: number;
|
||||||
|
igv: number;
|
||||||
|
type: string;
|
||||||
|
Resource: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type stopParameter = {
|
||||||
|
igi: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
declare function start({ imvci, igi, igv, type, Resource, }: startParameters): void;
|
||||||
|
|
||||||
|
declare function stop({ igi, }: stopParameter): void;
|
||||||
|
|
||||||
|
export { start, stop };
|
||||||
Vendored
+17
@@ -0,0 +1,17 @@
|
|||||||
|
type startParameters = {
|
||||||
|
imvci: number;
|
||||||
|
igi: number;
|
||||||
|
igv: number;
|
||||||
|
type: string;
|
||||||
|
Resource: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type stopParameter = {
|
||||||
|
igi: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
declare function start({ imvci, igi, igv, type, Resource, }: startParameters): void;
|
||||||
|
|
||||||
|
declare function stop({ igi, }: stopParameter): void;
|
||||||
|
|
||||||
|
export { start, stop };
|
||||||
Vendored
+128
@@ -0,0 +1,128 @@
|
|||||||
|
"use strict";
|
||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||||
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||||
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||||
|
var __export = (target, all) => {
|
||||||
|
for (var name in all)
|
||||||
|
__defProp(target, name, { get: all[name], enumerable: true });
|
||||||
|
};
|
||||||
|
var __copyProps = (to, from, except, desc) => {
|
||||||
|
if (from && typeof from === "object" || typeof from === "function") {
|
||||||
|
for (let key of __getOwnPropNames(from))
|
||||||
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||||
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||||
|
}
|
||||||
|
return to;
|
||||||
|
};
|
||||||
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||||
|
|
||||||
|
// src/index.ts
|
||||||
|
var src_exports = {};
|
||||||
|
__export(src_exports, {
|
||||||
|
start: () => start,
|
||||||
|
stop: () => stop
|
||||||
|
});
|
||||||
|
module.exports = __toCommonJS(src_exports);
|
||||||
|
|
||||||
|
// src/utility/errorFunc.ts
|
||||||
|
function ERR(err) {
|
||||||
|
console.error(" ");
|
||||||
|
console.error(" ______ _____ _____ ____ _____ \r\n | ____| __ \\| __ \\ / __ \\| __ \\ \r\n | |__ | |__) | |__) | | | | |__) |\r\n | __| | _ /| _ /| | | | _ / \r\n | |____| | \\ \\| | \\ \\| |__| | | \\ \\ \r\n |______|_| \\_\\_| \\_\\\\____/|_| \\_\\");
|
||||||
|
console.error(" ");
|
||||||
|
console.error("This error comes from the discord-audio-stream package!");
|
||||||
|
console.error("This error occurs if you are not using the package correctly, sometimes it can also be bugs in the package.");
|
||||||
|
console.error(" ");
|
||||||
|
console.error("See the docs or open a issue post on github.");
|
||||||
|
console.error(" ");
|
||||||
|
if (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/functions/startFunc.ts
|
||||||
|
var import_node_path = require("path");
|
||||||
|
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
|
||||||
|
function start({
|
||||||
|
imvci,
|
||||||
|
igi,
|
||||||
|
igv,
|
||||||
|
type,
|
||||||
|
Resource
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
let streamFile2 = function(FILE) {
|
||||||
|
let Audio = createAudioResource((0, import_node_path.join)(__dirname, FILE), { inlineVolume: true });
|
||||||
|
AudioPlayer.play(Audio);
|
||||||
|
joinVoiceChannel({
|
||||||
|
channelId: imvci,
|
||||||
|
guildId: igi,
|
||||||
|
adapterCreator: igv
|
||||||
|
}).subscribe(AudioPlayer);
|
||||||
|
}, streamLink2 = function(URL) {
|
||||||
|
let Audio = createAudioResource(URL);
|
||||||
|
AudioPlayer.play(Audio);
|
||||||
|
joinVoiceChannel({
|
||||||
|
channelId: imvci,
|
||||||
|
guildId: igi,
|
||||||
|
adapterCreator: igv
|
||||||
|
}).subscribe(AudioPlayer);
|
||||||
|
}, LinkValidation2 = function(URL) {
|
||||||
|
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");
|
||||||
|
return URLPattern.test(URL);
|
||||||
|
}, FileValidation2 = function(FILE) {
|
||||||
|
var FILEPattern = new RegExp("^(.+)/([^/]+)$");
|
||||||
|
return FILEPattern.test(FILE);
|
||||||
|
};
|
||||||
|
var streamFile = streamFile2, streamLink = streamLink2, LinkValidation = LinkValidation2, FileValidation = FileValidation2;
|
||||||
|
const AudioPlayer = createAudioPlayer();
|
||||||
|
switch (type) {
|
||||||
|
case "Link":
|
||||||
|
if (LinkValidation2(Resource) === true && FileValidation2(Resource) === false) {
|
||||||
|
streamLink2(Resource);
|
||||||
|
} else {
|
||||||
|
ERR();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "File":
|
||||||
|
if (LinkValidation2(Resource) === false && FileValidation2(Resource) === true) {
|
||||||
|
streamFile2(Resource);
|
||||||
|
} else {
|
||||||
|
ERR();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "Analyze":
|
||||||
|
if (LinkValidation2(Resource) === true && FileValidation2(Resource) === false) {
|
||||||
|
streamLink2(Resource);
|
||||||
|
} else if (LinkValidation2(Resource) === false && FileValidation2(Resource) === true) {
|
||||||
|
streamFile2(Resource);
|
||||||
|
} else {
|
||||||
|
ERR();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERR();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
ERR(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/functions/stopFunc.ts
|
||||||
|
var { getVoiceConnection } = require("@discordjs/voice");
|
||||||
|
function stop({
|
||||||
|
igi
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const connection = getVoiceConnection(igi);
|
||||||
|
connection.destroy();
|
||||||
|
} catch (err) {
|
||||||
|
ERR();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Annotate the CommonJS export names for ESM import in node:
|
||||||
|
0 && (module.exports = {
|
||||||
|
start,
|
||||||
|
stop
|
||||||
|
});
|
||||||
Vendored
+114
@@ -0,0 +1,114 @@
|
|||||||
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||||
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||||
|
}) : x)(function(x) {
|
||||||
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||||
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||||
|
});
|
||||||
|
|
||||||
|
// node_modules/tsup/assets/esm_shims.js
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
import path from "path";
|
||||||
|
var getFilename = () => fileURLToPath(import.meta.url);
|
||||||
|
var getDirname = () => path.dirname(getFilename());
|
||||||
|
var __dirname = /* @__PURE__ */ getDirname();
|
||||||
|
|
||||||
|
// src/utility/errorFunc.ts
|
||||||
|
function ERR(err) {
|
||||||
|
console.error(" ");
|
||||||
|
console.error(" ______ _____ _____ ____ _____ \r\n | ____| __ \\| __ \\ / __ \\| __ \\ \r\n | |__ | |__) | |__) | | | | |__) |\r\n | __| | _ /| _ /| | | | _ / \r\n | |____| | \\ \\| | \\ \\| |__| | | \\ \\ \r\n |______|_| \\_\\_| \\_\\\\____/|_| \\_\\");
|
||||||
|
console.error(" ");
|
||||||
|
console.error("This error comes from the discord-audio-stream package!");
|
||||||
|
console.error("This error occurs if you are not using the package correctly, sometimes it can also be bugs in the package.");
|
||||||
|
console.error(" ");
|
||||||
|
console.error("See the docs or open a issue post on github.");
|
||||||
|
console.error(" ");
|
||||||
|
if (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/functions/startFunc.ts
|
||||||
|
import { join } from "node:path";
|
||||||
|
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = __require("@discordjs/voice");
|
||||||
|
function start({
|
||||||
|
imvci,
|
||||||
|
igi,
|
||||||
|
igv,
|
||||||
|
type,
|
||||||
|
Resource
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
let streamFile2 = function(FILE) {
|
||||||
|
let Audio = createAudioResource(join(__dirname, FILE), { inlineVolume: true });
|
||||||
|
AudioPlayer.play(Audio);
|
||||||
|
joinVoiceChannel({
|
||||||
|
channelId: imvci,
|
||||||
|
guildId: igi,
|
||||||
|
adapterCreator: igv
|
||||||
|
}).subscribe(AudioPlayer);
|
||||||
|
}, streamLink2 = function(URL) {
|
||||||
|
let Audio = createAudioResource(URL);
|
||||||
|
AudioPlayer.play(Audio);
|
||||||
|
joinVoiceChannel({
|
||||||
|
channelId: imvci,
|
||||||
|
guildId: igi,
|
||||||
|
adapterCreator: igv
|
||||||
|
}).subscribe(AudioPlayer);
|
||||||
|
}, LinkValidation2 = function(URL) {
|
||||||
|
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");
|
||||||
|
return URLPattern.test(URL);
|
||||||
|
}, FileValidation2 = function(FILE) {
|
||||||
|
var FILEPattern = new RegExp("^(.+)/([^/]+)$");
|
||||||
|
return FILEPattern.test(FILE);
|
||||||
|
};
|
||||||
|
var streamFile = streamFile2, streamLink = streamLink2, LinkValidation = LinkValidation2, FileValidation = FileValidation2;
|
||||||
|
const AudioPlayer = createAudioPlayer();
|
||||||
|
switch (type) {
|
||||||
|
case "Link":
|
||||||
|
if (LinkValidation2(Resource) === true && FileValidation2(Resource) === false) {
|
||||||
|
streamLink2(Resource);
|
||||||
|
} else {
|
||||||
|
ERR();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "File":
|
||||||
|
if (LinkValidation2(Resource) === false && FileValidation2(Resource) === true) {
|
||||||
|
streamFile2(Resource);
|
||||||
|
} else {
|
||||||
|
ERR();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "Analyze":
|
||||||
|
if (LinkValidation2(Resource) === true && FileValidation2(Resource) === false) {
|
||||||
|
streamLink2(Resource);
|
||||||
|
} else if (LinkValidation2(Resource) === false && FileValidation2(Resource) === true) {
|
||||||
|
streamFile2(Resource);
|
||||||
|
} else {
|
||||||
|
ERR();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERR();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
ERR(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// src/functions/stopFunc.ts
|
||||||
|
var { getVoiceConnection } = __require("@discordjs/voice");
|
||||||
|
function stop({
|
||||||
|
igi
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const connection = getVoiceConnection(igi);
|
||||||
|
connection.destroy();
|
||||||
|
} catch (err) {
|
||||||
|
ERR();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export {
|
||||||
|
start,
|
||||||
|
stop
|
||||||
|
};
|
||||||
Generated
+2539
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "discord-audio-stream",
|
||||||
|
"version": "0.2.0",
|
||||||
|
"description": "🖼️ NPM Package to stream any audio link on discord.",
|
||||||
|
"main": "./dist/index.js",
|
||||||
|
"module": "./dist/index.mjs",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsup"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/FrauJulian/discord-audio-stream.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"discordjs-v14",
|
||||||
|
"stream",
|
||||||
|
"audio",
|
||||||
|
"music"
|
||||||
|
],
|
||||||
|
"author": "FrauJulian | Julian Lechner",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/FrauJulian/discord-audio-stream/issues"
|
||||||
|
},
|
||||||
|
"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",
|
||||||
|
"ffmpeg-static": "^5.2.0",
|
||||||
|
"fs": "^0.0.1-security",
|
||||||
|
"libsodium-wrappers": "^0.7.13",
|
||||||
|
"opusscript": "^0.0.8"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
|
||||||
|
import { ERR, startParameters } from "../managers/UtilityManager";
|
||||||
|
|
||||||
|
import { join } from "node:path";
|
||||||
|
|
||||||
|
export function start({
|
||||||
|
imvci,
|
||||||
|
igi,
|
||||||
|
igv,
|
||||||
|
type,
|
||||||
|
Resource,
|
||||||
|
}: startParameters) {
|
||||||
|
try {
|
||||||
|
const AudioPlayer = createAudioPlayer();
|
||||||
|
|
||||||
|
function streamFile(FILE: string) {
|
||||||
|
let Audio = createAudioResource(join(__dirname, FILE), { inlineVolume: true });
|
||||||
|
AudioPlayer.play(Audio);
|
||||||
|
|
||||||
|
joinVoiceChannel({
|
||||||
|
channelId: imvci,
|
||||||
|
guildId: igi,
|
||||||
|
adapterCreator: igv
|
||||||
|
}).subscribe(AudioPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
function streamLink(URL: string) {
|
||||||
|
let Audio = createAudioResource(URL);
|
||||||
|
AudioPlayer.play(Audio);
|
||||||
|
|
||||||
|
joinVoiceChannel({
|
||||||
|
channelId: imvci,
|
||||||
|
guildId: igi,
|
||||||
|
adapterCreator: igv
|
||||||
|
}).subscribe(AudioPlayer)
|
||||||
|
}
|
||||||
|
|
||||||
|
function LinkValidation(URL: string) {
|
||||||
|
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');
|
||||||
|
|
||||||
|
return URLPattern.test(URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileValidation(FILE: string) {
|
||||||
|
var FILEPattern = new RegExp("^(.+)\/([^\/]+)$");
|
||||||
|
|
||||||
|
return FILEPattern.test(FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case "Link":
|
||||||
|
if(LinkValidation(Resource) === true && FileValidation(Resource) === false) {
|
||||||
|
streamLink(Resource);
|
||||||
|
} else {
|
||||||
|
ERR();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "File":
|
||||||
|
if(LinkValidation(Resource) === false && FileValidation(Resource) === true) {
|
||||||
|
streamFile(Resource);
|
||||||
|
} else {
|
||||||
|
ERR();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "Analyze":
|
||||||
|
if(LinkValidation(Resource) === true && FileValidation(Resource) === false) {
|
||||||
|
streamLink(Resource);
|
||||||
|
} else if(LinkValidation(Resource) === false && FileValidation(Resource) === true) {
|
||||||
|
streamFile(Resource)
|
||||||
|
} else {
|
||||||
|
ERR();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERR();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
ERR(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
const { getVoiceConnection } = require("@discordjs/voice");
|
||||||
|
import { ERR, stopParameter } from "../managers/UtilityManager";
|
||||||
|
|
||||||
|
export function stop({
|
||||||
|
igi,
|
||||||
|
}: stopParameter) {
|
||||||
|
try {
|
||||||
|
const connection = getVoiceConnection(igi);
|
||||||
|
|
||||||
|
connection.destroy();
|
||||||
|
} catch (err) {
|
||||||
|
ERR();
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./managers/FuncManager";
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from "../functions/startFunc";
|
||||||
|
export * from "../functions/stopFunc";
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export * from "../utility/errorFunc";
|
||||||
|
export * from "../utility/startParameters";
|
||||||
|
export * from "../utility/stopParameter";
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
export function ERR(err?: unknown) {
|
||||||
|
console.error(" ")
|
||||||
|
console.error(" ______ _____ _____ ____ _____ \r\n | ____| __ \\| __ \\ \/ __ \\| __ \\ \r\n | |__ | |__) | |__) | | | | |__) |\r\n | __| | _ \/| _ \/| | | | _ \/ \r\n | |____| | \\ \\| | \\ \\| |__| | | \\ \\ \r\n |______|_| \\_\\_| \\_\\\\____\/|_| \\_\\")
|
||||||
|
console.error(" ")
|
||||||
|
console.error("This error comes from the discord-audio-stream package!")
|
||||||
|
console.error("This error occurs if you are not using the package correctly, sometimes it can also be bugs in the package.")
|
||||||
|
console.error(" ")
|
||||||
|
console.error("See the docs or open a issue post on github.")
|
||||||
|
console.error(" ")
|
||||||
|
if (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export type startParameters = {
|
||||||
|
imvci: number;
|
||||||
|
igi: number;
|
||||||
|
igv: number;
|
||||||
|
type: string;
|
||||||
|
Resource: string;
|
||||||
|
};
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export type stopParameter = {
|
||||||
|
igi: number;
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"strict": true,
|
||||||
|
"allowJs": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"target": "ES2022",
|
||||||
|
"moduleResolution": "Node",
|
||||||
|
"module": "CommonJS",
|
||||||
|
"declaration": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"outDir": "dist",
|
||||||
|
"types": [
|
||||||
|
"node"
|
||||||
|
],
|
||||||
|
"typeRoots": [
|
||||||
|
"node_modules/@types"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": ["node_modules"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { defineConfig } from "tsup";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
format: [ "cjs", "esm" ],
|
||||||
|
entry: ["./src/index.ts"],
|
||||||
|
dts: true,
|
||||||
|
shims: true,
|
||||||
|
skipNodeModulesBundle: true,
|
||||||
|
clean: true,
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user