From 15fe8b0c1d7777c5bf379a862111b4eb12fe132b Mon Sep 17 00:00:00 2001 From: Arhur Date: Fri, 26 Apr 2024 23:38:26 +0200 Subject: [PATCH] corrige bug --- commands/automatisation/viewtasks.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/commands/automatisation/viewtasks.ts b/commands/automatisation/viewtasks.ts index 7e98011..28fb3d6 100644 --- a/commands/automatisation/viewtasks.ts +++ b/commands/automatisation/viewtasks.ts @@ -9,24 +9,20 @@ module.exports = { utilisation: '', async execute(message: Message, args: string[], client: Client) { + message.delete(); db.all(`SELECT * FROM task`, (err: any, rows: any) => { if (err) { console.error(err.message); } - let tasks = ''; + let tasks = '# Voici la liste des tâches :'; rows.forEach((row: any) => { + if (tasks.length + row.id.toString().length + row.name.length + row.time.toString().length > 1970) { + message.channel.send(tasks); + tasks = ''; + } tasks += `\n- ${row.id} - ${row.name} : ${row.time} minutes`; }); - - const tasksChunks = tasks.match(/.{1,2000}/g); - - if (tasksChunks) { - tasksChunks.forEach((chunk: string) => { - message.edit(`# Liste des tâches :${chunk}`); - }); - } else { - message.edit(`# Liste des tâches :${tasks}`); - } + message.channel.send(tasks); }); } }; \ No newline at end of file