begin rewriting first services to be domain agnostic
more rewrites
This commit is contained in:
84
core/src/entities/commands/commands.entity.ts
Normal file
84
core/src/entities/commands/commands.entity.ts
Normal 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",
|
||||
},
|
||||
};
|
||||
59
core/src/entities/commands/commands.schema.ts
Normal file
59
core/src/entities/commands/commands.schema.ts
Normal 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);
|
||||
5
core/src/entities/interactions/interactions.schema.ts
Normal file
5
core/src/entities/interactions/interactions.schema.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import z from "zod";
|
||||
|
||||
export const InteractionOptions = ["command", "button"] as const;
|
||||
|
||||
export const Interactions = z.enum(InteractionOptions);
|
||||
3
core/src/entities/messages/messages.service.ts
Normal file
3
core/src/entities/messages/messages.service.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface MessagesServiceInterface<U = unknown> {
|
||||
sendToUser(user: U, message: string): Promise<void>;
|
||||
}
|
||||
6
core/src/entities/roles/roles.service.ts
Normal file
6
core/src/entities/roles/roles.service.ts
Normal 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>;
|
||||
}
|
||||
Reference in New Issue
Block a user