Add basic receipt logging

This commit is contained in:
2026-01-19 13:53:42 +01:00
parent e5933aacc2
commit 745e709bef
5 changed files with 169 additions and 45 deletions

View File

@@ -1,52 +0,0 @@
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
category: 'utility',
global: true,
data: new SlashCommandBuilder()
.setName('budget')
.setDescription('The thing')
.addSubcommand(subcommand =>
subcommand
.setName('set')
.setDescription('Set weekly budget')
.addIntegerOption(option =>
option.setName('amount')
.setRequired(true)
.setDescription('Amount as int'))
)
.addSubcommand(subcommand =>
subcommand
.setName('show')
.setDescription('not implemented')
),
async execute(interaction) {
console.log('budget command entrypoint');
let db = await interaction.client.localDB;
let discordId = interaction.member.id;
console.log(db, discordId);
let allowed = ['372115788498468864', '222457277708369928'].includes(discordId);
console.log(allowed);
if (!allowed) {
console.log('budget command denied');
await interaction.reply('This command may only be invoked by Miffy!');
return;
}
console.log(`Switcching on sub ${interaction.options.getSubcommand()}`);
switch (interaction.options.getSubcommand()) {
case 'set':
console.log('budget command set');
let budget = interaction.options.get('amount').value
db.prepare(`INSERT OR REPLACE INTO bot_config (id, weekly_budget) VALUES (1, ?)`).run(budget);
await interaction.reply(`Budget set to ${budget}`);
break;
case 'show':
console.log('budget command show');
await interaction.reply('Not implemented');
break
default:
await interaction.reply(`Sub mismatch. Switching on ${interaction.options.getSubcommand()}`);
break;
}
},
};