Skip to content

Commit

Permalink
feat: unfunny DISABLE_FUNNY_WORKER_NAMES environment variable imple…
Browse files Browse the repository at this point in the history
…mented

Signed-off-by: Promise <[email protected]>
  • Loading branch information
promise committed Dec 19, 2024
1 parent 291cc1b commit 33c1e6f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
bot:
build: .
Expand All @@ -11,6 +9,7 @@ services:
- OWNER_ID=$OWNER_ID
- THEME_COLOR=$THEME_COLOR
- AREA_LIMIT_PER_USER=$AREA_LIMIT_PER_USER
- DISABLE_FUNNY_WORKER_NAMES=$DISABLE_FUNNY_WORKER_NAMES
volumes:
- ./logs:/app/logs
depends_on:
Expand Down
5 changes: 3 additions & 2 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ DATABASE_URI=
OWNER_ID=

# optional below
THEME_COLOR=
AREA_LIMIT_PER_USER=
THEME_COLOR=#ffffff #(default blurple color)
AREA_LIMIT_PER_USER=#1 #(default 10, does not count for the owner)
DISABLE_FUNNY_WORKER_NAMES=#true #(default false)
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const config = {

themeColor: parseInt(process.env["THEME_COLOR"] ?? "0", 16) || Colors.Blurple,
limitAmountOfAreasPerUser: parseInt(process.env["AREA_LIMIT_PER_USER"] ?? "10", 10),
noGeneratedNames: process.env["DISABLE_FUNNY_WORKER_NAMES"] === "true",
} as const;

if (config.workerTokens.includes(config.clientToken)) throw new Error("You need to supply a separate bot token to be a worker, they cannot work alongside each other.");
Expand Down
3 changes: 2 additions & 1 deletion src/handlers/workers/Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Logger } from "winston";
import { Client, IntentsBitField, Options, Partials } from "discord.js";
import { objects, predicates } from "friendly-words";
import { inspect } from "util";
import config from "../../config";
import { workerLogger } from "../../utils/logger/discord";
import mainLogger from "../../utils/logger/main";
import handleInteractions from "../interactions";
Expand Down Expand Up @@ -86,7 +87,7 @@ export default class Worker {
handleInteractions(trueClient, this.workerName);
handleMentionCommands(trueClient, this.workerName);

if (trueClient.user.username !== this.workerName) {
if (!config.noGeneratedNames && trueClient.user.username !== this.workerName) {
void trueClient.user.edit({ username: this.workerName });
this.logger.info(`Renamed worker to match worker name. (${this.workerName})`);
}
Expand Down

0 comments on commit 33c1e6f

Please sign in to comment.