Skip to content

Commit d27cbd4

Browse files
committed
Switch to AWS Secrets
1 parent 8d70df6 commit d27cbd4

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/plugins/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const smClient = new SecretsManagerClient({
5555
region: genericConfig.AwsRegion,
5656
});
5757

58-
const getSecretValue = async (
58+
export const getSecretValue = async (
5959
secretId: string,
6060
): Promise<Record<string, string | number | boolean> | null> => {
6161
const data = await smClient.send(

src/routes/discord.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from "discord.js";
1111
import { type EventPostRequest } from "./events.js";
1212
import moment from "moment";
13+
import { getSecretValue } from "../plugins/auth.js";
1314

1415
// https://stackoverflow.com/a/3809435/5684541
1516
// https://calendar-buff.acmuiuc.pages.dev/calendar?id=dd7af73a-3df6-4e12-b228-0d2dac34fda7&date=2024-08-30
@@ -30,7 +31,8 @@ export const updateDiscord = async (
3031
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
3132
client.once(Events.ClientReady, async (readyClient: Client<true>) => {
3233
console.log(`Logged in as ${readyClient.user.tag}`);
33-
const guild = await client.guilds.fetch(process.env.DISCORD_GUILD_ID || "");
34+
const guildID = await getSecretValue("discord_guild_id");
35+
const guild = await client.guilds.fetch(guildID?.toString() || "");
3436
const discordEvents = await guild.scheduledEvents.fetch();
3537
const snowflakeMeetingLookup = discordEvents.reduce(
3638
(o, event) => {
@@ -100,6 +102,6 @@ export const updateDiscord = async (
100102
await client.destroy();
101103
});
102104

103-
console.log("TOKEN", process.env.DISCORD_BOT_TOKEN);
104-
client.login(process.env.DISCORD_BOT_TOKEN);
105+
const token = await getSecretValue("discord_bot_token");
106+
client.login(token?.toString());
105107
};

0 commit comments

Comments
 (0)