function joinVoice has defined overloads

This commit is contained in:
Histmy 2021-12-09 21:26:28 +01:00
parent d0e9994112
commit 6b99ed9b74
4 changed files with 13 additions and 5 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "denim_3001", "name": "denim_3001",
"version": "3001.33.1", "version": "3001.34.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "denim_3001", "name": "denim_3001",
"version": "3001.33.1", "version": "3001.34.0",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@discordjs/opus": "github:discordjs/opus", "@discordjs/opus": "github:discordjs/opus",

View File

@ -1,6 +1,6 @@
{ {
"name": "denim_3001", "name": "denim_3001",
"version": "3001.33.1", "version": "3001.34.0",
"description": "Toto je velmi kvalitní bot.", "description": "Toto je velmi kvalitní bot.",
"repository": { "repository": {
"url": "https://github.com/Histmy/Denim-Bot/" "url": "https://github.com/Histmy/Denim-Bot/"

View File

@ -1,3 +1,4 @@
import { VoiceConnection } from "@discordjs/voice";
import { Client, ClientEvents, ClientPresenceStatusData, Message, MessageOptions, User } from "discord.js"; import { Client, ClientEvents, ClientPresenceStatusData, Message, MessageOptions, User } from "discord.js";
type OutputRunFunkce = string | MessageOptions | void; type OutputRunFunkce = string | MessageOptions | void;
@ -71,3 +72,8 @@ export interface MuzikaFace {
export type KoamndNaExport = { export type KoamndNaExport = {
name: string; name: string;
} & BaseKomandProps; } & BaseKomandProps;
export interface JoinHovna {
conn: VoiceConnection;
prev: string | boolean;
};

View File

@ -1,7 +1,7 @@
import { AudioPlayerStatus, AudioResource, createAudioPlayer, createAudioResource, entersState, getVoiceConnection, joinVoiceChannel, PlayerSubscription, VoiceConnection, VoiceConnectionStatus } from "@discordjs/voice"; import { AudioPlayerStatus, AudioResource, createAudioPlayer, createAudioResource, entersState, getVoiceConnection, joinVoiceChannel, PlayerSubscription, VoiceConnection, VoiceConnectionStatus } from "@discordjs/voice";
import { Guild, StageChannel, VoiceChannel } from "discord.js"; import { Guild, StageChannel, VoiceChannel } from "discord.js";
import { once } from "events"; import { once } from "events";
import { MuzikaFace, SRecord } from "./types"; import { JoinHovna, MuzikaFace, SRecord } from "./types";
import { existsSync } from "fs"; import { existsSync } from "fs";
import { Readable } from "node:stream"; import { Readable } from "node:stream";
@ -63,7 +63,9 @@ export const formatCas = (cas: number) => {
return `${h} hodin ${m} mynut a ${s} se kund`; return `${h} hodin ${m} mynut a ${s} se kund`;
}; };
export const joinVoice = async (channel: VoiceChannel | StageChannel | string, guild?: Guild) => { export async function joinVoice(channel: VoiceChannel | StageChannel): Promise<JoinHovna>;
export async function joinVoice(channel: string, guild: Guild): Promise<JoinHovna>;
export async function joinVoice(channel: VoiceChannel | StageChannel | string, guild?: Guild): Promise<JoinHovna> {
const channelId = typeof channel === "string" ? channel : channel.id; const channelId = typeof channel === "string" ? channel : channel.id;
const guildId = typeof channel === "string" ? guild!.id : channel.guildId; const guildId = typeof channel === "string" ? guild!.id : channel.guildId;
const guilda = typeof channel === "string" ? guild! : channel.guild; const guilda = typeof channel === "string" ? guild! : channel.guild;