Refactor to more consistent structure (e.g. "plugins")

This commit is contained in:
2025-07-06 15:23:03 -04:00
parent a6255de889
commit 6fb38d36f3
22 changed files with 567 additions and 600 deletions

44
plugins/nag/checkin.ts Normal file
View File

@@ -0,0 +1,44 @@
import {
type ChatInputCommandInteraction,
SlashCommandBuilder,
} from 'discord.js';
import type {Settings} from '../../plugin';
import {CheckIn, Nag} from './models';
export default function (_settings: Settings) {
return {
data: new SlashCommandBuilder()
.setName('checkin')
.setDescription('Check-in for your daily nag')
.addStringOption(option =>
option
.setName('text')
.setDescription('Optional description of what you have achieved'),
),
execute: async (interaction: ChatInputCommandInteraction) => {
// TODO For now there is only one nag, but in the future this could be different.
// So let's construct it as a loop for now.
const result = await Nag.findAll({
where: {
userId: interaction.user.id,
},
});
if (!result) {
await interaction.reply(
"Couldn't find any nags for you, what are you checking in for?",
);
return;
}
for (const nag of result) {
await CheckIn.create({
nagId: nag.id,
lastCheckIn: new Date(Date.now()),
});
await interaction.reply('Thanks for checking in!');
break;
}
},
};
}