From 50abfbd3cf633768ed016664b020aa5cbc360e0f Mon Sep 17 00:00:00 2001 From: GhomKrosmonaute Date: Tue, 3 Oct 2023 08:48:22 +0200 Subject: [PATCH] fixed restart messages --- src/listeners/ready.restart.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/listeners/ready.restart.ts b/src/listeners/ready.restart.ts index d6354a8d..e1b4401c 100644 --- a/src/listeners/ready.restart.ts +++ b/src/listeners/ready.restart.ts @@ -12,11 +12,13 @@ const listener: app.Listener<"ready"> = { event: "ready", description: "Send restart messages", once: true, - async run() { + async run(client) { const restartMessages = await restart.query.select() + app.log("Restart messages: "+ restartMessages.length) + for (const restartMessage of restartMessages) { - const channel = this.channels.cache.get(restartMessage.last_channel_id) + const channel = client.channels.cache.get(restartMessage.last_channel_id) if (channel?.isText()) { const content = `${restartMessage.content} (${time @@ -42,6 +44,11 @@ const listener: app.Listener<"ready"> = { app.error(error, __filename) } } + } else { + app.error( + `channel ${restartMessage.last_channel_id} is not a text channel`, + __filename + ) } }