jehokomandy a muzika lidi
This commit is contained in:
parent
51bb0238fb
commit
a0bbacfc12
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "denim_3001",
|
||||
"version": "3001.48.2",
|
||||
"version": "3001.48.3",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "denim_3001",
|
||||
"version": "3001.48.2",
|
||||
"version": "3001.48.3",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@discordjs/voice": "^0.15.0",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "denim_3001",
|
||||
"version": "3001.48.2",
|
||||
"version": "3001.48.3",
|
||||
"description": "Toto je velmi kvalitní bot.",
|
||||
"repository": {
|
||||
"url": "https://github.com/Histmy/Denim-Bot/"
|
||||
|
||||
32
src/app.ts
32
src/app.ts
@ -1,20 +1,15 @@
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, Client, CommandInteraction, ComponentType, GatewayIntentBits, Message, Partials } from "discord.js";
|
||||
import { readdirSync } from "fs";
|
||||
import { CUser, EventSOn, KomandNaExport, Komand, ListenerFunkce, Modul, SRecord, SuperListenerFunkce, CClient, HelpServer, KomandRaw } from "./utils/types";
|
||||
import { adminLog, formatCas, oddiakritikovat, log, rand } from "./utils/utils.js";
|
||||
import { adminLog, formatCas, oddiakritikovat, log, rand, prefix } from "./utils/utils.js";
|
||||
import levenshtein from "js-levenshtein";
|
||||
import { emouty } from "./utils/emotes";
|
||||
import { existsSync } from "fs";
|
||||
|
||||
if (!existsSync("config.json")) throw new Error("config.json neexistuje");
|
||||
process.env = { ...process.env, ...require("../config.json") };
|
||||
|
||||
const ints = GatewayIntentBits;
|
||||
const client = new Client({
|
||||
partials: [Partials.Channel],
|
||||
intents: [ints.Guilds, ints.GuildVoiceStates, ints.GuildPresences, ints.GuildMessages, ints.DirectMessages, ints.MessageContent]
|
||||
}) as CClient;
|
||||
const prefix = process.env.prefix || "more";
|
||||
const DJ_PREFIX = "dj:";
|
||||
const modulFolder = `${__dirname}/modules/`;
|
||||
const eventy: SRecord<ListenerFunkce[]> = {};
|
||||
@ -215,6 +210,16 @@ function renderMessage(expression: string, args: string[]) {
|
||||
}
|
||||
}
|
||||
|
||||
function handle(e: unknown, mesOrInt: Message | CommandInteraction) {
|
||||
if (process.env.dieOnError) throw e;
|
||||
log("error pri spousteni akce", e as Error);
|
||||
const admin = process.env.adminID;
|
||||
|
||||
const txt = `pri spousteni thohoto komandu nastala chyba ${admin ? `<@${admin}> uz?` : ""}`;
|
||||
if (mesOrInt instanceof Message) return void mesOrInt.channel.send(txt);
|
||||
mesOrInt.reply(txt);
|
||||
}
|
||||
|
||||
async function runKomand(mes: Message, cmd: Komand, cmdName: string, arg: string): Promise<void>;
|
||||
async function runKomand(interaction: CommandInteraction, cmd: Komand, cmdName: string): Promise<void>;
|
||||
async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cmdName: string, arg?: string) {
|
||||
@ -240,17 +245,12 @@ async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cm
|
||||
const result = await akce(mesOrInt, arg);
|
||||
if (!result) return;
|
||||
|
||||
if (mesOrInt instanceof Message) return void mesOrInt.channel.send(result);
|
||||
if (mesOrInt instanceof Message) return void mesOrInt.channel.send(result)
|
||||
.catch(e => handle(e, mesOrInt));
|
||||
// @ts-ignore a zas ksd
|
||||
mesOrInt.reply(result);
|
||||
} catch (e) {
|
||||
if (process.env.dieOnError) throw e;
|
||||
log("error pri spousteni akce", e as Error);
|
||||
const admin = process.env.adminID;
|
||||
|
||||
const txt = `pri spousteni thohoto komandu nastala chyba ${admin ? `<@${admin}> uz?` : ""}`;
|
||||
if (mesOrInt instanceof Message) return void mesOrInt.channel.send(txt);
|
||||
mesOrInt.reply(txt);
|
||||
handle(e, mesOrInt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -327,10 +327,10 @@ client.on("presenceUpdate", (bef, aft) => {
|
||||
client.on("interactionCreate", async int => {
|
||||
if (process.env.ignoreMess || !int.isCommand()) return;
|
||||
|
||||
const cmdName = int.commandName.slice(4);
|
||||
const cmdName = int.commandName.slice(prefix.length);
|
||||
|
||||
const command = client.komandy[cmdName];
|
||||
if (!command) int.reply(`komand nenalezen ${emouty.lukiw}`);
|
||||
if (!command) return void int.reply(`komand nenalezen ${emouty.lukiw}`);
|
||||
|
||||
runKomand(int, command, cmdName);
|
||||
});
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { CClient, HelpServer, Komand, KomandNaExport, Modul, SRecord } from "../utils/types";
|
||||
import { join } from "path";
|
||||
import { existsSync, readFileSync, writeFileSync } from "fs";
|
||||
import { oddiakritikovat } from "../utils/utils";
|
||||
import { oddiakritikovat, prefix } from "../utils/utils";
|
||||
|
||||
let client: CClient;
|
||||
const cesta = `${join(__dirname, "../../res/")}custom`;
|
||||
@ -117,20 +117,75 @@ const exp: Modul = {
|
||||
}
|
||||
},
|
||||
|
||||
mojekomandy: mes => {
|
||||
let text = "tovje koamdy:\n";
|
||||
mojekomandy: async mes => {
|
||||
const arr = ["tovje koamdy:\n"];
|
||||
|
||||
for (const key in customKomandy) {
|
||||
if (customKomandy[key].owner == mes.author.id) text += `${key}\n`;
|
||||
if (customKomandy[key].owner == mes.author.id) arr.push(key);
|
||||
}
|
||||
|
||||
text += "\ntovje ajilasy:\n";
|
||||
arr.push("\ntovje ajilasy:\n");
|
||||
|
||||
for (const key in customAliasy) {
|
||||
if (customAliasy[key].owner == mes.author.id) text += `${key}\n`;
|
||||
if (customAliasy[key].owner == mes.author.id) arr.push(key);
|
||||
}
|
||||
|
||||
return text;
|
||||
let text = "";
|
||||
arr.forEach(element => {
|
||||
if (text.length + element.length > 2000) {
|
||||
mes.channel.send({ content: text, allowedMentions: { users: [] } });
|
||||
text = "";
|
||||
}
|
||||
text += `${element}\n`;
|
||||
});
|
||||
|
||||
return { content: text, allowedMentions: { users: [] } };
|
||||
},
|
||||
|
||||
jehokomandy: {
|
||||
DMUnsafe: true,
|
||||
run: () => {
|
||||
const client: CClient = module.exports.client;
|
||||
|
||||
return `tuto je novej komand a histmaj mrdal aby to slo i takhle proste pouzij </${prefix}jehokomandy:${client.slashCommandy[`${prefix}jehokomandy`]}>`;
|
||||
},
|
||||
|
||||
slashRun: int => {
|
||||
const kdoId = int.options.get("gdo")!.value as string;
|
||||
const kdo = client.users.cache.get(kdoId);
|
||||
|
||||
if (!kdo) return "tutoko kokota neznam";
|
||||
|
||||
const arr = [`koamdy kkta ${kdo.username}:\n`];
|
||||
|
||||
for (const key in customKomandy) {
|
||||
if (customKomandy[key].owner == kdo.id) arr.push(key);
|
||||
}
|
||||
|
||||
arr.push("\njeho ajilasy:\n");
|
||||
|
||||
for (const key in customAliasy) {
|
||||
if (customAliasy[key].owner == kdo.id) arr.push(key);
|
||||
}
|
||||
|
||||
function send(text: string, i: number) {
|
||||
if (i == 0) int.reply({ content: text, allowedMentions: { users: [] } });
|
||||
else int.channel!.send({ content: text, allowedMentions: { users: [] } });
|
||||
}
|
||||
|
||||
let text = "";
|
||||
let i = 0;
|
||||
arr.forEach(element => {
|
||||
if (text.length + element.length > 2000) {
|
||||
send(text, i);
|
||||
text = "";
|
||||
i++;
|
||||
}
|
||||
text += `${element}\n`;
|
||||
});
|
||||
|
||||
send(text, i);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -37,8 +37,12 @@ const exp: Modul = {
|
||||
if (druh != "yt_video" && druh != "so_track") return "tuto neumim zahrat";
|
||||
ajtem.url = txt;
|
||||
if (druh == "yt_video") {
|
||||
const video = await video_basic_info(txt);
|
||||
ajtem.name = video.video_details.title!;
|
||||
try {
|
||||
const video = await video_basic_info(txt);
|
||||
ajtem.name = video.video_details.title!;
|
||||
} catch (e) {
|
||||
return "sorka bracho ael tuto je ajdzreztrigtnuti";
|
||||
}
|
||||
if (typeof ajtem.name == "undefined") {
|
||||
const client: Client = module.exports.client;
|
||||
adminLog(client, "video nemá název");
|
||||
|
||||
@ -1,32 +1,47 @@
|
||||
import { REST, RESTPostAPIChatInputApplicationCommandsJSONBody, Routes } from 'discord.js';
|
||||
import { ApplicationCommandOptionType, REST, RESTPostAPIChatInputApplicationCommandsJSONBody, Routes } from 'discord.js';
|
||||
import { CClient, Modul, SRecord } from '../utils/types';
|
||||
import { prefix } from '../utils/utils';
|
||||
|
||||
const komandy: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [
|
||||
{
|
||||
name: "moreanketa",
|
||||
name: `${prefix}anketa`,
|
||||
description: "udelam fajnonovou anketu haby sy moch myt zbitecny anzori ostatnich",
|
||||
dm_permission: false,
|
||||
options: [
|
||||
{
|
||||
name: "moznosti",
|
||||
description: "mezi cim maj ty morove vibirat (odeluj carkama nebo pipama)",
|
||||
type: 3, // String
|
||||
type: ApplicationCommandOptionType.String,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
name: "cas",
|
||||
description: "jak dlouho budem cekat na ti bridili nez se rozhodnou",
|
||||
type: 4 // Integer
|
||||
type: ApplicationCommandOptionType.Integer
|
||||
},
|
||||
{
|
||||
name: "jmena",
|
||||
description: "jestli chces strapnovat ostatni jejich vibjerem tak tuto zapni",
|
||||
type: 5 // Boolean
|
||||
type: ApplicationCommandOptionType.Boolean
|
||||
},
|
||||
{
|
||||
name: "neprubezny",
|
||||
description: "jestli chces haby bili visledky vydet hned nebo az potom co bude pozde sy to rozmyslet",
|
||||
type: 5 // Boolean
|
||||
type: ApplicationCommandOptionType.Boolean
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
name: `${prefix}jehokomandy`,
|
||||
description: "napysu ti koamndy kteri udelal kkt kteriho viberes",
|
||||
dm_permission: false,
|
||||
options: [
|
||||
{
|
||||
name: "gdo",
|
||||
description: "ten kkt",
|
||||
type: ApplicationCommandOptionType.User,
|
||||
required: true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -35,6 +50,7 @@ const komandy: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [
|
||||
const exp: Modul = {
|
||||
on_ready: async () => {
|
||||
const client = module.exports.client as CClient;
|
||||
client.slashCommandy = {};
|
||||
|
||||
// Construct and prepare an instance of the REST module
|
||||
const rest = new REST({ version: '10' }).setToken(process.env.token!);
|
||||
@ -49,7 +65,9 @@ const exp: Modul = {
|
||||
{ body: komandy },
|
||||
)) as SRecord<string>[] | undefined;
|
||||
|
||||
console.log(data);
|
||||
data?.forEach(command => {
|
||||
client.slashCommandy[command.name] = command.id;
|
||||
});
|
||||
|
||||
console.log(`Successfully reloaded ${data?.length} application (/) commands.`);
|
||||
} catch (error) {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { StreamType, VoiceConnection } from "@discordjs/voice";
|
||||
import { Awaitable, Client, ClientEvents, ClientPresenceStatusData, CommandInteraction, Message, MessageCreateOptions, MessagePayload, User } from "discord.js";
|
||||
import { Awaitable, BaseMessageOptions, Client, ClientEvents, ClientPresenceStatusData, CommandInteraction, Message, MessageCreateOptions, MessagePayload, User } from "discord.js";
|
||||
import { EventEmitter } from "events";
|
||||
import { Readable } from "node:stream";
|
||||
|
||||
export type RunFunkce = (message: Message, argumenty: string) => Awaitable<string | MessagePayload | MessageCreateOptions | void>;
|
||||
export type InteractionRunFunkce = (interaction: CommandInteraction) => Awaitable<string | void>;
|
||||
export type InteractionRunFunkce = (interaction: CommandInteraction) => Awaitable<string | BaseMessageOptions | void>;
|
||||
|
||||
export type BaseKomandProps = {
|
||||
als?: string[];
|
||||
@ -116,4 +116,5 @@ export interface HelpServer {
|
||||
export class CClient extends Client {
|
||||
komandy!: SRecord<Komand>;
|
||||
aliasy!: SRecord<string>;
|
||||
slashCommandy!: SRecord<string>;
|
||||
}
|
||||
|
||||
@ -3,10 +3,14 @@ import { ChannelType, Client, Guild, StageChannel, User, VoiceChannel } from "di
|
||||
import { once } from "events";
|
||||
import { JoinHovna, MuzikaFace, SRecord } from "./types";
|
||||
import { Readable } from "node:stream";
|
||||
import { existsSync } from "fs";
|
||||
|
||||
const pripojeni: SRecord<PlayerSubscription> = {};
|
||||
const timeAnouncability: Record<string, boolean> = {};
|
||||
|
||||
if (!existsSync("config.json")) throw new Error("config.json neexistuje");
|
||||
process.env = { ...process.env, ...require("../../config.json") };
|
||||
|
||||
export const oddiakritikovat = (a: string) => {
|
||||
return a
|
||||
.replace(/[àáâãäåæāăą]/g, "a")
|
||||
@ -196,3 +200,5 @@ export async function sendDM(user: User, txt: string) {
|
||||
}
|
||||
|
||||
export const rand = (max: number) => Math.floor(Math.random() * max);
|
||||
|
||||
export const prefix = process.env.prefix || "more";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user