import { CronJob } from "cron"; import { getRandomInt } from "lib/utils"; import config from "config"; import client from "lib/client"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, type CacheType, type Interaction, } from "discord.js"; import { yesButton, noButton } from "./medication.components"; export class MedicationService { medication: string; tookMedication: boolean; constructor() { this.medication = ""; this.tookMedication = false; } async askMedication() { const channels = client.channels; const channel = channels.cache.get(config.discord.channelId); // funkt noch nicht, beides const row = new ActionRowBuilder().addComponents(yesButton); row.addComponents(noButton); if (channel?.isTextBased && channel?.isSendable() && this.tookMedication == false) { await channel.send({ content: "hast du schon deine medis genommen? :)", components: [row as any] }); } } getMedication() { throw new Error("Method not implemented."); } setMedication() { const reply = this.getReply(); console.log("medication"); // this.medication = input von user:in hier rein; return { reply, } } getReply() { return "medication reminder"; } async handleInteraction(interaction: Interaction) { const result = this.setMedication(); const yesButton = new ButtonBuilder() .setCustomId("yesMedication") .setLabel("ja") .setStyle(ButtonStyle.Primary); const noButton = new ButtonBuilder() .setCustomId("noMedication") .setLabel("noch nicht") .setStyle(ButtonStyle.Secondary); const row = new ActionRowBuilder().addComponents(yesButton); row.addComponents(noButton); if (interaction.isChatInputCommand()) { await interaction.reply({ content: result.reply, // biome-ignore lint/suspicious/noExplicitAny: components: [row as any], }); } else if (interaction.isButton()) { console.log("button interaction"); if (interaction.customId == "yesMedication") { interaction.reply({ content: "das hast du toll gemacht <3 mach weiter so :3", }); } else if (interaction.customId == "noMedication") { interaction.reply({ content: "das passiert mal... aber versuch sie heute noch zu nehmen, oki? :)", }); } } } }