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
|
## 📝 Usage
|
||||||
|
|
||||||
### Install Package
|
### Install package
|
||||||
```
|
```
|
||||||
npm i discord-audio-stream
|
npm i discord-audio-stream
|
||||||
```
|
```
|
||||||
@@ -27,7 +27,7 @@ or
|
|||||||
yarn add discord-audio-stream
|
yarn add discord-audio-stream
|
||||||
```
|
```
|
||||||
|
|
||||||
### Start Audio Stream
|
### Code Snippet - Start
|
||||||
```js
|
```js
|
||||||
const Audio = require("discord-audio-stream");
|
const Audio = require("discord-audio-stream");
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ Audio.StreamStart({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Stop Audio Stream
|
### Code Snippet - Stop
|
||||||
```js
|
```js
|
||||||
const Audio = require("discord-audio-stream");
|
const Audio = require("discord-audio-stream");
|
||||||
|
|
||||||
@@ -51,4 +51,4 @@ Audio.StreamStart({
|
|||||||
|
|
||||||
## 🤝 Enjoy the package?
|
## 🤝 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";
|
"use strict";
|
||||||
var __create = Object.create;
|
|
||||||
var __defProp = Object.defineProperty;
|
var __defProp = Object.defineProperty;
|
||||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||||
var __getProtoOf = Object.getPrototypeOf;
|
|
||||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||||
var __export = (target, all) => {
|
var __export = (target, all) => {
|
||||||
for (var name in all)
|
for (var name in all)
|
||||||
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|||||||
}
|
}
|
||||||
return to;
|
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);
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||||
|
|
||||||
// src/index.ts
|
// src/index.ts
|
||||||
@@ -38,7 +28,7 @@ module.exports = __toCommonJS(src_exports);
|
|||||||
// src/stuff/error.ts
|
// src/stuff/error.ts
|
||||||
function ERROR() {
|
function ERROR() {
|
||||||
console.log(" ");
|
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(" ");
|
||||||
console.log("This error comes from the discord-audio-stream package!");
|
console.log("This error comes from the discord-audio-stream package!");
|
||||||
console.log("This error happens if you don't use the package right.");
|
console.log("This error happens if you don't use the package right.");
|
||||||
@@ -48,8 +38,8 @@ function ERROR() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/functions/start.ts
|
// src/functions/start.ts
|
||||||
var import_fs = __toESM(require("fs"));
|
|
||||||
var import_node_path = require("path");
|
var import_node_path = require("path");
|
||||||
|
var Source = "";
|
||||||
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
|
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
|
||||||
function StreamStart({
|
function StreamStart({
|
||||||
imvci,
|
imvci,
|
||||||
@@ -60,9 +50,10 @@ function StreamStart({
|
|||||||
}) {
|
}) {
|
||||||
try {
|
try {
|
||||||
let FileResource2 = function() {
|
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);
|
AudioPlayer.play(Audio);
|
||||||
joinVoiceChannel({
|
joinVoiceChannel({
|
||||||
|
//Join the channel.
|
||||||
channelId: imvci,
|
channelId: imvci,
|
||||||
guildId: igi,
|
guildId: igi,
|
||||||
adapterCreator: igv
|
adapterCreator: igv
|
||||||
@@ -71,6 +62,7 @@ function StreamStart({
|
|||||||
let Audio = createAudioResource(Resource);
|
let Audio = createAudioResource(Resource);
|
||||||
AudioPlayer.play(Audio);
|
AudioPlayer.play(Audio);
|
||||||
joinVoiceChannel({
|
joinVoiceChannel({
|
||||||
|
//Join the channel.
|
||||||
channelId: imvci,
|
channelId: imvci,
|
||||||
guildId: igi,
|
guildId: igi,
|
||||||
adapterCreator: igv
|
adapterCreator: igv
|
||||||
@@ -78,23 +70,71 @@ function StreamStart({
|
|||||||
};
|
};
|
||||||
var FileResource = FileResource2, LinkResource = LinkResource2;
|
var FileResource = FileResource2, LinkResource = LinkResource2;
|
||||||
const AudioPlayer = createAudioPlayer();
|
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") {
|
if (type === "Link") {
|
||||||
LinkResource2();
|
if (URLPattern.test(Resource) === true) {
|
||||||
} else if (type === "File") {
|
|
||||||
FileResource2();
|
|
||||||
} else if (type === "Analyze") {
|
|
||||||
if (import_fs.default.existsSync(Resource)) {
|
|
||||||
FileResource2();
|
|
||||||
} else {
|
|
||||||
LinkResource2();
|
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 {
|
} else {
|
||||||
ERROR();
|
ERROR();
|
||||||
|
console.log("CODE: Unknown resource type!");
|
||||||
|
console.log(" ");
|
||||||
|
const result = new Promise((resolve2, reject) => {
|
||||||
|
resolve2("Unknown");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ERROR();
|
ERROR();
|
||||||
console.log("ERR:\n" + error);
|
console.log(">> ERR:\n" + error);
|
||||||
console.log(" ");
|
console.log(" ");
|
||||||
|
const result = new Promise((resolve2, reject) => {
|
||||||
|
resolve2("ERROR");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,10 +145,10 @@ function StreamStop({
|
|||||||
}) {
|
}) {
|
||||||
try {
|
try {
|
||||||
const connection = getVoiceConnection(igi);
|
const connection = getVoiceConnection(igi);
|
||||||
connection.disconnect();
|
connection.destroy();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ERROR();
|
ERROR();
|
||||||
console.log("ERR:\n" + error);
|
console.log(">> ERR:\n" + error);
|
||||||
console.log(" ");
|
console.log(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+63
-13
@@ -16,7 +16,7 @@ var __dirname = /* @__PURE__ */ getDirname();
|
|||||||
// src/stuff/error.ts
|
// src/stuff/error.ts
|
||||||
function ERROR() {
|
function ERROR() {
|
||||||
console.log(" ");
|
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(" ");
|
||||||
console.log("This error comes from the discord-audio-stream package!");
|
console.log("This error comes from the discord-audio-stream package!");
|
||||||
console.log("This error happens if you don't use the package right.");
|
console.log("This error happens if you don't use the package right.");
|
||||||
@@ -26,8 +26,8 @@ function ERROR() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/functions/start.ts
|
// src/functions/start.ts
|
||||||
import fs from "fs";
|
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
var Source = "";
|
||||||
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = __require("@discordjs/voice");
|
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = __require("@discordjs/voice");
|
||||||
function StreamStart({
|
function StreamStart({
|
||||||
imvci,
|
imvci,
|
||||||
@@ -38,9 +38,10 @@ function StreamStart({
|
|||||||
}) {
|
}) {
|
||||||
try {
|
try {
|
||||||
let FileResource2 = function() {
|
let FileResource2 = function() {
|
||||||
let Audio = createAudioResource(join(__dirname, Resource), { inlineVolume: true });
|
let Audio = createAudioResource(join(__dirname, Source));
|
||||||
AudioPlayer.play(Audio);
|
AudioPlayer.play(Audio);
|
||||||
joinVoiceChannel({
|
joinVoiceChannel({
|
||||||
|
//Join the channel.
|
||||||
channelId: imvci,
|
channelId: imvci,
|
||||||
guildId: igi,
|
guildId: igi,
|
||||||
adapterCreator: igv
|
adapterCreator: igv
|
||||||
@@ -49,6 +50,7 @@ function StreamStart({
|
|||||||
let Audio = createAudioResource(Resource);
|
let Audio = createAudioResource(Resource);
|
||||||
AudioPlayer.play(Audio);
|
AudioPlayer.play(Audio);
|
||||||
joinVoiceChannel({
|
joinVoiceChannel({
|
||||||
|
//Join the channel.
|
||||||
channelId: imvci,
|
channelId: imvci,
|
||||||
guildId: igi,
|
guildId: igi,
|
||||||
adapterCreator: igv
|
adapterCreator: igv
|
||||||
@@ -56,23 +58,71 @@ function StreamStart({
|
|||||||
};
|
};
|
||||||
var FileResource = FileResource2, LinkResource = LinkResource2;
|
var FileResource = FileResource2, LinkResource = LinkResource2;
|
||||||
const AudioPlayer = createAudioPlayer();
|
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") {
|
if (type === "Link") {
|
||||||
LinkResource2();
|
if (URLPattern.test(Resource) === true) {
|
||||||
} else if (type === "File") {
|
|
||||||
FileResource2();
|
|
||||||
} else if (type === "Analyze") {
|
|
||||||
if (fs.existsSync(Resource)) {
|
|
||||||
FileResource2();
|
|
||||||
} else {
|
|
||||||
LinkResource2();
|
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 {
|
} else {
|
||||||
ERROR();
|
ERROR();
|
||||||
|
console.log("CODE: Unknown resource type!");
|
||||||
|
console.log(" ");
|
||||||
|
const result = new Promise((resolve2, reject) => {
|
||||||
|
resolve2("Unknown");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ERROR();
|
ERROR();
|
||||||
console.log("ERR:\n" + error);
|
console.log(">> ERR:\n" + error);
|
||||||
console.log(" ");
|
console.log(" ");
|
||||||
|
const result = new Promise((resolve2, reject) => {
|
||||||
|
resolve2("ERROR");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,10 +133,10 @@ function StreamStop({
|
|||||||
}) {
|
}) {
|
||||||
try {
|
try {
|
||||||
const connection = getVoiceConnection(igi);
|
const connection = getVoiceConnection(igi);
|
||||||
connection.disconnect();
|
connection.destroy();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ERROR();
|
ERROR();
|
||||||
console.log("ERR:\n" + error);
|
console.log(">> ERR:\n" + error);
|
||||||
console.log(" ");
|
console.log(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+13
-19
@@ -1,23 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "discord-audio-stream",
|
"name": "discord-audio-stream",
|
||||||
"version": "0.0.3",
|
"version": "0.1.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "discord-audio-stream",
|
"name": "discord-audio-stream",
|
||||||
"version": "0.0.3",
|
"version": "0.1.0",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/voice": "^0.16.1",
|
"@discordjs/voice": "^0.16.1",
|
||||||
"discord.js": "^14.14.1",
|
"discord.js": "^14.14.1",
|
||||||
"ffmpeg": "^0.0.4",
|
|
||||||
"ffmpeg-static": "^5.2.0",
|
"ffmpeg-static": "^5.2.0",
|
||||||
"fs": "^0.0.1-security",
|
"fs": "^0.0.1-security",
|
||||||
"libsodium-wrappers": "^0.7.13",
|
"libsodium-wrappers": "^0.7.13",
|
||||||
"opusscript": "^0.0.8"
|
"opusscript": "^0.0.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/ejs": "^3.1.5",
|
||||||
|
"@types/node": "^20.12.8",
|
||||||
"tsup": "^8.0.2",
|
"tsup": "^8.0.2",
|
||||||
"typescript": "^5.4.5"
|
"typescript": "^5.4.5"
|
||||||
}
|
}
|
||||||
@@ -873,6 +874,12 @@
|
|||||||
"npm": ">=7.0.0"
|
"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": {
|
"node_modules/@types/estree": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
|
||||||
@@ -880,9 +887,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "20.12.7",
|
"version": "20.12.8",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.8.tgz",
|
||||||
"integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==",
|
"integrity": "sha512-NU0rJLJnshZWdE/097cdCBbyW1h4hEg0xpovcoAQYHl8dnEyp/NAOiE45pvc+Bd1Dt+2r94v2eGFpQJ4R7g+2w==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~5.26.4"
|
"undici-types": "~5.26.4"
|
||||||
}
|
}
|
||||||
@@ -1315,14 +1322,6 @@
|
|||||||
"reusify": "^1.0.4"
|
"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": {
|
"node_modules/ffmpeg-static": {
|
||||||
"version": "5.2.0",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/ffmpeg-static/-/ffmpeg-static-5.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/ffmpeg-static/-/ffmpeg-static-5.2.0.tgz",
|
||||||
@@ -2437,11 +2436,6 @@
|
|||||||
"webidl-conversions": "^4.0.2"
|
"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": {
|
"node_modules/which": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
|
|||||||
+5
-3
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "discord-audio-stream",
|
"name": "discord-audio-stream",
|
||||||
"version": "0.0.3",
|
"version": "0.1.0",
|
||||||
"description": "🖼️ NPM Package to stream any audio link on discord.",
|
"description": "🖼️ NPM Package to stream any audio link on discord.",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
@@ -15,7 +15,8 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"discordjs-v14",
|
"discordjs-v14",
|
||||||
"stream",
|
"stream",
|
||||||
"audio"
|
"audio",
|
||||||
|
"music"
|
||||||
],
|
],
|
||||||
"author": "FrauJulian | Julian Lechner",
|
"author": "FrauJulian | Julian Lechner",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
@@ -24,13 +25,14 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/FrauJulian/discord-audio-stream#readme",
|
"homepage": "https://github.com/FrauJulian/discord-audio-stream#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/ejs": "^3.1.5",
|
||||||
|
"@types/node": "^20.12.8",
|
||||||
"tsup": "^8.0.2",
|
"tsup": "^8.0.2",
|
||||||
"typescript": "^5.4.5"
|
"typescript": "^5.4.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/voice": "^0.16.1",
|
"@discordjs/voice": "^0.16.1",
|
||||||
"discord.js": "^14.14.1",
|
"discord.js": "^14.14.1",
|
||||||
"ffmpeg": "^0.0.4",
|
|
||||||
"ffmpeg-static": "^5.2.0",
|
"ffmpeg-static": "^5.2.0",
|
||||||
"fs": "^0.0.1-security",
|
"fs": "^0.0.1-security",
|
||||||
"libsodium-wrappers": "^0.7.13",
|
"libsodium-wrappers": "^0.7.13",
|
||||||
|
|||||||
+70
-32
@@ -1,8 +1,9 @@
|
|||||||
import { StartProps } from "../stuff/types";
|
import { StartProps } from "../stuff/types";
|
||||||
import { ERROR } from "../stuff/error";
|
import { ERROR } from "../stuff/error";
|
||||||
import fs from "fs";
|
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import { AudioPlayer } from "@discordjs/voice";
|
|
||||||
|
let Source = "";
|
||||||
|
|
||||||
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
|
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
|
||||||
|
|
||||||
@@ -17,52 +18,89 @@ export function StreamStart({
|
|||||||
//Create AudioPlayer variable.
|
//Create AudioPlayer variable.
|
||||||
const AudioPlayer = createAudioPlayer();
|
const AudioPlayer = createAudioPlayer();
|
||||||
|
|
||||||
//File Resource
|
//Play function for file resource.
|
||||||
function FileResource() {
|
function FileResource() {
|
||||||
|
|
||||||
let Audio = createAudioResource(join(__dirname, Resource), { inlineVolume: true });
|
let Audio = createAudioResource(join(__dirname, Source)); //Fetch stream File.
|
||||||
AudioPlayer.play(Audio);
|
AudioPlayer.play(Audio); //Set AudioPlayer to resource File.
|
||||||
|
|
||||||
joinVoiceChannel({
|
joinVoiceChannel({ //Join the channel.
|
||||||
channelId: imvci,
|
channelId: imvci,
|
||||||
guildId: igi,
|
guildId: igi,
|
||||||
adapterCreator: igv
|
adapterCreator: igv
|
||||||
}).subscribe(AudioPlayer);
|
}).subscribe(AudioPlayer); //AudioPlayer start playing audio.
|
||||||
}
|
}
|
||||||
|
|
||||||
//Link Resource
|
//Play function for link resource.
|
||||||
function LinkResource() {
|
function LinkResource() {
|
||||||
let Audio = createAudioResource(Resource);
|
let Audio = createAudioResource(Resource); //Fetch stream Link.
|
||||||
AudioPlayer.play(Audio);
|
AudioPlayer.play(Audio); //Set AudioPlayer to resource Link.
|
||||||
|
|
||||||
joinVoiceChannel({
|
joinVoiceChannel({ //Join the channel.
|
||||||
channelId: imvci,
|
channelId: imvci,
|
||||||
guildId: igi,
|
guildId: igi,
|
||||||
adapterCreator: igv
|
adapterCreator: igv
|
||||||
}).subscribe(AudioPlayer)
|
}).subscribe(AudioPlayer) //AudioPlayer start playing audio.
|
||||||
}
|
}
|
||||||
|
|
||||||
//If the type is "Link".
|
//URL Pattern to test if the resource is a link.
|
||||||
if (type === "Link") {
|
var URLPattern = new RegExp('^(https?:\\/\\/)?'+
|
||||||
LinkResource();
|
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|'+
|
||||||
//If the type is "File".
|
'((\\d{1,3}\\.){3}\\d{1,3}))'+
|
||||||
} else if (type === "File") {
|
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+
|
||||||
FileResource();
|
'(\\?[;&a-z\\d%_.~+=-]*)?'+
|
||||||
//If the type is "Analyze".
|
'(\\#[-a-z\\d_]*)?$','i');
|
||||||
} else if (type === "Analyze") {
|
|
||||||
if (fs.existsSync(Resource)) { //Check if Resource is a file and exist.
|
if (type === "Link") { //If the type is "Link".
|
||||||
FileResource();
|
|
||||||
} else { //If Resoure is not a file or doesn't exist.
|
if (URLPattern.test(Resource) === true) { //Check if Link is a URL.
|
||||||
LinkResource();
|
|
||||||
|
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.
|
} else if (type === "File") { //If the type is "File".
|
||||||
ERROR();
|
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.
|
} catch (error) { //If syntax is wrong.
|
||||||
ERROR();
|
ERROR(); //Run ERROR function.
|
||||||
console.log("ERR:\n" + error);
|
console.log(">> ERR:\n" + error); //Log the Error
|
||||||
console.log(" ");
|
console.log(" "); //Placeholder xD
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -14,8 +14,8 @@ export function StreamStop({
|
|||||||
connection.destroy();
|
connection.destroy();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ERROR();
|
ERROR(); //Run ERROR function.
|
||||||
console.log("ERR:\n" + error);
|
console.log(">> ERR:\n" + error); //Log the Error
|
||||||
console.log(" ");
|
console.log(" "); //Placeholder xD
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
//ERROR Message
|
//ERROR Message
|
||||||
export function ERROR() {
|
export function ERROR() {
|
||||||
console.log(" ");
|
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(" ");
|
||||||
console.log("This error comes from the discord-audio-stream package!");
|
console.log("This error comes from the discord-audio-stream package!");
|
||||||
console.log("This error happens if you don't use the package right.");
|
console.log("This error happens if you don't use the package right.");
|
||||||
|
|||||||
+11
-1
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
"allowJs": true,
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
@@ -8,10 +9,19 @@
|
|||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
"module": "CommonJS",
|
"module": "CommonJS",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"jsx": "react",
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"outDir": "dist"
|
"outDir": "dist",
|
||||||
|
"types": [
|
||||||
|
"node"
|
||||||
|
],
|
||||||
|
"typeRoots": [
|
||||||
|
"node_modules/@types"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
"include": ["src"],
|
"include": ["src"],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user