-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselectHandlers.js
More file actions
36 lines (30 loc) · 1.39 KB
/
Copy pathselectHandlers.js
File metadata and controls
36 lines (30 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const taskManager = require('./taskManager');
const { updateListMessage } = require('./commands');
const handlers = {
taskSelect: async (interaction, [action]) => {
// Value format: "action:taskId"
const value = interaction.values[0];
const [act, taskId] = value.split(':');
const guildId = interaction.guild.id;
if (act === 'complete') {
const task = taskManager.getTask(guildId, taskId);
if (!task) return interaction.reply({ content: '❌ Task not found.', ephemeral: true });
taskManager.updateTask(guildId, taskId, { done: true, completedAt: new Date().toISOString() });
await updateListMessage(interaction.guild);
await interaction.update({ content: `✅ **"${task.title}"** marked as complete!`, components: [], embeds: [] });
}
if (act === 'delete') {
const task = taskManager.getTask(guildId, taskId);
if (!task) return interaction.reply({ content: '❌ Task not found.', ephemeral: true });
taskManager.deleteTask(guildId, taskId);
await updateListMessage(interaction.guild);
await interaction.update({ content: `🗑️ **"${task.title}"** deleted.`, components: [], embeds: [] });
}
if (act === 'edit') {
// Trigger the edit modal
const buttonHandlers = require('./buttonHandlers');
await buttonHandlers.editTask(interaction, ['detail', taskId]);
}
}
};
module.exports = handlers;