added more ps
This commit is contained in:
parent
370caa08d8
commit
ce57c640a9
@ -4,9 +4,9 @@ import { Guild, GuildMember, Message, VoiceState } from "discord.js";
|
|||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import { emouty } from "../utils/emotes";
|
import { emouty } from "../utils/emotes";
|
||||||
import { Spinkackar } from "../utils/types";
|
import { Spinkackar } from "../utils/types";
|
||||||
import { formatCas } from "../utils/utils";
|
import { formatCas, formatter } from "../utils/utils";
|
||||||
|
|
||||||
const spinkacky: string[] = [];
|
let spinkacky: Record<string, Spinkackar>;
|
||||||
const budouciSpinky: Record<string, NodeJS.Timeout> = {};
|
const budouciSpinky: Record<string, NodeJS.Timeout> = {};
|
||||||
|
|
||||||
const contactSpinkServer = async (akce: string, id: string, nick: string = "", avatar: string | null = "") => {
|
const contactSpinkServer = async (akce: string, id: string, nick: string = "", avatar: string | null = "") => {
|
||||||
@ -17,16 +17,17 @@ const contactSpinkServer = async (akce: string, id: string, nick: string = "", a
|
|||||||
|
|
||||||
const syncSpink = () => {
|
const syncSpink = () => {
|
||||||
fetch("https://spinkacek.ga/api/spinkacky")
|
fetch("https://spinkacek.ga/api/spinkacky")
|
||||||
.then(r => r.json() as Promise<Record<string, Spinkackar>>)
|
.then(r => r.json() as Promise<{ spinkacky: Record<string, Spinkackar>; }>)
|
||||||
.then(d => {
|
.then(d => {
|
||||||
const data = d.spinkacky;
|
const data = d.spinkacky;
|
||||||
const keys = Object.keys(data);
|
const keys = Object.keys(data);
|
||||||
const values = Object.values(data);
|
const values = Object.values(data);
|
||||||
spinkacky.splice(0);
|
spinkacky = {};
|
||||||
|
|
||||||
for (let i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
if (!values[i].spinkacek || keys[i][0] === "i") continue;
|
const k = keys[i];
|
||||||
spinkacky.push(keys[i].slice(8));
|
if (k[0] != "d") continue;
|
||||||
|
spinkacky[k.slice(8)] = { spinkacek: values[i].spinkacek, timeup: values[i].timeup * 1000 };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -99,7 +100,6 @@ module.exports = {
|
|||||||
const ted = new Date();
|
const ted = new Date();
|
||||||
const tedT = Number(ted);
|
const tedT = Number(ted);
|
||||||
const spink = new Date();
|
const spink = new Date();
|
||||||
const formatter = new Intl.DateTimeFormat("cs", { day: "numeric", month: "short", hour: "numeric", minute: "numeric", second: "numeric" });
|
|
||||||
|
|
||||||
if (/^\d+$/.test(kdy) || !kdy)
|
if (/^\d+$/.test(kdy) || !kdy)
|
||||||
spink.setTime(tedT + Number(kdy || 7200) * 1000);
|
spink.setTime(tedT + Number(kdy || 7200) * 1000);
|
||||||
@ -126,12 +126,19 @@ module.exports = {
|
|||||||
|
|
||||||
budouciSpinky[mes.author.id] = setTimeout(() => contactSpinkServer("spinkacek", mes.author.id, mes.author.username, mes.author.avatarURL()), Number(spink) - tedT);
|
budouciSpinky[mes.author.id] = setTimeout(() => contactSpinkServer("spinkacek", mes.author.id, mes.author.username, mes.author.avatarURL()), Number(spink) - tedT);
|
||||||
return `tvuj spinkacek byl naplanovan na ${formatter.format(spink)}`;
|
return `tvuj spinkacek byl naplanovan na ${formatter.format(spink)}`;
|
||||||
|
},
|
||||||
|
|
||||||
|
ps: {
|
||||||
|
als: ["poslednispink"],
|
||||||
|
run: (mes: Message) => {
|
||||||
|
return `naposled si spal ${formatter.format(new Date(spinkacky[mes.author.id].timeup))}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
on_voiceStateUpdate: (bef: VoiceState, aft: VoiceState) => {
|
on_voiceStateUpdate: (bef: VoiceState, aft: VoiceState) => {
|
||||||
if (!aft.channel || bef.channel) return;
|
if (!aft.channel || bef.channel) return;
|
||||||
if (spinkacky.includes(aft.id)) aft.disconnect("spinkacek")
|
if (spinkacky[aft.id]?.spinkacek) aft.disconnect("spinkacek")
|
||||||
.catch(err => console.log("spinkacek odpojit se nepovedlo nebo co:", err));
|
.catch(err => console.log("spinkacek odpojit se nepovedlo nebo co:", err));
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -151,7 +158,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (spinkacky.includes(mes.author.id) && cmd != "vstavacek") {
|
} else if (spinkacky[mes.author.id]?.spinkacek && cmd != "vstavacek") {
|
||||||
mes.delete();
|
mes.delete();
|
||||||
(async () => {
|
(async () => {
|
||||||
const chanel = mes.author.dmChannel ?? await mes.author.createDM();
|
const chanel = mes.author.dmChannel ?? await mes.author.createDM();
|
||||||
|
|||||||
@ -31,6 +31,7 @@ export interface Komand {
|
|||||||
|
|
||||||
export interface Spinkackar {
|
export interface Spinkackar {
|
||||||
spinkacek: boolean;
|
spinkacek: boolean;
|
||||||
|
timeup: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FakePresence {
|
export interface FakePresence {
|
||||||
@ -47,13 +48,13 @@ export interface UserChange {
|
|||||||
export type StatusyINaFounu = "Online" | "OnlinePhone" | "Idle" | "IdlePhone" | "DND" | "DNDPhone" | "Offline";
|
export type StatusyINaFounu = "Online" | "OnlinePhone" | "Idle" | "IdlePhone" | "DND" | "DNDPhone" | "Offline";
|
||||||
|
|
||||||
export interface ZmenovejObjekt {
|
export interface ZmenovejObjekt {
|
||||||
id: string,
|
id: string;
|
||||||
nick?: string,
|
nick?: string;
|
||||||
pfp?: string,
|
pfp?: string;
|
||||||
status?: string;
|
status?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MuzikaFace {
|
export interface MuzikaFace {
|
||||||
name: string,
|
name: string;
|
||||||
volume: number;
|
volume: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -163,3 +163,5 @@ export function loadEnv() {
|
|||||||
if (!existsSync("config.json")) throw new Error("config.json neexistuje");
|
if (!existsSync("config.json")) throw new Error("config.json neexistuje");
|
||||||
process.env = { ...process.env, ...require("../../config.json") };
|
process.env = { ...process.env, ...require("../../config.json") };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const formatter = new Intl.DateTimeFormat("cs", { day: "numeric", month: "short", hour: "numeric", minute: "numeric", second: "numeric" });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user