Add files via upload
This commit is contained in:
@@ -35,9 +35,8 @@ Audio.StreamStart({
|
|||||||
imvci: 0, //Voice Channel ID e.g. interaction.member.voice.channel.id
|
imvci: 0, //Voice Channel ID e.g. interaction.member.voice.channel.id
|
||||||
igi: 0, //Guild ID e.g. interaction.guild.id
|
igi: 0, //Guild ID e.g. interaction.guild.id
|
||||||
igv: 0, //Bot Voice Adapter e.g. interaction.guild.voiceAdapterCreator
|
igv: 0, //Bot Voice Adapter e.g. interaction.guild.voiceAdapterCreator
|
||||||
type: "Link", //Choose the Stream resource - File or Link
|
type: "", //Choose the Stream resource - File or Link or Analyze
|
||||||
StreamFile: "", //Link to File e.g. ../assets/Stream.mp3
|
Resource: "", //Link to File e.g. ../assets/Stream.mp3 or Link to Audio Stream e.g. YouTube Video or LautFM Stream Link
|
||||||
StreamLink: "" //Link to Audio Stream e.g. YouTube Video or LautFM Stream Link
|
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -52,4 +51,4 @@ Audio.StreamStart({
|
|||||||
|
|
||||||
## 🤝 Enjoy the package?
|
## 🤝 Enjoy the package?
|
||||||
|
|
||||||
Give it a star ⭐ on github!
|
Give it a star ⭐ on github or [donate](https://buymeacoffee.com/fraujuliannn) a hot chocolate!
|
||||||
Vendored
+2
-3
@@ -3,14 +3,13 @@ type StartProps = {
|
|||||||
igi: number;
|
igi: number;
|
||||||
igv: number;
|
igv: number;
|
||||||
type: string;
|
type: string;
|
||||||
StreamFile?: string;
|
Resource: string;
|
||||||
StreamLink?: string;
|
|
||||||
};
|
};
|
||||||
type StopProps = {
|
type StopProps = {
|
||||||
igi: number;
|
igi: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
declare function StreamStart({ imvci, igi, igv, type, StreamFile, StreamLink }: StartProps): void;
|
declare function StreamStart({ imvci, igi, igv, type, Resource, }: StartProps): void;
|
||||||
|
|
||||||
declare function StreamStop({ igi, }: StopProps): void;
|
declare function StreamStop({ igi, }: StopProps): void;
|
||||||
|
|
||||||
|
|||||||
Vendored
+2
-3
@@ -3,14 +3,13 @@ type StartProps = {
|
|||||||
igi: number;
|
igi: number;
|
||||||
igv: number;
|
igv: number;
|
||||||
type: string;
|
type: string;
|
||||||
StreamFile?: string;
|
Resource: string;
|
||||||
StreamLink?: string;
|
|
||||||
};
|
};
|
||||||
type StopProps = {
|
type StopProps = {
|
||||||
igi: number;
|
igi: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
declare function StreamStart({ imvci, igi, igv, type, StreamFile, StreamLink }: StartProps): void;
|
declare function StreamStart({ imvci, igi, igv, type, Resource, }: StartProps): void;
|
||||||
|
|
||||||
declare function StreamStop({ igi, }: StopProps): void;
|
declare function StreamStop({ igi, }: StopProps): void;
|
||||||
|
|
||||||
|
|||||||
Vendored
+41
-19
@@ -1,7 +1,9 @@
|
|||||||
"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)
|
||||||
@@ -15,6 +17,14 @@ 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,34 +48,46 @@ function ERROR() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/functions/start.ts
|
// src/functions/start.ts
|
||||||
|
var import_fs = __toESM(require("fs"));
|
||||||
|
var import_node_path = require("path");
|
||||||
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
|
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
|
||||||
var { join } = require("path");
|
|
||||||
function StreamStart({
|
function StreamStart({
|
||||||
imvci,
|
imvci,
|
||||||
igi,
|
igi,
|
||||||
igv,
|
igv,
|
||||||
type,
|
type,
|
||||||
StreamFile,
|
Resource
|
||||||
StreamLink
|
|
||||||
}) {
|
}) {
|
||||||
try {
|
try {
|
||||||
|
let FileResource2 = function() {
|
||||||
|
let Audio = createAudioResource((0, import_node_path.join)(__dirname, Resource), { inlineVolume: true });
|
||||||
|
AudioPlayer.play(Audio);
|
||||||
|
joinVoiceChannel({
|
||||||
|
channelId: imvci,
|
||||||
|
guildId: igi,
|
||||||
|
adapterCreator: igv
|
||||||
|
}).subscribe(AudioPlayer);
|
||||||
|
}, LinkResource2 = function() {
|
||||||
|
let Audio = createAudioResource(Resource);
|
||||||
|
AudioPlayer.play(Audio);
|
||||||
|
joinVoiceChannel({
|
||||||
|
channelId: imvci,
|
||||||
|
guildId: igi,
|
||||||
|
adapterCreator: igv
|
||||||
|
}).subscribe(AudioPlayer);
|
||||||
|
};
|
||||||
|
var FileResource = FileResource2, LinkResource = LinkResource2;
|
||||||
const AudioPlayer = createAudioPlayer();
|
const AudioPlayer = createAudioPlayer();
|
||||||
if (type === "File") {
|
if (type === "Link") {
|
||||||
let Audio = createAudioResource(StreamLink);
|
LinkResource2();
|
||||||
AudioPlayer.play(Audio);
|
} else if (type === "File") {
|
||||||
joinVoiceChannel({
|
FileResource2();
|
||||||
channelId: imvci,
|
} else if (type === "Analyze") {
|
||||||
guildId: igi,
|
if (import_fs.default.existsSync(Resource)) {
|
||||||
adapterCreator: igv
|
FileResource2();
|
||||||
}).subscribe(AudioPlayer);
|
} else {
|
||||||
} else if (type === "Link") {
|
LinkResource2();
|
||||||
const Audio = createAudioResource(join(__dirname, StreamFile));
|
}
|
||||||
AudioPlayer.play(Audio);
|
|
||||||
joinVoiceChannel({
|
|
||||||
channelId: imvci,
|
|
||||||
guildId: igi,
|
|
||||||
adapterCreator: igv
|
|
||||||
}).subscribe(AudioPlayer);
|
|
||||||
} else {
|
} else {
|
||||||
ERROR();
|
ERROR();
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+31
-19
@@ -26,34 +26,46 @@ function ERROR() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// src/functions/start.ts
|
// src/functions/start.ts
|
||||||
|
import fs from "fs";
|
||||||
|
import { join } from "node:path";
|
||||||
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = __require("@discordjs/voice");
|
var { joinVoiceChannel, createAudioPlayer, createAudioResource } = __require("@discordjs/voice");
|
||||||
var { join } = __require("node:path");
|
|
||||||
function StreamStart({
|
function StreamStart({
|
||||||
imvci,
|
imvci,
|
||||||
igi,
|
igi,
|
||||||
igv,
|
igv,
|
||||||
type,
|
type,
|
||||||
StreamFile,
|
Resource
|
||||||
StreamLink
|
|
||||||
}) {
|
}) {
|
||||||
try {
|
try {
|
||||||
|
let FileResource2 = function() {
|
||||||
|
let Audio = createAudioResource(join(__dirname, Resource), { inlineVolume: true });
|
||||||
|
AudioPlayer.play(Audio);
|
||||||
|
joinVoiceChannel({
|
||||||
|
channelId: imvci,
|
||||||
|
guildId: igi,
|
||||||
|
adapterCreator: igv
|
||||||
|
}).subscribe(AudioPlayer);
|
||||||
|
}, LinkResource2 = function() {
|
||||||
|
let Audio = createAudioResource(Resource);
|
||||||
|
AudioPlayer.play(Audio);
|
||||||
|
joinVoiceChannel({
|
||||||
|
channelId: imvci,
|
||||||
|
guildId: igi,
|
||||||
|
adapterCreator: igv
|
||||||
|
}).subscribe(AudioPlayer);
|
||||||
|
};
|
||||||
|
var FileResource = FileResource2, LinkResource = LinkResource2;
|
||||||
const AudioPlayer = createAudioPlayer();
|
const AudioPlayer = createAudioPlayer();
|
||||||
if (type === "File") {
|
if (type === "Link") {
|
||||||
let Audio = createAudioResource(StreamLink);
|
LinkResource2();
|
||||||
AudioPlayer.play(Audio);
|
} else if (type === "File") {
|
||||||
joinVoiceChannel({
|
FileResource2();
|
||||||
channelId: imvci,
|
} else if (type === "Analyze") {
|
||||||
guildId: igi,
|
if (fs.existsSync(Resource)) {
|
||||||
adapterCreator: igv
|
FileResource2();
|
||||||
}).subscribe(AudioPlayer);
|
} else {
|
||||||
} else if (type === "Link") {
|
LinkResource2();
|
||||||
const Audio = createAudioResource(join(__dirname, StreamFile));
|
}
|
||||||
AudioPlayer.play(Audio);
|
|
||||||
joinVoiceChannel({
|
|
||||||
channelId: imvci,
|
|
||||||
guildId: igi,
|
|
||||||
adapterCreator: igv
|
|
||||||
}).subscribe(AudioPlayer);
|
|
||||||
} else {
|
} else {
|
||||||
ERROR();
|
ERROR();
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+22
-2
@@ -1,17 +1,19 @@
|
|||||||
{
|
{
|
||||||
"name": "discord-audio-stream",
|
"name": "discord-audio-stream",
|
||||||
"version": "0.0.2",
|
"version": "0.0.3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "discord-audio-stream",
|
"name": "discord-audio-stream",
|
||||||
"version": "0.0.2",
|
"version": "0.0.3",
|
||||||
"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",
|
||||||
"libsodium-wrappers": "^0.7.13",
|
"libsodium-wrappers": "^0.7.13",
|
||||||
"opusscript": "^0.0.8"
|
"opusscript": "^0.0.8"
|
||||||
},
|
},
|
||||||
@@ -1313,6 +1315,14 @@
|
|||||||
"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",
|
||||||
@@ -1368,6 +1378,11 @@
|
|||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/fs": {
|
||||||
|
"version": "0.0.1-security",
|
||||||
|
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
|
||||||
|
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
|
||||||
|
},
|
||||||
"node_modules/fsevents": {
|
"node_modules/fsevents": {
|
||||||
"version": "2.3.3",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||||
@@ -2422,6 +2437,11 @@
|
|||||||
"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",
|
||||||
|
|||||||
@@ -30,7 +30,9 @@
|
|||||||
"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",
|
||||||
"libsodium-wrappers": "^0.7.13",
|
"libsodium-wrappers": "^0.7.13",
|
||||||
"opusscript": "^0.0.8"
|
"opusscript": "^0.0.8"
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-18
@@ -1,34 +1,26 @@
|
|||||||
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 { AudioPlayer } from "@discordjs/voice";
|
||||||
|
|
||||||
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
|
const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require("@discordjs/voice");
|
||||||
const { join } = require('node:path');
|
|
||||||
|
|
||||||
export function StreamStart({
|
export function StreamStart({
|
||||||
imvci,
|
imvci,
|
||||||
igi,
|
igi,
|
||||||
igv,
|
igv,
|
||||||
type,
|
type,
|
||||||
StreamFile,
|
Resource,
|
||||||
StreamLink
|
|
||||||
}: StartProps) {
|
}: StartProps) {
|
||||||
try {
|
try {
|
||||||
|
//Create AudioPlayer variable.
|
||||||
const AudioPlayer = createAudioPlayer();
|
const AudioPlayer = createAudioPlayer();
|
||||||
|
|
||||||
if (type === "File") {
|
//File Resource
|
||||||
|
function FileResource() {
|
||||||
let Audio = createAudioResource(StreamLink);
|
|
||||||
AudioPlayer.play(Audio);
|
let Audio = createAudioResource(join(__dirname, Resource), { inlineVolume: true });
|
||||||
|
|
||||||
joinVoiceChannel({
|
|
||||||
channelId: imvci,
|
|
||||||
guildId: igi,
|
|
||||||
adapterCreator: igv
|
|
||||||
}).subscribe(AudioPlayer)
|
|
||||||
|
|
||||||
} else if (type === "Link") {
|
|
||||||
|
|
||||||
const Audio = createAudioResource(join(__dirname, StreamFile));
|
|
||||||
AudioPlayer.play(Audio);
|
AudioPlayer.play(Audio);
|
||||||
|
|
||||||
joinVoiceChannel({
|
joinVoiceChannel({
|
||||||
@@ -36,11 +28,39 @@ export function StreamStart({
|
|||||||
guildId: igi,
|
guildId: igi,
|
||||||
adapterCreator: igv
|
adapterCreator: igv
|
||||||
}).subscribe(AudioPlayer);
|
}).subscribe(AudioPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Link Resource
|
||||||
|
function LinkResource() {
|
||||||
|
let Audio = createAudioResource(Resource);
|
||||||
|
AudioPlayer.play(Audio);
|
||||||
|
|
||||||
|
joinVoiceChannel({
|
||||||
|
channelId: imvci,
|
||||||
|
guildId: igi,
|
||||||
|
adapterCreator: igv
|
||||||
|
}).subscribe(AudioPlayer)
|
||||||
|
}
|
||||||
|
|
||||||
|
//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();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//If no valid value is specified.
|
||||||
ERROR();
|
ERROR();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
//If syntax is wrong.
|
||||||
ERROR();
|
ERROR();
|
||||||
console.log("ERR:\n" + error);
|
console.log("ERR:\n" + error);
|
||||||
console.log(" ");
|
console.log(" ");
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ export function StreamStop({
|
|||||||
igi,
|
igi,
|
||||||
}: StopProps) {
|
}: StopProps) {
|
||||||
try {
|
try {
|
||||||
|
//Get connection from interaction guild.
|
||||||
const connection = getVoiceConnection(igi);
|
const connection = getVoiceConnection(igi);
|
||||||
connection.disconnect();
|
|
||||||
|
//Destroy connection from interaction guild.
|
||||||
|
connection.destroy();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ERROR();
|
ERROR();
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
|
//Export Start and Stop Function
|
||||||
export * from "./functions/start";
|
export * from "./functions/start";
|
||||||
export * from "./functions/stop";
|
export * from "./functions/stop";
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
//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.log(" ______ _____ _____ ____ _____ \r\n | ____| __ \\| __ \\ \/ __ \\| __ \\ \r\n | |__ | |__) | |__) | | | | |__) |\r\n | __| | _ \/| _ \/| | | | _ \/ \r\n | |____| | \\ \\| | \\ \\| |__| | | \\ \\ \r\n |______|_| \\_\\_| \\_\\\\____\/|_| \\_\\");
|
||||||
|
|||||||
+3
-2
@@ -1,12 +1,13 @@
|
|||||||
|
//Variables to use start function.
|
||||||
export type StartProps = {
|
export type StartProps = {
|
||||||
imvci: number;
|
imvci: number;
|
||||||
igi: number;
|
igi: number;
|
||||||
igv: number;
|
igv: number;
|
||||||
type: string;
|
type: string;
|
||||||
StreamFile?: string;
|
Resource: string;
|
||||||
StreamLink?: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Variables to use stop function.
|
||||||
export type StopProps = {
|
export type StopProps = {
|
||||||
igi: number;
|
igi: number;
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user