begin rewriting first services to be domain agnostic

more rewrites
This commit is contained in:
2026-02-17 22:42:36 +01:00
parent b3766b9584
commit 071fe2f891
45 changed files with 915 additions and 521 deletions

View File

@@ -0,0 +1,84 @@
import type z from "zod";
import type { Commands } from "./commands.schema";
// TODO: add missing options
export const CommandsCollection: z.output<typeof Commands> = {
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 :)",
},
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",
options: [
{
name: "input",
description: "input for bot",
required: true,
type: "string",
},
],
},
welcome: {
description: "admin use only",
options: [
{
name: "input",
description: "input for bot",
required: true,
type: "string",
},
],
},
embed: {
description: "admin use only",
options: [
{
name: "title",
description: "title",
required: true,
type: "string",
},
{
name: "description",
description: "description",
required: true,
type: "string",
},
{
name: "timestamp",
description: "timestamp bool",
required: false,
type: "boolean",
},
],
},
message: {
description: "admin use only",
},
reminder: {
description: "admin use only",
},
version: {
description: "admin use only",
},
};

View File

@@ -0,0 +1,59 @@
import z from "zod";
export const CommandKeyOptions = [
"giessen",
"medikamente",
"hilfe",
"support",
"kofi",
"disboard",
"discadia",
"accept",
"welcome",
"embed",
"message",
"reminder",
"version",
] as const;
export const CommandOptionTypeOptions = [
"string",
"integer",
"boolean",
"mentionable",
"channel",
"role",
"user",
] as const;
export const CommandOptionTypes = z.enum(CommandOptionTypeOptions);
export const CommandOptionCommon = z.object({
name: z.string(),
description: z.string(),
required: z.boolean(),
});
export const CommandOptionString = CommandOptionCommon.extend({
type: z.literal(CommandOptionTypes.enum.string),
});
export const CommandOptionBoolean = CommandOptionCommon.extend({
type: z.literal(CommandOptionTypes.enum.boolean),
});
// TODO: add other option types
export const CommandOption = z.discriminatedUnion("type", [
CommandOptionString,
CommandOptionBoolean,
]);
export const CommandKeys = z.enum(CommandKeyOptions);
export const Command = z.object({
name: z.string().optional(),
description: z.string(),
options: z.array(CommandOption).optional(),
});
export const Commands = z.record(CommandKeys, Command);

View File

@@ -0,0 +1,5 @@
import z from "zod";
export const InteractionOptions = ["command", "button"] as const;
export const Interactions = z.enum(InteractionOptions);

View File

@@ -0,0 +1,3 @@
export interface MessagesServiceInterface<U = unknown> {
sendToUser(user: U, message: string): Promise<void>;
}

View File

@@ -0,0 +1,6 @@
export interface RolesServiceInterface<U = unknown> {
assignRole(user: U, role: string): void | Promise<void>;
removeRole(user: U, role: string): void | Promise<void>;
getRoles(user: U): string[] | Promise<string[]>;
hasRole(user: U, role: string): boolean | Promise<boolean>;
}