Added more cas
This commit is contained in:
parent
4e183b0947
commit
2a991099ab
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.21.1",
|
"version": "3001.22.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.21.1",
|
"version": "3001.22.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/opus": "github:discordjs/opus",
|
"@discordjs/opus": "github:discordjs/opus",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.21.1",
|
"version": "3001.22.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/"
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
import { getVoiceConnection, VoiceConnection, VoiceConnectionStatus } from "@discordjs/voice";
|
import { getVoiceConnection, VoiceConnection, VoiceConnectionStatus } from "@discordjs/voice";
|
||||||
import { GuildMember, Message, VoiceChannel } from "discord.js";
|
import { GuildMember, Message, VoiceChannel } from "discord.js";
|
||||||
import { emouty } from "../utils/emotes";
|
import { emouty } from "../utils/emotes";
|
||||||
import { joinVoice, leave, play } from "../utils/utils";
|
import { MuzikaFace } from "../utils/types";
|
||||||
|
import { handlePrevVoice, joinVoice, play } from "../utils/utils";
|
||||||
|
|
||||||
const timeouty: Record<string, NodeJS.Timeout> = {};
|
const timeouty: Record<string, NodeJS.Timeout> = {};
|
||||||
|
|
||||||
@ -115,9 +116,49 @@ module.exports = {
|
|||||||
|
|
||||||
const { conn, prev } = await joinVoice(channel);
|
const { conn, prev } = await joinVoice(channel);
|
||||||
await play(conn, "zvuky/grg.mp3");
|
await play(conn, "zvuky/grg.mp3");
|
||||||
if (prev === true) return; // Byl jsem v tomdle vojsu
|
handlePrevVoice(mes.guild!, prev);
|
||||||
if (prev === false) return leave(mes.guildId!); // Nebyl jsem ve vojsu vůbec
|
}
|
||||||
joinVoice(prev as string, mes.guild!); // Byl jsem jinde
|
},
|
||||||
|
|
||||||
|
cas: {
|
||||||
|
cd: 5,
|
||||||
|
run: async (_: any, mes: Message) => {
|
||||||
|
const date = new Date();
|
||||||
|
const h = date.getHours();
|
||||||
|
const m = date.getMinutes();
|
||||||
|
const pre = "zvuky/cas/";
|
||||||
|
|
||||||
|
const addSuffix = (prefix: string, hodnota: number) => {
|
||||||
|
const koncovka = hodnota == 1 ? "a" : hodnota > 1 && hodnota < 5 ? "y" : "";
|
||||||
|
return `${prefix}${koncovka}`;
|
||||||
|
};
|
||||||
|
const rozdelAPridej = (cislo: number) => {
|
||||||
|
if (cislo == 2) return zvuky.push({ name: `${pre}dvě.mp3`, volume: 2.5 });
|
||||||
|
if (cislo < 20) return zvuky.push({ name: `${pre}${cislo}.mp3`, volume: 2.5 });
|
||||||
|
const text = String(cislo);
|
||||||
|
zvuky.push({ name: `${pre}${text[0]}0.mp3`, volume: 2.5 });
|
||||||
|
if (text[1] != "0") zvuky.push({ name: `${pre}${text[1]}.mp3`, volume: 2.5 });
|
||||||
|
};
|
||||||
|
|
||||||
|
const hod = addSuffix("hodin", h);
|
||||||
|
const min = addSuffix("minut", m);
|
||||||
|
const je = h > 1 && h < 5 ? "jsou" : "je";
|
||||||
|
|
||||||
|
const channel = mes.member?.voice.channel;
|
||||||
|
if (!channel) return mes.channel.send(`${je} ${h} ${hod} ${m} ${min}`);
|
||||||
|
|
||||||
|
const zvuky: MuzikaFace[] = [{ name: `${pre}${je}.mp3`, volume: 2.5 }];
|
||||||
|
|
||||||
|
rozdelAPridej(h);
|
||||||
|
zvuky.push({ name: `${pre}${hod}.mp3`, volume: 2.5 });
|
||||||
|
if (m > 0) {
|
||||||
|
rozdelAPridej(m);
|
||||||
|
zvuky.push({ name: `${pre}${min}.mp3`, volume: 2.5 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const { conn, prev } = await joinVoice(channel);
|
||||||
|
await play(conn, zvuky);
|
||||||
|
handlePrevVoice(mes.guild!, prev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,5 +46,5 @@ export interface ZmenovejObjekt {
|
|||||||
|
|
||||||
export interface MuzikaFace {
|
export interface MuzikaFace {
|
||||||
name: string,
|
name: string,
|
||||||
volume?: number;
|
volume: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ export const oddiakritikovat = (a: string) => {
|
|||||||
.replace(/[Ŵ]/g, "W")
|
.replace(/[Ŵ]/g, "W")
|
||||||
.replace(/[ÝŶŸ]/g, "Y")
|
.replace(/[ÝŶŸ]/g, "Y")
|
||||||
.replace(/[ŹŻŽ]/g, "Z");
|
.replace(/[ŹŻŽ]/g, "Z");
|
||||||
}
|
};
|
||||||
|
|
||||||
export const formatCas = (cas: number) => {
|
export const formatCas = (cas: number) => {
|
||||||
const h = Math.floor(cas / 3600);
|
const h = Math.floor(cas / 3600);
|
||||||
@ -63,9 +63,16 @@ export const joinVoice = async (channel: VoiceChannel | StageChannel | string, g
|
|||||||
const guilda = typeof channel === "string" ? guild! : channel.guild;
|
const guilda = typeof channel === "string" ? guild! : channel.guild;
|
||||||
|
|
||||||
let conn = getVoiceConnection(guildId);
|
let conn = getVoiceConnection(guildId);
|
||||||
let prev: Boolean | string = false;
|
let prev: boolean | string = false;
|
||||||
if (conn) {
|
if (conn) {
|
||||||
if (conn.joinConfig.channelId === channelId) return { conn, prev: true };
|
if (conn.joinConfig.channelId === channelId) {
|
||||||
|
await entersState(conn, VoiceConnectionStatus.Ready, 3e4)
|
||||||
|
.catch(err => {
|
||||||
|
conn!.destroy();
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
return { conn, prev: true };
|
||||||
|
}
|
||||||
prev = conn.joinConfig.channelId!;
|
prev = conn.joinConfig.channelId!;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,13 +98,12 @@ export const joinVoice = async (channel: VoiceChannel | StageChannel | string, g
|
|||||||
|
|
||||||
const makeAudioPlayer = (co: string | MuzikaFace) => {
|
const makeAudioPlayer = (co: string | MuzikaFace) => {
|
||||||
if (typeof co === "string") return createAudioResource(co);
|
if (typeof co === "string") return createAudioResource(co);
|
||||||
const res = createAudioResource(co.name, { inlineVolume: !!co.volume });
|
const res = createAudioResource(co.name, { inlineVolume: true });
|
||||||
if (co.volume) res.volume?.setVolume(co.volume);
|
res.volume?.setVolume(co.volume);
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const play = (conn: VoiceConnection, co: string | MuzikaFace | MuzikaFace[]) => {
|
export const play = (conn: VoiceConnection, co: string | string[] | MuzikaFace | MuzikaFace[]) => new Promise<void>(async (res, rej) => {
|
||||||
return new Promise<void>(async (res, rej) => {
|
|
||||||
if (conn.state.status !== VoiceConnectionStatus.Ready) return rej("conn není ready");
|
if (conn.state.status !== VoiceConnectionStatus.Ready) return rej("conn není ready");
|
||||||
|
|
||||||
const player = pripojeni[conn.joinConfig.guildId].player;
|
const player = pripojeni[conn.joinConfig.guildId].player;
|
||||||
@ -122,22 +128,27 @@ export const play = (conn: VoiceConnection, co: string | MuzikaFace | MuzikaFace
|
|||||||
}
|
}
|
||||||
player.play(resources[0]);
|
player.play(resources[0]);
|
||||||
|
|
||||||
let i = 1;
|
let i = 0;
|
||||||
const funkce = () => {
|
const funkce = () => {
|
||||||
player.play(resources[i]);
|
|
||||||
i++;
|
i++;
|
||||||
if (i === resources.length) {
|
if (i === resources.length) {
|
||||||
res();
|
res();
|
||||||
player.removeListener(AudioPlayerStatus.Idle, funkce);
|
player.removeListener(AudioPlayerStatus.Idle, funkce);
|
||||||
}
|
}
|
||||||
|
else player.play(resources[i]);
|
||||||
};
|
};
|
||||||
player.on(AudioPlayerStatus.Idle, funkce);
|
player.on(AudioPlayerStatus.Idle, funkce);
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
export const leave = (guildId: string) => {
|
const leave = (guildId: string) => {
|
||||||
const conn = getVoiceConnection(guildId);
|
const conn = getVoiceConnection(guildId);
|
||||||
if (!conn) return;
|
if (!conn) return;
|
||||||
conn.destroy();
|
conn.destroy();
|
||||||
delete pripojeni[guildId];
|
delete pripojeni[guildId];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const handlePrevVoice = (guild: Guild, prev: boolean | string) => {
|
||||||
|
if (prev === true) return; // Byl jsem v tomdle vojsu
|
||||||
|
if (prev === false) return leave(guild.id); // Nebyl jsem ve vojsu vůbec
|
||||||
|
joinVoice(prev, guild); // Byl jsem jinde
|
||||||
|
};
|
||||||
|
|||||||
BIN
zvuky/bez_se_zabit.mp3
Normal file
BIN
zvuky/bez_se_zabit.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/0.mp3
Normal file
BIN
zvuky/cas/0.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/1.mp3
Normal file
BIN
zvuky/cas/1.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/10.mp3
Normal file
BIN
zvuky/cas/10.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/11.mp3
Normal file
BIN
zvuky/cas/11.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/12.mp3
Normal file
BIN
zvuky/cas/12.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/13.mp3
Normal file
BIN
zvuky/cas/13.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/14.mp3
Normal file
BIN
zvuky/cas/14.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/15.mp3
Normal file
BIN
zvuky/cas/15.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/16.mp3
Normal file
BIN
zvuky/cas/16.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/17.mp3
Normal file
BIN
zvuky/cas/17.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/18.mp3
Normal file
BIN
zvuky/cas/18.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/19.mp3
Normal file
BIN
zvuky/cas/19.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/2.mp3
Normal file
BIN
zvuky/cas/2.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/20.mp3
Normal file
BIN
zvuky/cas/20.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/3.mp3
Normal file
BIN
zvuky/cas/3.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/30.mp3
Normal file
BIN
zvuky/cas/30.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/4.mp3
Normal file
BIN
zvuky/cas/4.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/40.mp3
Normal file
BIN
zvuky/cas/40.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/5.mp3
Normal file
BIN
zvuky/cas/5.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/50.mp3
Normal file
BIN
zvuky/cas/50.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/6.mp3
Normal file
BIN
zvuky/cas/6.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/7.mp3
Normal file
BIN
zvuky/cas/7.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/8.mp3
Normal file
BIN
zvuky/cas/8.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/9.mp3
Normal file
BIN
zvuky/cas/9.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/dvě.mp3
Normal file
BIN
zvuky/cas/dvě.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/hodin.mp3
Normal file
BIN
zvuky/cas/hodin.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/hodina.mp3
Normal file
BIN
zvuky/cas/hodina.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/hodiny.mp3
Normal file
BIN
zvuky/cas/hodiny.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/je.mp3
Normal file
BIN
zvuky/cas/je.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/jsou.mp3
Normal file
BIN
zvuky/cas/jsou.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/minut.mp3
Normal file
BIN
zvuky/cas/minut.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/minuta.mp3
Normal file
BIN
zvuky/cas/minuta.mp3
Normal file
Binary file not shown.
BIN
zvuky/cas/minuty.mp3
Normal file
BIN
zvuky/cas/minuty.mp3
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user