NEODPOSLOUCHAVEJ!!-§§-§§!

This commit is contained in:
Histmy 2022-11-04 16:57:06 +01:00
parent a677eb16e9
commit 7ca353fc7f
4 changed files with 29 additions and 9 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "denim_3001",
"version": "3001.42.4",
"version": "3001.43.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "denim_3001",
"version": "3001.42.4",
"version": "3001.43.0",
"license": "ISC",
"dependencies": {
"@discordjs/voice": "^0.11.0",

View File

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

View File

@ -1,12 +1,13 @@
// Cokoliv co má něco společnýho s vojsem
import { getVoiceConnection, VoiceConnection, VoiceConnectionStatus } from "@discordjs/voice";
import { ChannelType, GuildMember, VoiceChannel } from "discord.js";
import { ChannelType, GuildMember, VoiceChannel, VoiceState } from "discord.js";
import { emouty } from "../utils/emotes";
import { Modul, MuzikaFace, SRecord } from "../utils/types";
import { canAnounceTime, handlePrevVoice, joinVoice, log, play } from "../utils/utils";
const timeouty: SRecord<NodeJS.Timeout> = {};
const muty: string[] = [];
const vypocitatCas = (guild: string, conn: VoiceConnection) => {
const c = new Date();
@ -179,6 +180,27 @@ const exp: Modul = {
handlePrevVoice(mes.guild!, prev);
}
}
},
// Neodposlouchávej
on_voiceStateUpdate: (bef: VoiceState, aft: VoiceState) => {
const conn = getVoiceConnection(aft.guild.id);
if (!aft.channel || !conn || aft.member?.user.id == aft.client.user?.id) return;
if (aft.selfMute && !aft.deaf) {
play(conn, { name: "./zvuky/neodposlouchavej.ogg", volume: 0.38 })
.then(() => {
if (!aft.selfMute) return;
aft.setDeaf(true, "otposlouchávala ta gadza");
if (!muty.includes(aft.member!.id)) muty.push(aft.member!.id);
});
}
if (!bef.channel) return;
if (bef.mute && bef.deaf && !aft.mute && aft.serverDeaf && muty.includes(aft.member!.id)) {
aft.setDeaf(false, "us muze poslouchat gadza");
muty.splice(muty.indexOf(aft.member!.id), 1);
}
}
};

View File

@ -125,11 +125,7 @@ export const play = (conn: VoiceConnection, co: string | string[] | MuzikaFace |
if (!Array.isArray(co)) {
const aud = makeAudioPlayer(co);
player.play(aud);
const funkce = () => {
res();
player.removeListener(AudioPlayerStatus.Idle, funkce);
};
player.on(AudioPlayerStatus.Idle, funkce);
player.once(AudioPlayerStatus.Idle, () => res());
return;
}
@ -241,3 +237,5 @@ export const statusOnFoun = (bef: FakePresence | null, aft: FakePresence) => {
return predAPo;
};
export const getGuildConnection = (guildId: string) => pripojeni[guildId]?.connection;