Skip to content

Commit 6d0a5b1

Browse files
authored
Merge pull request #26 from GSM-MSG/15-schedule-command-and-job-register
🔀 :: Schedule 도메인 관련 Command와 Job 봇에 등록
2 parents 09d6269 + 00c76b0 commit 6d0a5b1

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/MSGSaltBot.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import { Command } from "./interfaces/Command";
1111
import { saltRepository } from "./repositories/SaltRepository";
1212
import { config } from "./utils/config";
1313
import { JobService } from "./services/JobService";
14+
import AddScheduleCommand from "./commands/AddScheduleCommand";
15+
import SyncScheduleCommand from "./commands/SyncScheduleCommand";
16+
import FetchScheduleListCommand from "./commands/FetchScheduleListCommand";
17+
import DeleteScheduleCommand from "./commands/DeleteScheduleCommand";
1418

1519
export class MSGSaltBot {
1620
private slashCommandMap = new Map<string, Command>();
@@ -45,7 +49,11 @@ export class MSGSaltBot {
4549
DMCommand,
4650
SearchMSGMemberCommand,
4751
CurrentSaltCommand,
48-
FilterMensionCommand
52+
FilterMensionCommand,
53+
AddScheduleCommand,
54+
SyncScheduleCommand,
55+
FetchScheduleListCommand,
56+
DeleteScheduleCommand
4957
];
5058

5159
this.slashCommandMap = slashCommands.reduce((map, command) => {
@@ -75,9 +83,15 @@ export class MSGSaltBot {
7583
} catch (error: any) {
7684
console.error(error);
7785

78-
await interaction.reply({
79-
content: error.toString()
80-
});
86+
if (interaction.replied) {
87+
await interaction.followUp({
88+
content: error.toString()
89+
});
90+
} else {
91+
await interaction.reply({
92+
content: error.toString()
93+
});
94+
}
8195
}
8296
});
8397
}

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ import express, { Express } from "express";
33
import { client } from "./discordClient";
44
import { JobService } from "./services/JobService";
55
import { Job } from "./interfaces/Job";
6+
import { ReminderSchedulerJob } from "./jobs/ReminderSchedulerJob";
7+
import { scheduleRepository } from "./repositories/ScheduleRepository";
8+
import { SchedulerJob } from "./jobs/SchedulerJob";
69

10+
scheduleRepository.syncRemote()
711

812
const jobs: Job[] = [
13+
new ReminderSchedulerJob(client),
14+
new SchedulerJob(client)
915
];
1016

1117
const jobService = new JobService(jobs);

0 commit comments

Comments
 (0)