The older version of this repo I created some easy modules. Wich I want to change to .ts and put in the latest version.
I hope that someone sees what exactly I am missing in my code, why this don't return anything.
But I don't know what I'm missing, i added a teammaker.ts with the following code:
import Strings from "../lib/db";
import inputSanitization from "../sidekick/input-sanitization";
import Client from "../sidekick/client";
import { proto } from "@adiwajshing/baileys";
import BotsApp from "../sidekick/sidekick";
import { MessageType } from "../sidekick/message-type";
import STRINGS from "../lib/db";
module.exports = {
name: "teammaker",
description: STRINGS.teammaker.DESCRIPTION,
extendedDescription: STRINGS.teammaker.EXTENDED_DESCRIPTION,
demo: { isEnabled: false },
async handle(client: Client, chat: proto.IWebMessageInfo, BotsApp: BotsApp, args: string[]): Promise<void> {
try{
if(args.length === 0) {
client.sendMessage(
BotsApp.chatId,
STRINGS.teammaker.NO_TEXT,
MessageType.text
).catch(err => inputSanitization.handleError(err, client, BotsApp));
return;
}
if(args.length > 0) {
const bodySplitter = BotsApp.body.split("|");
let deelnemers = bodySplitter[0].slice(0, bodySplitter[0].length - 1).split(" ");
deelnemers.shift();
const aantalTeams:any = bodySplitter[1];
function shuffleArray(arr) {
arr.sort(() => Math.random() - 0.5);
}
shuffleArray(deelnemers);
const spelersPerTeam = deelnemers.length / aantalTeams;
let teamNumber = 1;
let i = 0;
function splitIntoChunk(arr, chunk) {
for (i < arr.length; i += chunk;) {
let tempArray;
tempArray = arr.slice(i, i + chunk);
client.sendMessage(
BotsApp.chatId,
`*░░░░░░░░░░ Team ${teamNumber} ░░░░░░░░░░*\n\n${tempArray.join(',\n')}\n\n *░░░░░░░░░░░░░░░░░░░░░░░░░*`,
MessageType.text
);
teamNumber++;
}
}
splitIntoChunk(deelnemers, spelersPerTeam);
}
} catch (err) {
await inputSanitization.handleError(err, client, BotsApp);
}
}
}
The older version of this repo I created some easy modules. Wich I want to change to .ts and put in the latest version. I hope that someone sees what exactly I am missing in my code, why this don't return anything.
But I don't know what I'm missing, i added a
teammaker.ts
with the following code: