diff --git a/src/commands/bonk.ts b/src/commands/bonk.ts index 3a491a25..1e316a64 100644 --- a/src/commands/bonk.ts +++ b/src/commands/bonk.ts @@ -6,9 +6,6 @@ import type { Client, GuildMember } from "discord.js"; import type { CommandResult, MessageCommand } from "./command.js"; import type { ProcessableMessage } from "../handler/cmdHandler.js"; import log from "../utils/logger.js"; -import { getConfig } from "../utils/configHandler.js"; - -const config = getConfig(); const createBonkMeme = async (author: GuildMember): Promise => { const bonk = await fs.readFile("assets/bonk.png"); @@ -30,9 +27,9 @@ export class BonkCommand implements MessageCommand { name = "bonk"; aliases = ["bong"]; description = `Bonkt einen Nutzer und ersetzt den rechten gelben Hund mit dem Avatar des Nutzers. -Usage: ${config.bot_settings.prefix.command_prefix}bonk - ${config.bot_settings.prefix.command_prefix}bonk @ShadowByte#1337 - Oder auf eine Nachricht mit ${config.bot_settings.prefix.command_prefix}bonk antworten.`; +Usage: $COMMAND_PREFIX$bonk + $COMMAND_PREFIX$bonk @ShadowByte#1337 + Oder auf eine Nachricht mit $COMMAND_PREFIX$bonk antworten.`; async handleMessage( message: ProcessableMessage, diff --git a/src/commands/extend.ts b/src/commands/extend.ts index 381dfa85..1d0422ed 100644 --- a/src/commands/extend.ts +++ b/src/commands/extend.ts @@ -1,12 +1,9 @@ import { type APIEmbedField, EmbedBuilder, type Message } from "discord.js"; import log from "../utils/logger.js"; -import { getConfig } from "../utils/configHandler.js"; import * as poll from "./poll.js"; import type { CommandFunction } from "../types.js"; -const config = getConfig(); - const isPollField = (field: APIEmbedField): boolean => !field.inline && poll.LETTERS.some(l => field.name.startsWith(l)); @@ -132,4 +129,4 @@ export const run: CommandFunction = async (client, message, args, context) => { await message.delete(); }; -export const description = `Nutzbar als Reply auf eine mit --extendable erstellte Umfrage, um eine/mehrere Antwortmöglichkeit/en hinzuzüfgen. Die Anzahl der bestehenden und neuen Antwortmöglichkeiten darf ${poll.OPTION_LIMIT} nicht übersteigen.\nUsage: ${config.bot_settings.prefix.command_prefix}extend [Antwort 1] ; [...]`; +export const description = `Nutzbar als Reply auf eine mit --extendable erstellte Umfrage, um eine/mehrere Antwortmöglichkeit/en hinzuzüfgen. Die Anzahl der bestehenden und neuen Antwortmöglichkeiten darf ${poll.OPTION_LIMIT} nicht übersteigen.\nUsage: $COMMAND_PREFIX$extend [Antwort 1] ; [...]`; diff --git a/src/commands/min.ts b/src/commands/min.ts index 172dd480..7e29a6aa 100644 --- a/src/commands/min.ts +++ b/src/commands/min.ts @@ -1,8 +1,5 @@ -import { getConfig } from "../utils/configHandler.js"; import type { CommandFunction } from "../types.js"; -const config = getConfig(); - const getAdvice = (age: number) => { if (age <= 13) { return "Nicht mit vertretbarer rechtlicher Komplexität durchbutterbar"; @@ -41,4 +38,5 @@ export const run: CommandFunction = async (_client, message, args) => { await message.channel.send(advice); }; -export const description = `Gibt dir die Moralisch vertretbare Altersgrenze für den Geschlechtsakt basierend auf deinem Alter zurück. \nUsage: ${config.bot_settings.prefix.command_prefix}min [dein Alter]`; +export const description = + "Gibt dir die Moralisch vertretbare Altersgrenze für den Geschlechtsakt basierend auf deinem Alter zurück. \nUsage: $COMMAND_PREFIX$min [dein Alter]"; diff --git a/src/commands/modcommands/assigner.ts b/src/commands/modcommands/assigner.ts index 12e35528..186e036f 100644 --- a/src/commands/modcommands/assigner.ts +++ b/src/commands/modcommands/assigner.ts @@ -1,8 +1,5 @@ import type { CommandFunction } from "../../types.js"; import log from "../../utils/logger.js"; -import { getConfig } from "../../utils/configHandler.js"; - -const config = getConfig(); /** * Creates an assigner message @@ -28,4 +25,5 @@ export const run: CommandFunction = async (_client, message, args) => { await Promise.all(validRoles.map(drawRole)); }; -export const description = `Startet den assigner mit gegebenen Rollen \nBenutzung: ${config.bot_settings.prefix.mod_prefix}assigner [rolle 1] [rolle 2] [...]`; +export const description = + "Startet den assigner mit gegebenen Rollen \nBenutzung: $MOD_COMMAND_PREFIX$assigner [rolle 1] [rolle 2] [...]"; diff --git a/src/commands/poll.ts b/src/commands/poll.ts index 9e7a924b..54c4bd81 100644 --- a/src/commands/poll.ts +++ b/src/commands/poll.ts @@ -12,12 +12,9 @@ import { import log from "../utils/logger.js"; import * as additionalMessageData from "../storage/additionalMessageData.js"; -import { getConfig } from "../utils/configHandler.js"; import type { BotContext } from "../context.js"; import type { CommandFunction } from "../types.js"; -const config = getConfig(); - export const LETTERS = [ ":regional_indicator_a:", ":regional_indicator_b:", @@ -379,7 +376,7 @@ export const processPolls = async (context: BotContext) => { }; export const description = `Erstellt eine Umfrage mit mehreren Antwortmöglichkeiten (standardmäßig mit Mehrfachauswahl) (maximal ${OPTION_LIMIT}). -Usage: ${config.bot_settings.prefix.command_prefix}poll [Optionen?] [Hier die Frage] ; [Antwort 1] ; [Antwort 2] ; [...] +Usage: $COMMAND_PREFIX$poll [Optionen?] [Hier die Frage] ; [Antwort 1] ; [Antwort 2] ; [...] Optionen: \t-c, --channel \t\t\tSendet die Umfrage in den Umfragenchannel, um den Slowmode zu umgehen diff --git a/src/commands/roll.ts b/src/commands/roll.ts index 6370bf4b..59068a77 100644 --- a/src/commands/roll.ts +++ b/src/commands/roll.ts @@ -1,10 +1,7 @@ import { type APIEmbed, cleanContent } from "discord.js"; -import { getConfig } from "../utils/configHandler.js"; import type { CommandFunction } from "../types.js"; -const config = getConfig(); - /** * Creates a pseudo randomly generated number * @param {number} min @@ -122,6 +119,6 @@ export const run: CommandFunction = async (_client, message, args) => { export const description = ` Wirft x beliebig viele Würfel mit y vielen Seiten. -Usage: ${config.bot_settings.prefix.command_prefix}roll xdy +Usage: $COMMAND_PREFIX$roll xdy Mit x als die Anzahl der Würfel (<11) und y als die Menge der Seiten der Würfel (<=100) `.trim(); diff --git a/src/commands/selfban.ts b/src/commands/selfban.ts index b9bce088..44017fa7 100644 --- a/src/commands/selfban.ts +++ b/src/commands/selfban.ts @@ -3,11 +3,8 @@ import moment from "moment"; import type { CommandFunction } from "../types.js"; import * as banService from "../storage/ban.js"; -import { getConfig } from "../utils/configHandler.js"; import * as ban from "./modcommands/ban.js"; -const config = getConfig(); - export const run: CommandFunction = async (client, message, args, context) => { let input = args?.[0]?.trim() ?? "8"; const tilt = input === "tilt"; @@ -86,9 +83,10 @@ export const run: CommandFunction = async (client, message, args, context) => { await message.author.send(`Du hast dich selber von der Coding Shitpost Zentrale gebannt! Du wirst entbannt in: ${durationHumanized} -Falls du doch vorzeitig entbannt entbannt werden möchtest, kannst du dich im <#${config.ids.banned_channel_id}> Channel melden. +Falls du doch vorzeitig entbannt entbannt werden möchtest, kannst du dich im ${context.textChannels.banned} Channel melden. Haddi & xD™`); }; -export const description = `Bannt den ausführenden User indem er ihn von allen Channels ausschließt.\nBenutzung: ${config.bot_settings.prefix.command_prefix}selfban [Dauer in Stunden = 8; tilt; 0 = manuelle Entbannung durch Moderader nötig]`; +export const description = + "Bannt den ausführenden User indem er ihn von allen Channels ausschließt.\nBenutzung: $COMMAND_PREFIX$selfban [Dauer in Stunden = 8; tilt; 0 = manuelle Entbannung durch Moderader nötig]"; diff --git a/src/commands/vote.ts b/src/commands/vote.ts index 5824c0b3..a413e9d1 100644 --- a/src/commands/vote.ts +++ b/src/commands/vote.ts @@ -2,9 +2,6 @@ import parseOptions from "minimist"; import { cleanContent } from "discord.js"; import type { CommandFunction } from "../types.js"; -import { getConfig } from "../utils/configHandler.js"; - -const config = getConfig(); /** * Creates a new poll (vote; yes/no) @@ -53,7 +50,7 @@ export const run: CommandFunction = async (_client, message, args, context) => { }; export const description = `Erstellt eine Umfrage (ja/nein). -Usage: ${config.bot_settings.prefix.command_prefix}vote [Optionen?] [Hier die Frage] +Usage: $COMMAND_PREFIX$vote [Optionen?] [Hier die Frage] Optionen: \t-c, --channel \t\t\tSendet die Umfrage in den Umfragenchannel, um den Slowmode zu umgehen`; diff --git a/src/handler/cmdHandler.ts b/src/handler/cmdHandler.ts index 80fb5777..e052ec1b 100644 --- a/src/handler/cmdHandler.ts +++ b/src/handler/cmdHandler.ts @@ -5,7 +5,6 @@ import type { Client, Guild, GuildMember, Message } from "discord.js"; import type { CommandFunction, CommandResult } from "../types.js"; import log from "../utils/logger.js"; -import { getConfig } from "../utils/configHandler.js"; import * as ban from "../commands/modcommands/ban.js"; import { hasBotDenyRole } from "../utils/userUtils.js"; import { isMessageInBotSpam } from "../utils/channelUtils.js"; diff --git a/src/handler/messageDeleteHandler.ts b/src/handler/messageDeleteHandler.ts index d4dfa57b..9264a77d 100644 --- a/src/handler/messageDeleteHandler.ts +++ b/src/handler/messageDeleteHandler.ts @@ -1,10 +1,7 @@ import type { Client, Message } from "discord.js"; -import { getConfig } from "../utils/configHandler.js"; import type { BotContext } from "../context.js"; -const config = getConfig(); - const deleteInlineRepliesFromBot = ( messageRef: Message, client: Client, @@ -22,17 +19,13 @@ const deleteInlineRepliesFromBot = ( export default async function ( message: Message, client: Client, - _context: BotContext, + context: BotContext, ) { if (message.author && message.author.id !== client.user?.id) { if (message.content) { const isNormalCommand = - message.content.startsWith( - config.bot_settings.prefix.command_prefix, - ) || - message.content.startsWith( - config.bot_settings.prefix.mod_prefix, - ); + message.content.startsWith(context.prefix.command) || + message.content.startsWith(context.prefix.modCommand); if (isNormalCommand) { await deleteInlineRepliesFromBot(message, client); diff --git a/src/handler/voiceStateUpdateHandler.ts b/src/handler/voiceStateUpdateHandler.ts index 674929ac..1f653ac3 100644 --- a/src/handler/voiceStateUpdateHandler.ts +++ b/src/handler/voiceStateUpdateHandler.ts @@ -1,10 +1,7 @@ import type { VoiceState } from "discord.js"; import type { BotContext } from "../context.js"; -import { getConfig } from "../utils/configHandler.js"; import log from "../utils/logger.js"; -const config = getConfig(); - export interface VoiceUpdateEvent { oldState: VoiceState; newState: VoiceState; @@ -18,15 +15,17 @@ export const woisData = { export async function checkVoiceUpdate( oldState: VoiceState, newState: VoiceState, - _botContext: BotContext, + context: BotContext, ): Promise { log.debug( `Voice update detected: ${oldState.channelId} -> ${newState.channelId}`, ); + const mainVoiceId = context.voiceChannels.haupt_woischat.id; + // User joined Channel if (oldState.channel === null && newState.channel !== null) { - if (newState.channelId === config.ids.haupt_woischat) { + if (newState.channelId === mainVoiceId) { woisData.latestEvents.push({ oldState, newState, @@ -37,7 +36,7 @@ export async function checkVoiceUpdate( // user left channel if (oldState.channel !== null && newState.channel === null) { - if (newState.channelId === config.ids.haupt_woischat) { + if (newState.channelId === mainVoiceId) { // Add to latest events woisData.latestEvents.push({ oldState,