From 200678212d950061fe1d3ab324262eb6efbca193 Mon Sep 17 00:00:00 2001 From: Tutur33 Date: Tue, 12 Mar 2024 20:10:35 +0100 Subject: [PATCH] upgrade --- commands/automatisation/taskinfo.ts | 26 ++++++++++++++++++++++++++ commands/automatisation/viewtasks.ts | 23 +++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 commands/automatisation/taskinfo.ts create mode 100644 commands/automatisation/viewtasks.ts diff --git a/commands/automatisation/taskinfo.ts b/commands/automatisation/taskinfo.ts new file mode 100644 index 0000000..36d9309 --- /dev/null +++ b/commands/automatisation/taskinfo.ts @@ -0,0 +1,26 @@ +import { Message, Client } from 'discord.js'; +import db from '../../fonctions/instanceDB'; +require('dotenv').config(); + +module.exports = { + aliases: [], + description: 'Afficher toutes les informations d\'une tâche.', + emote: '⏱️', + utilisation: '', + + async execute(message: Message, args: string[], client: Client) { + let id = args[0]; + if (!id) { + return message.edit('Veuillez entrer un id'); + } + db.get(`SELECT * FROM task WHERE id = ?`, [id], (err: any, row: any) => { + if (err) { + console.error(err.message); + } + if (!row) { + return message.edit('Aucune tâche avec cet id.'); + } + message.edit(`# Informations de la tâche ${row.name} :\n- Id : ${row.id}\n- Nom : ${row.name}\n- Temps : ${row.time} minutes\n- Code :\n\`\`\`js\n${row.code}\`\`\``); + }); + } +}; \ No newline at end of file diff --git a/commands/automatisation/viewtasks.ts b/commands/automatisation/viewtasks.ts new file mode 100644 index 0000000..d4354ec --- /dev/null +++ b/commands/automatisation/viewtasks.ts @@ -0,0 +1,23 @@ +import { Message, Client } from 'discord.js'; +import db from '../../fonctions/instanceDB'; +require('dotenv').config(); + +module.exports = { + aliases: ['viewtask', 'alltask', 'tasks', 'tasklist', 'listtasks', 'listtask', 'alltasks', 'viewalltasks', 'alltaskslist', 'alltasklist', 'taskslist', 'listalltasks', 'listalltask'], + description: 'Voir toutes les tâches.', + emote: '⏱️', + utilisation: '', + + async execute(message: Message, args: string[], client: Client) { + db.all(`SELECT * FROM task`, (err: any, rows: any) => { + if (err) { + console.error(err.message); + } + let tasks = ''; + rows.forEach((row: any) => { + tasks += `\n- ${row.id} - ${row.name} : ${row.time} minutes`; + }); + message.edit(`# Liste des tâches :${tasks}`); + }); + } +}; \ No newline at end of file