diff --git a/src/actions/help/help.components.ts b/src/actions/help/help.components.ts index 2d59daf..ed2fdc3 100644 --- a/src/actions/help/help.components.ts +++ b/src/actions/help/help.components.ts @@ -14,6 +14,10 @@ export default function createEmbed() { // ({ embeds: [exampleEmbed] }) { name: `/${Commands.Enum.giessen}`, value: CommandsMeta.giessen.description }, { name: `/${Commands.Enum.medikamente}`, value: CommandsMeta.medikamente.description }, { name: `/${Commands.Enum.hilfe}`, value: CommandsMeta.hilfe.description }, + { name: `/${Commands.Enum.support}`, value: CommandsMeta.support.description }, + { name: `/${Commands.Enum.kofi}`, value: CommandsMeta.kofi.description }, + { name: `/${Commands.Enum.disboard}`, value: CommandsMeta.disboard.description }, + { name: `/${Commands.Enum.discadia}`, value: CommandsMeta.discadia.description }, ) .setTimestamp() //.setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' }); diff --git a/src/actions/help/help.service.ts b/src/actions/help/help.service.ts index de25656..4595608 100644 --- a/src/actions/help/help.service.ts +++ b/src/actions/help/help.service.ts @@ -15,6 +15,7 @@ export class HelpService { if (interaction.isChatInputCommand()) { await interaction.reply({ embeds: [this.exampleEmbed], + ephemeral: true, }); } } diff --git a/src/actions/support/support.components.ts b/src/actions/support/support.components.ts new file mode 100644 index 0000000..db30f1d --- /dev/null +++ b/src/actions/support/support.components.ts @@ -0,0 +1,18 @@ +import { createEmbed } from "actions/customMessage/customMessage.components"; + +const kofiTitle = "ko-fi"; +const kofiLink = "[ko-fi.com/avocadi](https://ko-fi.com/avocadi)"; +const kofiDesc = "gerne kannst du uns eine kleine spende ueber ko-fi zukommen lassen!"; + +const disboardTitle = "disboard"; +const disboardLink = "[disboard.org/de/server/1316153371899592774](https://disboard.org/de/server/1316153371899592774)"; +const disboardDesc = "hier kannst du eine bewertung schreiben <3"; + +const discadiaTitle = "discadia"; +const discadiaLink = "[discadia.com/server/avocadi](https://discadia.com/server/avocadi/)"; +const discadiaDesc = "du moechtest fuer uns voten? dann klicke auf den link :)"; + +export const supportContent = createEmbed("support", (`${kofiTitle}: ${kofiLink}\n${disboardTitle}: ${disboardLink}\n${discadiaTitle}: ${discadiaLink}`)); +export const kofiContent = createEmbed(kofiTitle, (`${kofiDesc}\n${kofiLink}`)); +export const disboardContent = createEmbed(disboardTitle, (`${disboardDesc}\n${disboardLink}`)); +export const discadiaContent = createEmbed(discadiaTitle, (`${discadiaDesc}\n${discadiaLink}`)); \ No newline at end of file diff --git a/src/actions/support/support.service.ts b/src/actions/support/support.service.ts new file mode 100644 index 0000000..20746d1 --- /dev/null +++ b/src/actions/support/support.service.ts @@ -0,0 +1,93 @@ +import config from "config"; +import client from "lib/client"; +import { getRandomInt } from "lib/utils"; +import { + kofiContent, + supportContent, + discadiaContent, + disboardContent, +} from "./support.components.ts"; +import type { + CacheType, + Interaction, + ChatInputCommandInteraction, +} from "discord.js"; +import { Commands, type CommandsType } from "commands/index.ts"; + +export class SupportService { + async handleInteraction(interaction: Interaction) { + if (interaction.isChatInputCommand()) { + await this.handleChatInputCommand(interaction); + return; + } + } + + async handleChatInputCommand( + interaction: ChatInputCommandInteraction, + ) { + const commandName = interaction.commandName as CommandsType; + switch (commandName) { + case Commands.Enum.support: + await this.supportCommand(interaction); + return; + case Commands.Enum.kofi: + await this.kofiCommand(interaction); + return; + case Commands.Enum.disboard: + await this.disboardCommand(interaction); + return; + case Commands.Enum.discadia: + await this.discadiaCommand(interaction); + return; + default: + break; + } + } + async supportCommand(interaction: ChatInputCommandInteraction) { + console.log("supportCommand"); + try { + await interaction.reply({ + embeds: [supportContent], + ephemeral: true, + }); + } catch (error) { + console.error("error while sending supportCommand msg:", error); + } + } + + async kofiCommand(interaction: ChatInputCommandInteraction) { + console.log("kofiCommand"); + try { + await interaction.reply({ + embeds: [kofiContent], + ephemeral: true, + }); + } catch (error) { + console.error("error while sending kofiCommand msg:", error); + } + } + + async disboardCommand(interaction: ChatInputCommandInteraction) { + console.log("disboardCommand"); + try { + await interaction.reply({ + embeds: [disboardContent], + ephemeral: true, + }); + } catch (error) { + console.error("error while sending disboardCommand msg:", error); + } + } + + async discadiaCommand(interaction: ChatInputCommandInteraction) { + console.log("discadiaCommand"); + try { + await interaction.reply({ + embeds: [discadiaContent], + ephemeral: true, + }); + } catch (error) { + console.error("error while sending discadiaCommand msg:", error); + } + } +} diff --git a/src/commands/index.ts b/src/commands/index.ts index d5f5662..7e11630 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -1,7 +1,7 @@ import { SlashCommandBuilder, userMention } from "discord.js"; import { z } from "zod"; -export const Commands = z.enum(["giessen", "medikamente", "hilfe", "accept", "welcome", "embed", "message", "reminder"]); +export const Commands = z.enum(["giessen", "medikamente", "hilfe", "support", "kofi", "disboard", "discadia", "accept", "welcome", "embed", "message", "reminder"]); export const CommandsMeta: Record, { description: string }> = { giessen: { @@ -13,6 +13,18 @@ export const CommandsMeta: Record, { description: stri hilfe: { description: "ich schreibe dir auf, was du alles mit mir machen kannst :)" }, + support: { + description: "unterstuetze uns! link zu unserem ko-fi, disboard und discardia c:" + }, + kofi: { + description: "link zu unserem ko-fi (spendenportal):" + }, + disboard: { + description: "link zu disboard, hier kannst du uns bewerten!" + }, + discadia: { + description: "link zu discadia, hier kannst du fuer uns voten!" + }, accept: { description: "admin use only" }, @@ -43,6 +55,18 @@ export default function getCommands() { new SlashCommandBuilder() .setName(Commands.Enum.hilfe) .setDescription(CommandsMeta.hilfe.description), + new SlashCommandBuilder() + .setName(Commands.Enum.support) + .setDescription(CommandsMeta.support.description), + new SlashCommandBuilder() + .setName(Commands.Enum.kofi) + .setDescription(CommandsMeta.kofi.description), + new SlashCommandBuilder() + .setName(Commands.Enum.disboard) + .setDescription(CommandsMeta.disboard.description), + new SlashCommandBuilder() + .setName(Commands.Enum.discadia) + .setDescription(CommandsMeta.discadia.description), new SlashCommandBuilder() .setName(Commands.Enum.accept) .setDescription(CommandsMeta.accept.description) diff --git a/src/controllers/discord.controller.ts b/src/controllers/discord.controller.ts index d0e1e97..8fb251d 100644 --- a/src/controllers/discord.controller.ts +++ b/src/controllers/discord.controller.ts @@ -17,6 +17,7 @@ import DiscordService from "services/discord.service"; import { WaterMeService } from "actions/waterMe/waterMe.service"; import { MedicationService } from "actions/medication/medication.service"; import { HelpService } from "actions/help/help.service"; +import { SupportService } from "actions/support/support.service"; import { GreetingService } from "actions/greeting/greeting.service"; import { ActivityService } from "actions/activity/activity.service"; import { DmService } from "actions/dm/dm.service"; @@ -31,6 +32,7 @@ export default class DiscordController extends EventEmitter { greetingService: GreetingService; medicationService: MedicationService; helpService: HelpService; + supportService: SupportService; activityService: ActivityService; dmService: DmService; customMessageService: CustomMessageService; @@ -46,6 +48,7 @@ export default class DiscordController extends EventEmitter { this.greetingService = new GreetingService(); this.medicationService = new MedicationService(); this.helpService = new HelpService(); + this.supportService = new SupportService(); this.activityService = new ActivityService(); this.dmService = new DmService(); this.customMessageService = new CustomMessageService(); @@ -203,28 +206,32 @@ export default class DiscordController extends EventEmitter { // add commands switch (commandName) { case Commands.Enum.giessen: - await this.waterMeService.handleInteraction(interaction); + await this.waterMeService.handleInteraction(interaction); // zu chatinputcommand wechseln return; case Commands.Enum.medikamente: - await this.medicationService.handleInteraction(interaction); + await this.medicationService.handleChatInputCommand(interaction); return; case Commands.Enum.hilfe: - await this.helpService.handleInteraction(interaction); + await this.helpService.handleInteraction(interaction); // zu chatinputcommand wechseln + return; + case Commands.Enum.support: + case Commands.Enum.kofi: + case Commands.Enum.disboard: + case Commands.Enum.discadia: + await this.supportService.handleInteraction(interaction); return; case Commands.Enum.accept: - await this.greetingService.handleInteraction(interaction); + await this.greetingService.handleChatInputCommand(interaction); return; case Commands.Enum.welcome: - await this.greetingService.handleInteraction(interaction); + await this.greetingService.handleChatInputCommand(interaction); return; case Commands.Enum.embed: - await this.customMessageService.handleInteraction(interaction); - return; case Commands.Enum.message: - await this.customMessageService.handleInteraction(interaction); + await this.customMessageService.handleChatInputCommand(interaction); return; case Commands.Enum.reminder: - await this.greetingService.handleInteraction(interaction); + await this.greetingService.handleChatInputCommand(interaction); return; default: break;