Bot now listens on DM

even better react
This commit is contained in:
Histmy 2022-06-12 16:24:19 +02:00
parent a246a5007f
commit 8820aa5c20
9 changed files with 65 additions and 48 deletions

4
package-lock.json generated
View File

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

View File

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

View File

@ -11,7 +11,10 @@ const custom: CustomKomandy = require("./utils/customCommands");
loadEnv();
const ints = Intents.FLAGS;
const client = new Client({ intents: [ints.GUILDS, ints.GUILD_VOICE_STATES, ints.GUILD_PRESENCES, ints.GUILD_MESSAGES] });
const client = new Client({
partials: ["CHANNEL"],
intents: [ints.GUILDS, ints.GUILD_VOICE_STATES, ints.GUILD_PRESENCES, ints.GUILD_MESSAGES, ints.DIRECT_MESSAGES]
});
const prefix = process.env.prefix || "more";
const modulFolder = `${__dirname}/modules/`;
const eventy: SRecord<ListenerFunkce[]> = {};
@ -91,7 +94,7 @@ readdirSync(modulFolder).forEach(soubor => {
komandy[cmdName] = { run: value };
toCoExportuju.arg = fnToArg(value);
} else {
komandy[cmdName] = { run: value.run, cd: value.cd };
komandy[cmdName] = { run: value.run, cd: value.cd, DMUnsafe: value.DMUnsafe };
Object.assign(toCoExportuju, { als: value.als, arg: value.arg ?? fnToArg(value.run) });
hide = !!value.hidden;
value.als?.forEach(al => aliasy[al] = cmdName);
@ -153,6 +156,7 @@ client.on("messageCreate", async mes => {
const cmdName = aliasy[komand] ?? komand;
if (runEvent("message", [mes, cmdName])) return;
const cmd = komandy[cmdName] ?? customKomandy[cmdName];
if (cmd.DMUnsafe && mes.channel.type == "DM") return void mes.channel.send("tuten komand bohuzel v sz nefunkuje");
if (!cmd) {
const slova: string[] = [];

View File

@ -1,30 +1,31 @@
// Komandy, který pošlou jenom celArgs a random hovno
import { Message } from "discord.js";
import { emouty } from "../utils/emotes";
import { Modul } from "../utils/types";
const delAndReturn = (mes: Message, co: string) => {
if (mes.channel.type != "DM") mes.delete();
return co;
};
const exp: Modul = {
more_komandy: {
rekni: (mes, co) => {
if (mes.author.bot) return "ne";
const corict = co || `co mam jako rict ${mes.author}`;
mes.delete();
return corict;
return delAndReturn(mes, co || `co mam jako rict ${mes.author}`);
},
clap: (mes, text) => {
mes.delete();
return `${text} ${emouty.clap}`;
return delAndReturn(mes, `${text} ${emouty.clap}`);
},
clap2: (mes, text) => {
mes.delete();
return `${emouty.clap2} ${text}`;
return delAndReturn(mes, `${emouty.clap2} ${text}`);
},
voliz: (mes, co) => {
mes.delete();
return `${emouty.lickL}${co}${emouty.lickR}`;
return delAndReturn(mes, `${emouty.lickL}${co}${emouty.lickR}`);
},
pozdrav: (_, koho) => `zdravim ${koho}`,

View File

@ -91,11 +91,15 @@ const exp: Modul = {
naCo = await mes.channel.messages.fetch(mes.reference.messageId!);
} else {
const msgs = [...mes.channel.messages.cache.values()];
naCo = msgs[msgs.length - 2];
console.log(msgs.length);
if (msgs.length < 2) {
naCo = (await mes.channel.messages.fetch({ limit: 2 })).at(1)!;
}
else naCo = msgs[msgs.length - 2];
}
const reakce: Promise<void | MessageReaction>[] = [];
mes.delete();
if (mes.channel.type != "DM") mes.delete();
emouty.forEach(emout => {
reakce.push(naCo.react(emout)
.catch(() => { }));

View File

@ -6,30 +6,33 @@ import { joinVoice, play } from "../utils/utils";
const exp: Modul = {
more_komandy: {
zahraj: async (mes, txt) => {
let url: string;
const druh = await validate(txt);
if (druh && druh != "search") {
if (druh != "yt_video" && druh != "so_track") return "tuto neumim zahrat";
url = txt;
if (druh == "yt_video") {
video_basic_info(url).then(v => mes.channel.send(`hraju \`${v.video_details.title}\``));
zahraj: {
DMUnsafe: true,
run: async (mes, txt) => {
let url: string;
const druh = await validate(txt);
if (druh && druh != "search") {
if (druh != "yt_video" && druh != "so_track") return "tuto neumim zahrat";
url = txt;
if (druh == "yt_video") {
video_basic_info(url).then(v => mes.channel.send(`hraju \`${v.video_details.title}\``));
} else {
soundcloud(url).then(s => mes.channel.send(`hraju \`${s.name}\``));
}
} else {
soundcloud(url).then(s => mes.channel.send(`hraju \`${s.name}\``));
const msg = mes.channel.send("hledam");
const hledani = await search(txt, { limit: 1 });
url = hledani[0].url;
msg.then(m => m.edit(`hraju \`${hledani[0].title}\``));
}
} else {
const msg = mes.channel.send("hledam");
const hledani = await search(txt, { limit: 1 });
url = hledani[0].url;
msg.then(m => m.edit(`hraju \`${hledani[0].title}\``));
const kanel = mes.member?.voice.channel;
if (!kanel) return "nejsi ve vojsu ty kkt";
const { conn } = await joinVoice(kanel);
const src = await stream(url);
play(conn, { name: src.stream, volume: 1, type: src.type });
}
const kanel = mes.member?.voice.channel;
if (!kanel) return "nejsi ve vojsu ty kkt";
const { conn } = await joinVoice(kanel);
const src = await stream(url);
play(conn, { name: src.stream, volume: 1, type: src.type });
}
}
};

View File

@ -1,6 +1,6 @@
// Modul dedikovaný funkci spinkáček
import { GuildMember, Message, Presence, Role, TextBasedChannel, VoiceState } from "discord.js";
import { Message, Presence, Role, TextBasedChannel, User, VoiceState } from "discord.js";
import fetch from "node-fetch";
import { emouty } from "../utils/emotes";
import { Modul, Spinkackar, SRecord } from "../utils/types";
@ -36,10 +36,10 @@ const syncSpink = () => {
syncSpink();
const handleSpink = async (act: "spinkacek" | "vstavacek", member: GuildMember) => {
const handleSpink = async (act: "spinkacek" | "vstavacek", user: User) => {
const ok = act == "spinkacek"
? await contactSpinkServer(act, member.id, member.user.username, member.user.avatarURL())
: await contactSpinkServer(act, member.id);
? await contactSpinkServer(act, user.id, user.username, user.avatarURL())
: await contactSpinkServer(act, user.id);
return ok.startsWith("OK") ? ok : false;
};
@ -54,7 +54,7 @@ const ifUzRemove = (m: Message) => {
return false;
};
const tovjemamvolepreceroliky = async (roliky: GuildMember) => {
const tovjemamvolepreceroliky = async (roliky: User) => {
const odpoved = await handleSpink("vstavacek", roliky);
if (!odpoved) return "uz jsi vzhuru ty hajzle";
const cas = Number(odpoved.slice(3));
@ -66,7 +66,7 @@ const tovjemamvolepreceroliky = async (roliky: GuildMember) => {
else if (cas < 30) zpr = "dobrej mikrospánek debile";
else if (cas < 10800) zpr = "dobrej fake spink debile";
return `dobry rano hajzle ${roliky.user}\nspal sy ${formatedCas}\n${zpr}`;
return `dobry rano hajzle ${roliky}\nspal sy ${formatedCas}\n${zpr}`;
};
const exp: Modul = {
@ -76,7 +76,7 @@ const exp: Modul = {
als: ["spink", "spoink", "spinkake", "spoinkacek", "gn", emouty.spinkacek, emouty.gn],
run: async mes => {
if (mes.author.bot) return `až někdy${emouty.kapp}`;
if (await handleSpink("spinkacek", mes.member!)) {
if (await handleSpink("spinkacek", mes.author)) {
mes.react(emouty.spinkacek);
ifUzRemove(mes);
}
@ -89,7 +89,7 @@ const exp: Modul = {
run: async mes => {
if (mes.author.bot) return emouty.sjeta;
return tovjemamvolepreceroliky(mes.member!);
return tovjemamvolepreceroliky(mes.author);
}
},
@ -127,7 +127,7 @@ const exp: Modul = {
ifUzRemove(mes);
budouciSpinky[mes.author.id] = setTimeout(() => {
handleSpink("spinkacek", mes.member!);
handleSpink("spinkacek", mes.author);
mes.react(emouty.spinkacek);
}, Number(spink) - tedT);
if (!random) return `tvuj spinkacek byl naplanovan na ${formatter(spink)}`;
@ -230,12 +230,12 @@ const exp: Modul = {
const prop = autoSpinky[aft.userId];
if (!prop) return;
if (!befoff && aftoff) {
handleSpink("spinkacek", aft.member!);
handleSpink("spinkacek", aft.member!.user);
}
if (befoff && !aftoff) {
if (prop[0]) delete autoSpinky[aft.userId];
const kanel = prop[1];
if (kanel?.isText()) kanel.send(await tovjemamvolepreceroliky(aft.member!));
if (kanel?.isText()) kanel.send(await tovjemamvolepreceroliky(aft.member!.user));
}
}
};

View File

@ -65,6 +65,7 @@ const exp: Modul = {
vojs: {
cd: 1800,
arg: "potichu (nepovinné)",
DMUnsafe: true,
run: (mes, arg) => {
const channel = mes.member?.voice.channel;
if (!channel) return `di si tam sam ne ty gadzo ${mes.author}`;
@ -90,6 +91,7 @@ const exp: Modul = {
vypadni: {
als: ["odejdi", "disconnect", "leave", "odpoj", "votpoj", "vodpoj", "vodprejskni", "tahni"],
DMUnsafe: true,
run: mes => {
const vojs = getVoiceConnection(mes.guildId!);
if (!vojs) return 'nejsem ve vojsu';
@ -101,6 +103,7 @@ const exp: Modul = {
vytah: {
als: ["vitah"],
DMUnsafe: true,
run: (mes, parto) => {
if (!mes.member?.voice.channel) return `nejsi ve vojsu ty gadzo ${mes.author}`;
if (!parto) return `napis do jakiho patra ${mes.author}`;

View File

@ -16,6 +16,7 @@ type KomandRaw = {
run: string | RunFunkce;
cd?: number;
hidden?: true;
DMUnsafe?: true;
} & BaseKomandProps;
export type ListenerFunkce = (...args: any[]) => void;
@ -41,6 +42,7 @@ export type Modul = {
export interface Komand {
run: RunFunkce | string;
cd?: number;
DMUnsafe?: true;
}
export interface Spinkackar {