Skip to content

Commit

Permalink
i forgot the presence statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleylamont committed Feb 15, 2024
1 parent 8d06738 commit 71da1e5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/door-status.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import express, { type Express } from "express";
import { ClientPresenceStatus } from "discord.js";

const TEN_MINUTES = 1000 * 60 * 10;

// Helper functions to set the presence text and status channel name
const setPresenceText = (text: string) =>
const setPresenceText = (text: string, status: ClientPresenceStatus) =>
discordClient.user.setPresence({
activities: [
{
name: text,
type: 3,
},
],
status: "idle",
status,
});

export async function attachDoorServer(app: Express) {
Expand All @@ -29,7 +30,7 @@ export async function attachDoorServer(app: Express) {
throw new Error("Status channel is not a voice channel");
const setStatusChannelName = (name: string) => statusChannel.setName(name);

setPresenceText("the door sensor boot");
setPresenceText("the door sensor boot", "idle");
await setStatusChannelName("CR is loading...");

// Assume the door is closed until we hear otherwise
Expand All @@ -41,7 +42,7 @@ export async function attachDoorServer(app: Express) {
}, TEN_MINUTES);

const timeout = () => {
setPresenceText("sensor dead poke #general");
setPresenceText("sensor dead poke #general", "idle");
setStatusChannelName("CR is missing :|");
timer = undefined;
};
Expand All @@ -65,11 +66,11 @@ export async function attachDoorServer(app: Express) {
// Update the status and the presence text
if (request.body.state === "1") {
status = true;
setPresenceText("room is Open ✨");
setPresenceText("room is Open ✨", "online");
setStatusChannelName("CR is open!");
} else {
status = false;
setPresenceText("room is Closed");
setPresenceText("room is Closed", "dnd");
setStatusChannelName("CR is closed");
}

Expand Down

0 comments on commit 71da1e5

Please sign in to comment.