add more listeners

add activity service
add log channel service
This commit is contained in:
2026-02-17 23:07:17 +01:00
parent 071fe2f891
commit aa88d30244
14 changed files with 159 additions and 37 deletions

View File

@@ -12,25 +12,6 @@ export default class DiscordController extends EventEmitter {
super();
let channelListeners = new Map();
// log when running
client.once("ready", async () => {
const channels = client.channels;
const logChannel = channels.cache.get(config.discord.channelIdLog);
if (logChannel?.isTextBased() && logChannel?.isSendable()) {
try {
console.log("bot is online");
await logChannel.send("wieder online!!!");
} catch (error) {
console.error("failed to send online message:", error);
}
} else {
console.error("log channel is not valid or sendable.");
}
await this.setActivity(100);
console.log("ready");
});
process.on("exit", async () => {
const channels = client.channels;
const logChannel = channels.cache.get(config.discord.channelIdLog);
@@ -144,24 +125,6 @@ export default class DiscordController extends EventEmitter {
}
}
async handleShutdown(logChannel: Channel | undefined) {
if (logChannel?.isTextBased() && logChannel?.isSendable()) {
try {
await logChannel.send("bot is going offline...");
} catch (error) {
console.error("failed to send offline message:", error);
}
} else {
console.error("log channel is not valid or sendable.");
}
await this.setActivity(0);
console.log("bot is offline.");
}
async init() {
await this.discordService.init();
}
async handleInteraction(interaction: Interaction<CacheType>) {
if (interaction.isModalSubmit()) {
await this.handleModalSubmit(interaction);