From 38cbb0b961fef9207664bcd1e9f3941b0a6d8ff7 Mon Sep 17 00:00:00 2001 From: walcutt Date: Tue, 27 Feb 2024 23:05:08 -0500 Subject: [PATCH] Added message on boot --- .gitignore | 3 ++- asher/src/constants.js | 3 +++ .../startup-send-message/startupSendMessage.js | 11 +++++++++++ asher/src/routines/routineManifest.js | 2 ++ asher/src/secrets.js | 4 +++- docker-compose.yml | 5 ++++- 6 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 asher/src/constants.js create mode 100644 asher/src/routines/client-ready/startup-send-message/startupSendMessage.js diff --git a/.gitignore b/.gitignore index 160a805..83826e4 100644 --- a/.gitignore +++ b/.gitignore @@ -130,4 +130,5 @@ dist .pnp.* # secrets -botkey.txt \ No newline at end of file +botkey.txt +defaultchannel.txt \ No newline at end of file diff --git a/asher/src/constants.js b/asher/src/constants.js new file mode 100644 index 0000000..9cbb83b --- /dev/null +++ b/asher/src/constants.js @@ -0,0 +1,3 @@ +export const textStrings = { + BOOT_MESSAGE: "Hi! Chloe just started me up! I'm not quite ready yet though!", +}; \ No newline at end of file diff --git a/asher/src/routines/client-ready/startup-send-message/startupSendMessage.js b/asher/src/routines/client-ready/startup-send-message/startupSendMessage.js new file mode 100644 index 0000000..e97eaa0 --- /dev/null +++ b/asher/src/routines/client-ready/startup-send-message/startupSendMessage.js @@ -0,0 +1,11 @@ +import { secretKeys, getSecret } from "../../../secrets.js"; +import { textStrings } from "../../../constants.js"; + +export function startupSendMessage(readyClient) { + const channelId = getSecret(secretKeys.DEFAULT_CHANNEL); + console.log(channelId); + + const channel = readyClient.channels.resolve(channelId); + + channel.send(textStrings.BOOT_MESSAGE); +} \ No newline at end of file diff --git a/asher/src/routines/routineManifest.js b/asher/src/routines/routineManifest.js index 010cb7f..153bbc7 100644 --- a/asher/src/routines/routineManifest.js +++ b/asher/src/routines/routineManifest.js @@ -1,6 +1,7 @@ import { Events } from "discord.js"; // Import routines. import { startupHeartbeat } from "./client-ready/startup-heartbeat/startupHeartbeat.js"; +import { startupSendMessage } from "./client-ready/startup-send-message/startupSendMessage.js"; /* * All bot actions are "routines" that fire off of some trigger. @@ -17,6 +18,7 @@ export const routineManifest = [ event: Events.ClientReady, routines: [ startupHeartbeat, + startupSendMessage, ], }, ]; \ No newline at end of file diff --git a/asher/src/secrets.js b/asher/src/secrets.js index 7349932..0fd6262 100644 --- a/asher/src/secrets.js +++ b/asher/src/secrets.js @@ -1,11 +1,13 @@ import fs from 'fs'; export const secretKeys = { - BOT_KEY: 'botkey' + BOT_KEY: 'botkey', + DEFAULT_CHANNEL: 'default-channel', }; const secretManifest = [ secretKeys.BOT_KEY, + secretKeys.DEFAULT_CHANNEL, ]; let secrets = {}; diff --git a/docker-compose.yml b/docker-compose.yml index 08b05b7..07741f4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,8 +10,11 @@ services: command: bash -c "cd /asher && npm i && npm run serve" secrets: - botkey + - default-channel secrets: botkey: - file: ./botkey.txt \ No newline at end of file + file: ./botkey.txt + default-channel: + file: ./defaultchannel.txt \ No newline at end of file