diff --git a/icon/mo_Avocadi_Avatar_Closeup_2.png b/icon/mo_Avocadi_Avatar_Closeup_2.png new file mode 100644 index 0000000..773df00 Binary files /dev/null and b/icon/mo_Avocadi_Avatar_Closeup_2.png differ diff --git a/src/actions/help/help.components.ts b/src/actions/help/help.components.ts new file mode 100644 index 0000000..c2deda5 --- /dev/null +++ b/src/actions/help/help.components.ts @@ -0,0 +1,22 @@ +import { Commands, CommandsMeta } from 'commands'; +import { AttachmentBuilder, EmbedBuilder } from 'discord.js'; + +export default function createEmbed() { // ({ embeds: [exampleEmbed] }) + console.log("createEmbed()"); + + const exampleEmbed = new EmbedBuilder() + .setColor(0x004400) + //.setTitle("/hilfe") + //.setURL("") + .setAuthor({ name: "avocadi - befehle", iconURL: "https://media.discordapp.net/attachments/1321933410188656693/1323447010380222474/mo_Avocadi_Avatar_Closeup_2.png?ex=67748b93&is=67733a13&hm=f48efb3523bca5f50e79144c7b41a127c94670e693e3da3dc2e6ffe62ad8a769&=&format=webp&quality=lossless&width=1524&height=1524", url: 'https://git.unom.io/moriese/avocadi-bot' }) + .setDescription(" ") + .addFields( + { name: "/" + Commands.Enum.giessen, value: CommandsMeta.giessen.description }, + { name: "/" + Commands.Enum.medikamente, value: CommandsMeta.medikamente.description }, + { name: "/" + Commands.Enum.hilfe, value: CommandsMeta.hilfe.description }, + ) + .setTimestamp() + //.setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' }); + ; + return exampleEmbed; +} \ No newline at end of file diff --git a/src/actions/help/help.service.ts b/src/actions/help/help.service.ts new file mode 100644 index 0000000..3a5df4c --- /dev/null +++ b/src/actions/help/help.service.ts @@ -0,0 +1,20 @@ +import type { CacheType, Interaction } from "discord.js"; +import createEmbed from "./help.components"; + +export class HelpService { + exampleEmbed: any; + + constructor() { + this.exampleEmbed = createEmbed(); + } + + async handleInteraction(interaction: Interaction) { + console.log("help"); + + if (interaction.isChatInputCommand()) { + await interaction.reply({ + embeds: [this.exampleEmbed], + }); + } + } +} \ No newline at end of file diff --git a/src/commands/index.ts b/src/commands/index.ts new file mode 100644 index 0000000..913b25e --- /dev/null +++ b/src/commands/index.ts @@ -0,0 +1,34 @@ +import { SlashCommandBuilder } from "discord.js"; +import { z } from "zod"; + +export const Commands = z.enum(["giessen", "medikamente", "hilfe"]); + +export const CommandsMeta: Record, { description: string }> = { + giessen: { + description: "giess mich mit etwas wasser :3" + }, + medikamente: { + description: "ich erinnere dich gerne daran, deine medikamente zu nehmen! :)" + }, + hilfe: { + description: "ich schreibe dir auf, was du alles mit mir machen kannst :)" + } +} + +export type CommandsType = z.output; + +export default function getCommands() { + const commands = [ + new SlashCommandBuilder() + .setName(Commands.Enum.giessen) + .setDescription(CommandsMeta.giessen.description), + new SlashCommandBuilder() + .setName(Commands.Enum.medikamente) + .setDescription(CommandsMeta.medikamente.description), + new SlashCommandBuilder() + .setName(Commands.Enum.hilfe) + .setDescription(CommandsMeta.hilfe.description), + ].map((command) => command.toJSON()); + + return commands; +} diff --git a/src/components/commands.component.ts b/src/components/commands.component.ts deleted file mode 100644 index cc0e802..0000000 --- a/src/components/commands.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { SlashCommandBuilder } from "discord.js"; -import { z } from "zod"; - -export const Commands = z.enum(["giessen", "medikamente"]); -export type CommandsType = z.output; - -export default function getCommands() { - const commands = [ - new SlashCommandBuilder() - .setName(Commands.Enum.giessen) - .setDescription("giess mich mit etwas wasser :3"), - - new SlashCommandBuilder() - .setName(Commands.Enum.medikamente) - .setDescription("ich erinnere dich gerne daran, deine medikamente zu nehmen! :)"), - ].map((command) => command.toJSON()); - - return commands; -} diff --git a/src/components/index.ts b/src/components/index.ts new file mode 100644 index 0000000..e995b64 --- /dev/null +++ b/src/components/index.ts @@ -0,0 +1,24 @@ +import { EmbedBuilder } from "discord.js"; +import { Commands, CommandsMeta } from "commands"; + +export default function getEmbed() { // channel.send({ embeds: [exampleEmbed] }); + const exampleEmbed = new EmbedBuilder() + .setColor(0x0099FF) + .setTitle('Some title') + .setURL('https://discord.js.org/') + .setAuthor({ name: 'Some name', iconURL: 'https://i.imgur.com/AfFp7pu.png', url: 'https://discord.js.org' }) + .setDescription('Some description here') + .setThumbnail('https://i.imgur.com/AfFp7pu.png') + .addFields( + { 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: '\u200B', value: '\u200B' }, + { name: 'Inline field title', value: 'Some value here', inline: true }, + ) + .addFields({ name: 'Inline field title', value: 'Some value here', inline: true }) + .setImage('https://i.imgur.com/AfFp7pu.png') + .setTimestamp() + .setFooter({ text: 'Some footer text here', iconURL: 'https://i.imgur.com/AfFp7pu.png' }); + return exampleEmbed; +} \ No newline at end of file diff --git a/src/controllers/discord.controller.ts b/src/controllers/discord.controller.ts index be04a62..1969c10 100644 --- a/src/controllers/discord.controller.ts +++ b/src/controllers/discord.controller.ts @@ -1,4 +1,4 @@ -import { Commands, type CommandsType } from "components/commands.component"; +import { Commands, type CommandsType } from "commands"; import type { ButtonInteraction, CacheType, @@ -9,20 +9,24 @@ import type { import client from "lib/client"; import EventEmitter from "node:events"; import DiscordService from "services/discord.service"; -import { WaterMeService } from "actions/waterMe/waterMe.service"; import config from "config"; +import { WaterMeService } from "actions/waterMe/waterMe.service"; import { MedicationService } from "actions/medication/medication.service"; +import { HelpService } from "actions/help/help.service"; +import { custom } from "zod"; export default class DiscordController extends EventEmitter { private discordService!: DiscordService; waterMeService: WaterMeService; medicationService: MedicationService; + helpService: HelpService; constructor() { super(); this.discordService = new DiscordService(); this.waterMeService = new WaterMeService(); this.medicationService = new MedicationService(); + this.helpService = new HelpService(); // log when running client.once("ready", async () => { client.user?.setActivity("HALLOOO HOERT IHR MICH?", { type: 4 }); @@ -36,7 +40,7 @@ export default class DiscordController extends EventEmitter { if (channel?.isTextBased && channel?.isSendable()) { await channel.send({ - content: "bin gerade erst aufgewacht :o", + content: "bin wieder da :o war kurz weg :3", }); }*/ }); @@ -69,7 +73,7 @@ export default class DiscordController extends EventEmitter { const { customId } = interaction; console.log(interaction.customId); - if (customId === "moreWater") { + if (customId.toLowerCase().includes("moreWater")) { await this.waterMeService.handleInteraction(interaction); } if (customId.toLowerCase().includes("medication")) { @@ -90,6 +94,9 @@ export default class DiscordController extends EventEmitter { case Commands.Enum.medikamente: await this.medicationService.handleInteraction(interaction); return; + case Commands.Enum.hilfe: + await this.helpService.handleInteraction(interaction); + return; default: break; } diff --git a/src/services/discord.service.ts b/src/services/discord.service.ts index bff3fe7..fa94f6f 100644 --- a/src/services/discord.service.ts +++ b/src/services/discord.service.ts @@ -1,7 +1,7 @@ import { Routes } from "discord.js"; import { REST } from "@discordjs/rest"; import config from "config"; -import getCommands from "components/commands.component"; +import getCommands from "commands"; export default class DiscordService { rest: REST;