corrige bug

This commit is contained in:
Arhur
2024-04-26 23:38:26 +02:00
parent e0b7657705
commit 15fe8b0c1d
+7 -11
View File
@@ -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);
});
}
};