diff --git a/src/commands/admin/qotd.js b/src/commands/admin/qotd.js index 0da5427..326189f 100644 --- a/src/commands/admin/qotd.js +++ b/src/commands/admin/qotd.js @@ -42,7 +42,7 @@ module.exports = new Command({ .setColor(0xA47DAB) .setDescription( queue.map((q, i) => - `#${i + 1} (ID ${q.id}) - ${q.question}`) + `#${i + 1} - ${q.question}`) .join('\n') || 'Queue is empty.'); message.channel.send({ embeds: [queueEmbed] }); break; diff --git a/src/database/qotd.js b/src/database/qotd.js index 745a65b..78f433e 100644 --- a/src/database/qotd.js +++ b/src/database/qotd.js @@ -54,7 +54,20 @@ module.exports = { getPast: () => all( 'SELECT * FROM past_questions ORDER BY posted_at DESC LIMIT 10'), - removeQuestion: (id) => run('DELETE FROM queue WHERE id = ?', [id]), + removeQuestion: async (position) => { + const index = parseInt(position) - 1; + if (isNaN(index) || index < 0) throw new Error('Invalid position'); + + const target = await get( + 'SELECT id FROM queue ORDER BY priority DESC, id ASC LIMIT 1 OFFSET ?', + [index] + ); + + if (target) { + return run('DELETE FROM queue WHERE id = ?', [target.id]); + } + return null; + }, popNext: async () => { const next = await get(