good progress :3

This commit is contained in:
2025-01-05 03:51:02 +01:00
parent 07aa025ba0
commit 94d2fc40e6
12 changed files with 243 additions and 54 deletions

View File

@@ -1,6 +1,8 @@
import { Commands, type CommandsType } from "commands";
import {
ChannelType,
Client,
Events,
IntentsBitField,
type ButtonInteraction,
type CacheType,
@@ -18,6 +20,7 @@ import { HelpService } from "actions/help/help.service";
import { custom } from "zod";
import { GreetingService } from "actions/greeting/greeting.service";
import { ActivityService } from "actions/activity/activity.service";
import { DmService } from "actions/dm/dm.service";
export default class DiscordController extends EventEmitter {
private discordService!: DiscordService;
@@ -26,6 +29,7 @@ export default class DiscordController extends EventEmitter {
medicationService: MedicationService;
helpService: HelpService;
activityService: ActivityService;
dmService: DmService;
constructor() {
super();
@@ -35,17 +39,29 @@ export default class DiscordController extends EventEmitter {
this.medicationService = new MedicationService();
this.helpService = new HelpService();
this.activityService = new ActivityService();
this.dmService = new DmService();
// log when running
client.once("ready", async () => {
this.setActivity();
this.greetingService.customMessage();
await this.setActivity();
console.log("ready");
});
// listen for interactions
client.on("interactionCreate", this.handleInteraction.bind(this));
client.on("messageCreate", async (message) => {
console.log(message.id)
if (message.channel.type === ChannelType.DM
&& message.author.id !== config.discord.botId
) {
console.log("got msg");
this.dmService.forward(message);
}
});
client.on("guildMemberAdd", async (member) => {
console.log("client on guildMemberAdd");
await this.greetingService.welcome(member);
await this.dmService.welcomePrivate(member);
});
}
@@ -105,6 +121,9 @@ export default class DiscordController extends EventEmitter {
case Commands.Enum.hilfe:
await this.helpService.handleInteraction(interaction);
return;
case Commands.Enum.accept:
await this.greetingService.handleInteraction(interaction);
return;
default:
break;
}