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
+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;
};