if you spink you get role spink

This commit is contained in:
Histmy 2021-09-29 18:59:07 +02:00
parent 44329ce277
commit 7141da4c58
3 changed files with 30 additions and 9 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "denim_3001", "name": "denim_3001",
"version": "3001.28.0", "version": "3001.29.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "denim_3001", "name": "denim_3001",
"version": "3001.28.0", "version": "3001.29.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.28.0", "version": "3001.29.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,6 +1,6 @@
// Modul dedikovaný funkci spinkáček // Modul dedikovaný funkci spinkáček
import { Message, VoiceState } from "discord.js"; 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";
@ -33,6 +33,28 @@ const syncSpink = () => {
syncSpink(); syncSpink();
const handleSpink = async (act: "spinkacek" | "vstavacek", member: GuildMember, guild: Guild) => {
const spink = act == "spinkacek";
const ok = spink
? await contactSpinkServer(act, member.id, member.user.username, member.user.avatarURL())
: await contactSpinkServer(act, member.id);
if (!ok.startsWith("OK")) return false;
const c = guild.roles.cache;
const spinkRole = c.find(r => r.name == "spink");
const adminRole = c.find(r => r.name == "admin");
if (spink) {
if (spinkRole) member.roles.add(spinkRole);
if (adminRole) member.roles.remove(adminRole);
} else {
if (spinkRole) member.roles.remove(spinkRole);
if (adminRole) member.roles.add(adminRole);
}
return ok;
};
module.exports = { module.exports = {
more_komandy: { more_komandy: {
@ -40,7 +62,7 @@ module.exports = {
als: ["spink", "spoink", "spinkake", "spoinkacek", "gn", "<:spinkacek:761652251966046208>", "<:gn:887124590583746590>"], als: ["spink", "spoink", "spinkake", "spoinkacek", "gn", "<:spinkacek:761652251966046208>", "<:gn:887124590583746590>"],
run: async (_: any, mes: Message) => { run: async (_: any, mes: Message) => {
if (mes.author.bot) return `až někdy${emouty.kapp}`; if (mes.author.bot) return `až někdy${emouty.kapp}`;
if (await contactSpinkServer('spinkacek', mes.author.id, mes.author.username, mes.author.avatarURL()) === "OK") { if (await handleSpink("spinkacek", mes.member!, mes.guild!)) {
mes.react(emouty.spinkacek); mes.react(emouty.spinkacek);
const uz = budouciSpinky[mes.author.id]; const uz = budouciSpinky[mes.author.id];
if (uz) { if (uz) {
@ -57,10 +79,9 @@ module.exports = {
run: async (_: any, mes: Message) => { run: async (_: any, mes: Message) => {
if (mes.author.bot) return emouty.sjeta; if (mes.author.bot) return emouty.sjeta;
const odpoved = await contactSpinkServer('vstavacek', mes.author.id); const odpoved = await handleSpink("vstavacek", mes.member!, mes.guild!);
const [ok, casTxt] = odpoved.split(" "); if (!odpoved) return "uz jsi vzhuru ty hajzle";
const cas = Number(casTxt); const cas = Number(odpoved.slice(3));
if (ok !== "OK") return "uz jsi vzhuru ty hajzle";
const formatedCas = formatCas(cas); const formatedCas = formatCas(cas);
let zpr = ""; let zpr = "";
if (cas >= 57600) zpr = "mas dat more vstavacek uz kdyz vstanes retarde"; if (cas >= 57600) zpr = "mas dat more vstavacek uz kdyz vstanes retarde";