changed Project Stucture - Part1
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
.idea
|
.idea
|
||||||
node_modules
|
node_modules
|
||||||
src
|
src
|
||||||
|
.gitignore
|
||||||
|
README.md
|
||||||
tsconfig.json
|
tsconfig.json
|
||||||
tsup.config.ts
|
tsup.config.ts
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import {AudioStreamManager} from "./src";
|
||||||
|
|
||||||
|
let temp = new AudioStreamManager("MySql", "frg");
|
||||||
|
|
||||||
|
console.log(temp);
|
||||||
Generated
+1165
-311
File diff suppressed because it is too large
Load Diff
+13
-9
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "discord-audio-stream",
|
"name": "discord-audio-stream",
|
||||||
"version": "0.4.1",
|
"version": "0.5.0",
|
||||||
"description": "Node libary to make discord audio streaming easier.",
|
"description": "Node library to make discord audio streaming easier.",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
@@ -26,15 +26,19 @@
|
|||||||
"homepage": "https://github.com/FrauJulian/DiscordAudioStreamNPM#readme",
|
"homepage": "https://github.com/FrauJulian/DiscordAudioStreamNPM#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/ejs": "^3.1.5",
|
"@types/ejs": "^3.1.5",
|
||||||
"@types/node": "^20.12.8",
|
"@types/node": "^22.13.16",
|
||||||
"tsup": "^8.0.2",
|
"tsup": "^8.4.0",
|
||||||
"typescript": "^5.4.5"
|
"typescript": "^5.8.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/voice": "^0.16.1",
|
"@discordjs/opus": "^0.10.0",
|
||||||
|
"@discordjs/voice": "^0.18.0",
|
||||||
|
"@noble/ciphers": "^1.2.1",
|
||||||
"ffmpeg-static": "^5.2.0",
|
"ffmpeg-static": "^5.2.0",
|
||||||
"fs": "^0.0.1-security",
|
"libsodium-wrappers": "^0.7.15",
|
||||||
"libsodium-wrappers": "^0.7.13",
|
"mysql2": "^3.14.0",
|
||||||
"opusscript": "^0.0.8"
|
"node-json-db": "^2.3.1",
|
||||||
|
"opusscript": "^0.1.1",
|
||||||
|
"sodium-native": "^5.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import {JsonDatabaseServices} from "../InternalServices/DatabaseServices/JsonDatabaseServices";
|
||||||
|
import {MySqlDatabaseServices} from "../InternalServices/DatabaseServices/MySqlDatabaseServices";
|
||||||
|
|
||||||
|
export class Constants {
|
||||||
|
public static DatabaseServices: JsonDatabaseServices | MySqlDatabaseServices | null = null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import {JsonDatabaseServices} from "../../InternalServices/DatabaseServices/JsonDatabaseServices";
|
||||||
|
import {MySqlDatabaseServices} from "../../InternalServices/DatabaseServices/MySqlDatabaseServices";
|
||||||
|
import {Constants} from "../../Core/Contants";
|
||||||
|
|
||||||
|
export class AudioStreamManager {
|
||||||
|
constructor(
|
||||||
|
databaseType: "Json" | "MySql",
|
||||||
|
databaseOptions: {
|
||||||
|
Host: string;
|
||||||
|
Port: number;
|
||||||
|
Username: string;
|
||||||
|
Password: string;
|
||||||
|
Database: string;
|
||||||
|
} | string) {
|
||||||
|
|
||||||
|
if (databaseType === "MySql" &&
|
||||||
|
databaseOptions &&
|
||||||
|
typeof databaseOptions === "object") {
|
||||||
|
console.log("mysql passed")
|
||||||
|
Constants.DatabaseServices = new MySqlDatabaseServices(databaseOptions);
|
||||||
|
} else if (databaseType === "Json" &&
|
||||||
|
databaseOptions &&
|
||||||
|
typeof databaseOptions === "string") {
|
||||||
|
console.log("json passed")
|
||||||
|
Constants.DatabaseServices = new JsonDatabaseServices(databaseOptions);
|
||||||
|
} else {
|
||||||
|
console.log("err passed")
|
||||||
|
throw new Error("Failed validating database.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import {DiscordGatewayAdapterCreator, getVoiceConnection, joinVoiceChannel, VoiceConnection} from "@discordjs/voice";
|
||||||
|
import {IConnectionManager} from "./IConnectionManager";
|
||||||
|
import {Constants} from "../../Core/Contants";
|
||||||
|
|
||||||
|
class ConnectionManager implements IConnectionManager {
|
||||||
|
constructor() {
|
||||||
|
if (Constants.DatabaseServices === null) throw Error("Database services were not initialized.");
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateConnection(connectionData: {
|
||||||
|
VoiceChannelId: number;
|
||||||
|
GuildId: number;
|
||||||
|
VoiceAdapter: DiscordGatewayAdapterCreator;
|
||||||
|
}): VoiceConnection {
|
||||||
|
return joinVoiceChannel({
|
||||||
|
channelId: connectionData.VoiceChannelId.toString(),
|
||||||
|
guildId: connectionData.GuildId.toString(),
|
||||||
|
adapterCreator: connectionData.VoiceAdapter
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayAudioOnConnection(audioData: {
|
||||||
|
ResourceType: "Link" | "File";
|
||||||
|
Resource: string;
|
||||||
|
}, guildId: bigint): VoiceConnection {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectAndPlayAudio(connectionData: { VoiceChannelId: number; GuildId: number; VoiceAdapter: DiscordGatewayAdapterCreator; }, audioData: {
|
||||||
|
ResourceType: "Link" | "File";
|
||||||
|
Resource: string;
|
||||||
|
}): VoiceConnection {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
StopAudioOnConnection(guildId: bigint): VoiceConnection {
|
||||||
|
let voiceConnection = getVoiceConnection(guildId.toString());
|
||||||
|
if (!voiceConnection) throw new Error("Voice connection were not found.");
|
||||||
|
|
||||||
|
//TODO: MAKE STOP AUDIO WITHOUT DESTROYING CONNECTION
|
||||||
|
|
||||||
|
return voiceConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
DestroyConnection(guildId: bigint): void {
|
||||||
|
let voiceConnection = getVoiceConnection(guildId.toString());
|
||||||
|
if (!voiceConnection) throw new Error("Voice connection were not found.");
|
||||||
|
|
||||||
|
voiceConnection.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
SetMaxListeners(maxListeners: number, guildId: bigint): VoiceConnection {
|
||||||
|
let voiceConnection = getVoiceConnection(guildId.toString());
|
||||||
|
if (!voiceConnection) throw new Error("Voice connection were not found.");
|
||||||
|
|
||||||
|
voiceConnection.setMaxListeners(maxListeners);
|
||||||
|
|
||||||
|
return voiceConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetVolume(volume: number, guildId: bigint): VoiceConnection {
|
||||||
|
if (volume < 0 || volume > 100) throw new Error("Volume must be between 0 and 100.");
|
||||||
|
|
||||||
|
let voiceConnection = getVoiceConnection(guildId.toString());
|
||||||
|
if (!voiceConnection) throw new Error("Voice connection were not found.");
|
||||||
|
|
||||||
|
//TODO: MAKE VOLUME WORK
|
||||||
|
|
||||||
|
return voiceConnection;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import {DiscordGatewayAdapterCreator, getVoiceConnection, joinVoiceChannel, VoiceConnection} from "@discordjs/voice";
|
||||||
|
|
||||||
|
export interface IConnectionManager {
|
||||||
|
CreateConnection(connectionData: {
|
||||||
|
VoiceChannelId: number;
|
||||||
|
GuildId: number;
|
||||||
|
VoiceAdapter: DiscordGatewayAdapterCreator;
|
||||||
|
}): VoiceConnection;
|
||||||
|
|
||||||
|
SetVolume(volume: number, guildId: bigint): VoiceConnection;
|
||||||
|
|
||||||
|
SetMaxListeners(maxListeners: number, guildId: bigint): VoiceConnection;
|
||||||
|
|
||||||
|
DestroyConnection(guildId: bigint): void;
|
||||||
|
|
||||||
|
StopAudioOnConnection(guildId: bigint): VoiceConnection;
|
||||||
|
|
||||||
|
ConnectAndPlayAudio(connectionData: {
|
||||||
|
VoiceChannelId: number;
|
||||||
|
GuildId: number;
|
||||||
|
VoiceAdapter: DiscordGatewayAdapterCreator;
|
||||||
|
}, audioData: {
|
||||||
|
ResourceType: "Link" | "File";
|
||||||
|
Resource: string;
|
||||||
|
}): VoiceConnection;
|
||||||
|
|
||||||
|
PlayAudioOnConnection(audioData: {
|
||||||
|
ResourceType: "Link" | "File";
|
||||||
|
Resource: string;
|
||||||
|
}, guildId: bigint): VoiceConnection;
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export interface IDatabaseServices {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import {IDatabaseServices} from "./IDatabaseServices";
|
||||||
|
|
||||||
|
export class JsonDatabaseServices implements IDatabaseServices {
|
||||||
|
constructor(databaseOptions : string) {
|
||||||
|
// IMPLEMENT DATABASE
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import {IDatabaseServices} from "./IDatabaseServices";
|
||||||
|
|
||||||
|
export class MySqlDatabaseServices implements IDatabaseServices {
|
||||||
|
|
||||||
|
constructor(databaseOptions: {
|
||||||
|
Host: string;
|
||||||
|
Port: number;
|
||||||
|
Username: string;
|
||||||
|
Password: string;
|
||||||
|
Database: string;
|
||||||
|
}) {
|
||||||
|
//IMPLEMENT DATABASE
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
const {joinVoiceChannel, createAudioPlayer, createAudioResource} = require("@discordjs/voice");
|
const {
|
||||||
|
joinVoiceChannel, createAudioPlayer, createAudioResource} = require("@discordjs/voice");
|
||||||
const {join} = require("node:path");
|
const {join} = require("node:path");
|
||||||
|
|
||||||
import {startMethodOptions} from "../Utils/Options/StartMethodOptions";
|
import {startMethodOptions} from "../Utils/Options/StartMethodOptions";
|
||||||
|
|||||||
+1
-3
@@ -1,3 +1 @@
|
|||||||
export * from "./Methods/StartMethod";
|
export { AudioStreamManager } from "./ExternalServices/AudioStreamManager/AudioStreamManager";
|
||||||
export * from "./Methods/StopMethod";
|
|
||||||
export * from "./Methods/MaxListenerMethod";
|
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"allowJs": true,
|
"allowJs": false,
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user