Add files via upload

This commit is contained in:
2024-05-03 20:35:26 +02:00
committed by GitHub
parent f8db6ca654
commit f9d503f6ae
14 changed files with 2951 additions and 87 deletions
+28
View File
@@ -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.
+55 -5
View File
@@ -1,5 +1,55 @@
# SOON
```
CODE
```
# Discord Audio Stream
[![npm](https://img.shields.io/npm/dw/discord-audio-stream)](http://npmjs.org/package/discord-audio-stream)
![GitHub package.json version](https://img.shields.io/github/package-json/v/FrauJulian/discord-audio-stream)
![GitHub Repo stars](https://img.shields.io/github/stars/FrauJulian/discord-audio-stream?style=social)
<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
```
npm i discord-audio-stream
```
or
```
yarn add discord-audio-stream
```
### Start Audio Stream
```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: Link, //Choose the Stream resource - File or Link
StreamFile: "", //Link to File e.g. ../assets/Stream.mp3
StreamLink: "" //Link to Audio Stream e.g. YouTube Video or LautFM Stream Link
})
```
### Stop Audio Stream
```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!
+15 -11
View File
@@ -1,13 +1,17 @@
declare function start({ firstName, lastName, age }: {
firstName: String;
lastName: String;
age: Number;
}): void;
type StartProps = {
imvci: number;
igi: number;
igv: number;
type: string;
StreamFile?: string;
StreamLink?: string;
};
type StopProps = {
igi: number;
};
declare function stop({ firstName, lastName, age }: {
firstName: String;
lastName: String;
age: Number;
}): void;
declare function StreamStart({ imvci, igi, igv, type, StreamFile, StreamLink }: StartProps): void;
export { start, stop };
declare function StreamStop({ igi, }: StopProps): void;
export { StreamStart, StreamStop };
+15 -11
View File
@@ -1,13 +1,17 @@
declare function start({ firstName, lastName, age }: {
firstName: String;
lastName: String;
age: Number;
}): void;
type StartProps = {
imvci: number;
igi: number;
igv: number;
type: string;
StreamFile?: string;
StreamLink?: string;
};
type StopProps = {
igi: number;
};
declare function stop({ firstName, lastName, age }: {
firstName: String;
lastName: String;
age: Number;
}): void;
declare function StreamStart({ imvci, igi, igv, type, StreamFile, StreamLink }: StartProps): void;
export { start, stop };
declare function StreamStop({ igi, }: StopProps): void;
export { StreamStart, StreamStop };
+66 -12
View File
@@ -20,24 +20,78 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
// src/index.ts
var src_exports = {};
__export(src_exports, {
start: () => start,
stop: () => stop
StreamStart: () => StreamStart,
StreamStop: () => StreamStop
});
module.exports = __toCommonJS(src_exports);
// src/start.ts
function start({ firstName, lastName, age }) {
console.log("Hello!");
console.log(firstName, lastName, age);
// src/stuff/error.ts
function ERROR() {
console.log(" ");
console.log(" ______ _____ _____ ____ _____ \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.");
console.log(" ");
console.log("See the docs or open a issue post on github.");
console.log(" ");
}
// src/stop.ts
function stop({ firstName, lastName, age }) {
console.log("Hello!");
console.log(firstName, lastName, age);
// src/functions/start.ts
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
var { join } = require("path");
function StreamStart({
imvci,
igi,
igv,
type,
StreamFile,
StreamLink
}) {
try {
const AudioPlayer = createAudioPlayer();
if (type === "File") {
let Audio = createAudioResource(StreamLink);
AudioPlayer.play(Audio);
joinVoiceChannel({
channelId: imvci,
guildId: igi,
adapterCreator: igv
}).subscribe(AudioPlayer);
} else if (type === "Link") {
const Audio = createAudioResource(join(__dirname, StreamFile));
AudioPlayer.play(Audio);
joinVoiceChannel({
channelId: imvci,
guildId: igi,
adapterCreator: igv
}).subscribe(AudioPlayer);
} else {
ERROR();
}
} catch (error) {
ERROR();
console.log("ERR:\n" + error);
console.log(" ");
}
}
// src/functions/stop.ts
var { getVoiceConnection } = require("@discordjs/voice");
function StreamStop({
igi
}) {
try {
const connection = getVoiceConnection(igi);
connection.disconnect();
} catch (error) {
ERROR();
console.log("ERR:\n" + error);
console.log(" ");
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
start,
stop
StreamStart,
StreamStop
});
+79 -10
View File
@@ -1,15 +1,84 @@
// src/start.ts
function start({ firstName, lastName, age }) {
console.log("Hello!");
console.log(firstName, lastName, age);
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/stuff/error.ts
function ERROR() {
console.log(" ");
console.log(" ______ _____ _____ ____ _____ \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.");
console.log(" ");
console.log("See the docs or open a issue post on github.");
console.log(" ");
}
// src/stop.ts
function stop({ firstName, lastName, age }) {
console.log("Hello!");
console.log(firstName, lastName, age);
// src/functions/start.ts
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = __require("@discordjs/voice");
var { join } = __require("node:path");
function StreamStart({
imvci,
igi,
igv,
type,
StreamFile,
StreamLink
}) {
try {
const AudioPlayer = createAudioPlayer();
if (type === "File") {
let Audio = createAudioResource(StreamLink);
AudioPlayer.play(Audio);
joinVoiceChannel({
channelId: imvci,
guildId: igi,
adapterCreator: igv
}).subscribe(AudioPlayer);
} else if (type === "Link") {
const Audio = createAudioResource(join(__dirname, StreamFile));
AudioPlayer.play(Audio);
joinVoiceChannel({
channelId: imvci,
guildId: igi,
adapterCreator: igv
}).subscribe(AudioPlayer);
} else {
ERROR();
}
} catch (error) {
ERROR();
console.log("ERR:\n" + error);
console.log(" ");
}
}
// src/functions/stop.ts
var { getVoiceConnection } = __require("@discordjs/voice");
function StreamStop({
igi
}) {
try {
const connection = getVoiceConnection(igi);
connection.disconnect();
} catch (error) {
ERROR();
console.log("ERR:\n" + error);
console.log(" ");
}
}
export {
start,
stop
StreamStart,
StreamStop
};
+2564
View File
File diff suppressed because it is too large Load Diff
+37 -35
View File
@@ -1,35 +1,37 @@
{
"name": "@discord.js/radio",
"version": "0.0.1",
"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.js-radio.git"
},
"keywords": [
"discord.js",
"stream",
"audio",
"radio"
],
"author": "FrauJulian | Julian Lechner",
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/FrauJulian/discord.js-radio/issues"
},
"homepage": "https://github.com/FrauJulian/discord.js-radio#readme",
"devDependencies": {
"tsup": "^8.0.2",
"typescript": "^5.4.5"
},
"dependencies": {
"my-package": "^0.0.0"
}
}
{
"name": "discord-audio-stream",
"version": "0.0.3",
"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"
],
"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": {
"tsup": "^8.0.2",
"typescript": "^5.4.5"
},
"dependencies": {
"@discordjs/voice": "^0.16.1",
"discord.js": "^14.14.1",
"ffmpeg-static": "^5.2.0",
"libsodium-wrappers": "^0.7.13",
"opusscript": "^0.0.8"
}
}
+48
View File
@@ -0,0 +1,48 @@
import { StartProps } from "../stuff/types";
import { ERROR } from "../stuff/error";
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
const { join } = require('node:path');
export function StreamStart({
imvci,
igi,
igv,
type,
StreamFile,
StreamLink
}: StartProps) {
try {
const AudioPlayer = createAudioPlayer();
if (type === "File") {
let Audio = createAudioResource(StreamLink);
AudioPlayer.play(Audio);
joinVoiceChannel({
channelId: imvci,
guildId: igi,
adapterCreator: igv
}).subscribe(AudioPlayer)
} else if (type === "Link") {
const Audio = createAudioResource(join(__dirname, StreamFile));
AudioPlayer.play(Audio);
joinVoiceChannel({
channelId: imvci,
guildId: igi,
adapterCreator: igv
}).subscribe(AudioPlayer);
} else {
ERROR();
}
} catch (error) {
ERROR();
console.log("ERR:\n" + error);
console.log(" ");
}
};
+19
View File
@@ -0,0 +1,19 @@
import { StopProps } from "../stuff/types";
import { ERROR } from "../stuff/error";
const { getVoiceConnection } = require("@discordjs/voice");
export function StreamStop({
igi,
}: StopProps) {
try {
const connection = getVoiceConnection(igi);
connection.disconnect();
} catch (error) {
ERROR();
console.log("ERR:\n" + error);
console.log(" ");
}
};
+2 -2
View File
@@ -1,2 +1,2 @@
export * from "./start";
export * from "./stop";
export * from "./functions/start";
export * from "./functions/stop";
+10
View File
@@ -0,0 +1,10 @@
export function ERROR() {
console.log(" ");
console.log(" ______ _____ _____ ____ _____ \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.");
console.log(" ")
console.log("See the docs or open a issue post on github.")
console.log(" ")
}
+12
View File
@@ -0,0 +1,12 @@
export type StartProps = {
imvci: number;
igi: number;
igv: number;
type: string;
StreamFile?: string;
StreamLink?: string;
};
export type StopProps = {
igi: number;
};
+1 -1
View File
@@ -5,7 +5,7 @@
"esModuleInterop": true,
"strictNullChecks": true,
"target": "ES2022",
"moduleResolution": "Node10",
"moduleResolution": "Node",
"module": "CommonJS",
"declaration": true,
"isolatedModules": true,