Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands/admin/qotd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 14 additions & 1 deletion src/database/qotd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading