Add files via upload
This commit is contained in:
@@ -29,26 +29,36 @@ yarn add discord-audio-stream
|
||||
|
||||
### Code Snippet - Start
|
||||
```js
|
||||
const Audio = require("discord-audio-stream");
|
||||
const AudioStream = 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
|
||||
AudioStream.start({
|
||||
VoiceChannelID: 0, //Integer | Voice Channel ID | e.g interaction.member.voice.channel.id
|
||||
GuildID: 0, //Integer | Guild ID | e.g interaction.guild.id
|
||||
VoiceAdapter: 0, //Integer | Voice Adapter Creator | e.g interaction.guild.voiceAdapterCreator
|
||||
Type: "", //String | choose the Audio Resource [File or Link or Analyze] | Analyze
|
||||
Resource: "", //String | Audio Stream Link or File Location | e.g https://synradiode.stream.laut.fm/synradiode
|
||||
})
|
||||
```
|
||||
|
||||
### Code Snippet - Stop
|
||||
```js
|
||||
const Audio = require("discord-audio-stream");
|
||||
const AudioStream = require("discord-audio-stream");
|
||||
|
||||
Audio.StreamStart({
|
||||
igi: 0, //Guild ID e.g. interaction.guild.id
|
||||
AudioStream.stop({
|
||||
GuildID: 0, //Integer | Guild ID | e.g interaction.guild.id
|
||||
})
|
||||
```
|
||||
|
||||
### Code Snippet - Set Max Listeners
|
||||
```js
|
||||
const AudioStream = require("discord-audio-stream");
|
||||
|
||||
AudioStream.setMaxListeners({
|
||||
GuildID: 0, //Integer | Guild ID | e.g interaction.guild.id
|
||||
MaxListeners: 0, //Integer | max Listeners | e.g 30
|
||||
})
|
||||
```
|
||||
|
||||
## 🤝 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!
|
||||
Give it a star ⭐ on [github](https://github.com/FrauJulian/discord-audio-stream) or [buy](https://buymeacoffee.com/fraujuliannn) a hot chocolate!
|
||||
Vendored
+15
-8
@@ -1,17 +1,24 @@
|
||||
type startParameters = {
|
||||
imvci: number;
|
||||
igi: number;
|
||||
igv: number;
|
||||
type: string;
|
||||
VoiceChannelID: number;
|
||||
GuildID: number;
|
||||
VoiceAdapter: number;
|
||||
Type: string;
|
||||
Resource: string;
|
||||
};
|
||||
|
||||
type stopParameter = {
|
||||
igi: number;
|
||||
GuildID: number;
|
||||
};
|
||||
|
||||
declare function start({ imvci, igi, igv, type, Resource, }: startParameters): void;
|
||||
type maxListenerParameter = {
|
||||
GuildID: number;
|
||||
MaxListeners: number;
|
||||
};
|
||||
|
||||
declare function stop({ igi, }: stopParameter): void;
|
||||
declare function start({ VoiceChannelID, GuildID, VoiceAdapter, Type, Resource, }: startParameters): void;
|
||||
|
||||
export { start, stop };
|
||||
declare function stop({ GuildID, }: stopParameter): void;
|
||||
|
||||
declare function setMaxListeners({ GuildID, MaxListeners, }: maxListenerParameter): void;
|
||||
|
||||
export { setMaxListeners, start, stop };
|
||||
|
||||
Vendored
+15
-8
@@ -1,17 +1,24 @@
|
||||
type startParameters = {
|
||||
imvci: number;
|
||||
igi: number;
|
||||
igv: number;
|
||||
type: string;
|
||||
VoiceChannelID: number;
|
||||
GuildID: number;
|
||||
VoiceAdapter: number;
|
||||
Type: string;
|
||||
Resource: string;
|
||||
};
|
||||
|
||||
type stopParameter = {
|
||||
igi: number;
|
||||
GuildID: number;
|
||||
};
|
||||
|
||||
declare function start({ imvci, igi, igv, type, Resource, }: startParameters): void;
|
||||
type maxListenerParameter = {
|
||||
GuildID: number;
|
||||
MaxListeners: number;
|
||||
};
|
||||
|
||||
declare function stop({ igi, }: stopParameter): void;
|
||||
declare function start({ VoiceChannelID, GuildID, VoiceAdapter, Type, Resource, }: startParameters): void;
|
||||
|
||||
export { start, stop };
|
||||
declare function stop({ GuildID, }: stopParameter): void;
|
||||
|
||||
declare function setMaxListeners({ GuildID, MaxListeners, }: maxListenerParameter): void;
|
||||
|
||||
export { setMaxListeners, start, stop };
|
||||
|
||||
Vendored
+34
-26
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
setMaxListeners: () => setMaxListeners,
|
||||
start: () => start,
|
||||
stop: () => stop
|
||||
});
|
||||
@@ -44,10 +45,10 @@ function ERR(err) {
|
||||
var import_node_path = require("path");
|
||||
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
|
||||
function start({
|
||||
imvci,
|
||||
igi,
|
||||
igv,
|
||||
type,
|
||||
VoiceChannelID,
|
||||
GuildID,
|
||||
VoiceAdapter,
|
||||
Type,
|
||||
Resource
|
||||
}) {
|
||||
try {
|
||||
@@ -55,17 +56,17 @@ function start({
|
||||
let Audio = createAudioResource((0, import_node_path.join)(__dirname, FILE), { inlineVolume: true });
|
||||
AudioPlayer.play(Audio);
|
||||
joinVoiceChannel({
|
||||
channelId: imvci,
|
||||
guildId: igi,
|
||||
adapterCreator: igv
|
||||
channelId: VoiceChannelID,
|
||||
guildId: GuildID,
|
||||
adapterCreator: VoiceAdapter
|
||||
}).subscribe(AudioPlayer);
|
||||
}, streamLink2 = function(URL) {
|
||||
let Audio = createAudioResource(URL);
|
||||
AudioPlayer.play(Audio);
|
||||
joinVoiceChannel({
|
||||
channelId: imvci,
|
||||
guildId: igi,
|
||||
adapterCreator: igv
|
||||
channelId: VoiceChannelID,
|
||||
guildId: GuildID,
|
||||
adapterCreator: VoiceAdapter
|
||||
}).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");
|
||||
@@ -76,25 +77,17 @@ function start({
|
||||
};
|
||||
var streamFile = streamFile2, streamLink = streamLink2, LinkValidation = LinkValidation2, FileValidation = FileValidation2;
|
||||
const AudioPlayer = createAudioPlayer();
|
||||
switch (type) {
|
||||
switch (Type) {
|
||||
case "Link":
|
||||
if (LinkValidation2(Resource) === true && FileValidation2(Resource) === false) {
|
||||
streamLink2(Resource);
|
||||
} else {
|
||||
ERR();
|
||||
}
|
||||
streamLink2(Resource);
|
||||
break;
|
||||
case "File":
|
||||
if (LinkValidation2(Resource) === false && FileValidation2(Resource) === true) {
|
||||
streamFile2(Resource);
|
||||
} else {
|
||||
ERR();
|
||||
}
|
||||
streamFile2(Resource);
|
||||
break;
|
||||
case "Analyze":
|
||||
if (LinkValidation2(Resource) === true && FileValidation2(Resource) === false) {
|
||||
if (LinkValidation2(Resource)) {
|
||||
streamLink2(Resource);
|
||||
} else if (LinkValidation2(Resource) === false && FileValidation2(Resource) === true) {
|
||||
} else if (FileValidation2(Resource)) {
|
||||
streamFile2(Resource);
|
||||
} else {
|
||||
ERR();
|
||||
@@ -112,17 +105,32 @@ function start({
|
||||
// src/functions/stopFunc.ts
|
||||
var { getVoiceConnection } = require("@discordjs/voice");
|
||||
function stop({
|
||||
igi
|
||||
GuildID
|
||||
}) {
|
||||
try {
|
||||
const connection = getVoiceConnection(igi);
|
||||
const connection = getVoiceConnection(GuildID);
|
||||
connection.destroy();
|
||||
} catch (err) {
|
||||
ERR();
|
||||
ERR(err);
|
||||
}
|
||||
}
|
||||
|
||||
// src/functions/maxListenersFunc.ts
|
||||
var { getVoiceConnection: getVoiceConnection2 } = require("@discordjs/voice");
|
||||
function setMaxListeners({
|
||||
GuildID,
|
||||
MaxListeners
|
||||
}) {
|
||||
try {
|
||||
const connection = getVoiceConnection2(GuildID);
|
||||
connection.setMaxListeners(MaxListeners);
|
||||
} catch (err) {
|
||||
ERR(err);
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
setMaxListeners,
|
||||
start,
|
||||
stop
|
||||
});
|
||||
|
||||
Vendored
+33
-26
@@ -31,10 +31,10 @@ function ERR(err) {
|
||||
import { join } from "node:path";
|
||||
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = __require("@discordjs/voice");
|
||||
function start({
|
||||
imvci,
|
||||
igi,
|
||||
igv,
|
||||
type,
|
||||
VoiceChannelID,
|
||||
GuildID,
|
||||
VoiceAdapter,
|
||||
Type,
|
||||
Resource
|
||||
}) {
|
||||
try {
|
||||
@@ -42,17 +42,17 @@ function start({
|
||||
let Audio = createAudioResource(join(__dirname, FILE), { inlineVolume: true });
|
||||
AudioPlayer.play(Audio);
|
||||
joinVoiceChannel({
|
||||
channelId: imvci,
|
||||
guildId: igi,
|
||||
adapterCreator: igv
|
||||
channelId: VoiceChannelID,
|
||||
guildId: GuildID,
|
||||
adapterCreator: VoiceAdapter
|
||||
}).subscribe(AudioPlayer);
|
||||
}, streamLink2 = function(URL) {
|
||||
let Audio = createAudioResource(URL);
|
||||
AudioPlayer.play(Audio);
|
||||
joinVoiceChannel({
|
||||
channelId: imvci,
|
||||
guildId: igi,
|
||||
adapterCreator: igv
|
||||
channelId: VoiceChannelID,
|
||||
guildId: GuildID,
|
||||
adapterCreator: VoiceAdapter
|
||||
}).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");
|
||||
@@ -63,25 +63,17 @@ function start({
|
||||
};
|
||||
var streamFile = streamFile2, streamLink = streamLink2, LinkValidation = LinkValidation2, FileValidation = FileValidation2;
|
||||
const AudioPlayer = createAudioPlayer();
|
||||
switch (type) {
|
||||
switch (Type) {
|
||||
case "Link":
|
||||
if (LinkValidation2(Resource) === true && FileValidation2(Resource) === false) {
|
||||
streamLink2(Resource);
|
||||
} else {
|
||||
ERR();
|
||||
}
|
||||
streamLink2(Resource);
|
||||
break;
|
||||
case "File":
|
||||
if (LinkValidation2(Resource) === false && FileValidation2(Resource) === true) {
|
||||
streamFile2(Resource);
|
||||
} else {
|
||||
ERR();
|
||||
}
|
||||
streamFile2(Resource);
|
||||
break;
|
||||
case "Analyze":
|
||||
if (LinkValidation2(Resource) === true && FileValidation2(Resource) === false) {
|
||||
if (LinkValidation2(Resource)) {
|
||||
streamLink2(Resource);
|
||||
} else if (LinkValidation2(Resource) === false && FileValidation2(Resource) === true) {
|
||||
} else if (FileValidation2(Resource)) {
|
||||
streamFile2(Resource);
|
||||
} else {
|
||||
ERR();
|
||||
@@ -99,16 +91,31 @@ function start({
|
||||
// src/functions/stopFunc.ts
|
||||
var { getVoiceConnection } = __require("@discordjs/voice");
|
||||
function stop({
|
||||
igi
|
||||
GuildID
|
||||
}) {
|
||||
try {
|
||||
const connection = getVoiceConnection(igi);
|
||||
const connection = getVoiceConnection(GuildID);
|
||||
connection.destroy();
|
||||
} catch (err) {
|
||||
ERR();
|
||||
ERR(err);
|
||||
}
|
||||
}
|
||||
|
||||
// src/functions/maxListenersFunc.ts
|
||||
var { getVoiceConnection: getVoiceConnection2 } = __require("@discordjs/voice");
|
||||
function setMaxListeners({
|
||||
GuildID,
|
||||
MaxListeners
|
||||
}) {
|
||||
try {
|
||||
const connection = getVoiceConnection2(GuildID);
|
||||
connection.setMaxListeners(MaxListeners);
|
||||
} catch (err) {
|
||||
ERR(err);
|
||||
}
|
||||
}
|
||||
export {
|
||||
setMaxListeners,
|
||||
start,
|
||||
stop
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "discord-audio-stream",
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.2",
|
||||
"description": "🖼️ NPM Package to stream any audio link on discord.",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
const { getVoiceConnection } = require("@discordjs/voice");
|
||||
import { ERR, maxListenerParameter } from "../managers/UtilityManager";
|
||||
|
||||
export function setMaxListeners({
|
||||
GuildID,
|
||||
MaxListeners,
|
||||
}: maxListenerParameter) {
|
||||
try {
|
||||
const connection = getVoiceConnection(GuildID);
|
||||
connection.setMaxListeners(MaxListeners);
|
||||
} catch (err) {
|
||||
ERR(err);
|
||||
}
|
||||
};
|
||||
+27
-35
@@ -1,13 +1,13 @@
|
||||
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
|
||||
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,
|
||||
VoiceChannelID,
|
||||
GuildID,
|
||||
VoiceAdapter,
|
||||
Type,
|
||||
Resource,
|
||||
}: startParameters) {
|
||||
try {
|
||||
@@ -16,32 +16,32 @@ export function start({
|
||||
function streamFile(FILE: string) {
|
||||
let Audio = createAudioResource(join(__dirname, FILE), { inlineVolume: true });
|
||||
AudioPlayer.play(Audio);
|
||||
|
||||
|
||||
joinVoiceChannel({
|
||||
channelId: imvci,
|
||||
guildId: igi,
|
||||
adapterCreator: igv
|
||||
channelId: VoiceChannelID,
|
||||
guildId: GuildID,
|
||||
adapterCreator: VoiceAdapter
|
||||
}).subscribe(AudioPlayer);
|
||||
}
|
||||
|
||||
function streamLink(URL: string) {
|
||||
let Audio = createAudioResource(URL);
|
||||
AudioPlayer.play(Audio);
|
||||
AudioPlayer.play(Audio);
|
||||
|
||||
joinVoiceChannel({
|
||||
channelId: imvci,
|
||||
guildId: igi,
|
||||
adapterCreator: igv
|
||||
joinVoiceChannel({
|
||||
channelId: VoiceChannelID,
|
||||
guildId: GuildID,
|
||||
adapterCreator: VoiceAdapter
|
||||
}).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');
|
||||
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);
|
||||
}
|
||||
@@ -52,31 +52,23 @@ export function start({
|
||||
return FILEPattern.test(FILE);
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
switch (Type) {
|
||||
case "Link":
|
||||
if(LinkValidation(Resource) === true && FileValidation(Resource) === false) {
|
||||
streamLink(Resource);
|
||||
} else {
|
||||
ERR();
|
||||
}
|
||||
break;
|
||||
streamLink(Resource);
|
||||
break;
|
||||
case "File":
|
||||
if(LinkValidation(Resource) === false && FileValidation(Resource) === true) {
|
||||
streamFile(Resource);
|
||||
} else {
|
||||
ERR();
|
||||
}
|
||||
streamFile(Resource);
|
||||
break;
|
||||
case "Analyze":
|
||||
if(LinkValidation(Resource) === true && FileValidation(Resource) === false) {
|
||||
if (LinkValidation(Resource)) {
|
||||
streamLink(Resource);
|
||||
} else if(LinkValidation(Resource) === false && FileValidation(Resource) === true) {
|
||||
} else if (FileValidation(Resource)) {
|
||||
streamFile(Resource)
|
||||
} else {
|
||||
ERR();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
ERR();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2,13 +2,12 @@ const { getVoiceConnection } = require("@discordjs/voice");
|
||||
import { ERR, stopParameter } from "../managers/UtilityManager";
|
||||
|
||||
export function stop({
|
||||
igi,
|
||||
GuildID,
|
||||
}: stopParameter) {
|
||||
try {
|
||||
const connection = getVoiceConnection(igi);
|
||||
|
||||
const connection = getVoiceConnection(GuildID);
|
||||
connection.destroy();
|
||||
} catch (err) {
|
||||
ERR();
|
||||
ERR(err);
|
||||
}
|
||||
};
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "../functions/startFunc";
|
||||
export * from "../functions/stopFunc";
|
||||
export * from "../functions/stopFunc";
|
||||
export * from "../functions/maxListenersFunc";
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "../utility/errorFunc";
|
||||
export * from "../utility/startParameters";
|
||||
export * from "../utility/stopParameter";
|
||||
export * from "../utility/stopParameter";
|
||||
export * from "../utility/maxListenerParameter";
|
||||
@@ -0,0 +1,4 @@
|
||||
export type maxListenerParameter = {
|
||||
GuildID: number;
|
||||
MaxListeners: number;
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
export type startParameters = {
|
||||
imvci: number;
|
||||
igi: number;
|
||||
igv: number;
|
||||
type: string;
|
||||
VoiceChannelID: number;
|
||||
GuildID: number;
|
||||
VoiceAdapter: number;
|
||||
Type: string;
|
||||
Resource: string;
|
||||
};
|
||||
@@ -1,3 +1,3 @@
|
||||
export type stopParameter = {
|
||||
igi: number;
|
||||
GuildID: number;
|
||||
};
|
||||
Reference in New Issue
Block a user