Small tweak

This commit is contained in:
2024-01-08 00:02:05 +01:00
parent 4f9d4f6426
commit b99f0c1e7b
3 changed files with 12 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
import { guildid, onlineLogChannel, botLogChannel, guildLogChannel, errorLogChannel, moderationLogChannel } from "../../../config/options.json"
import { guildid, onlineLogChannel, botLogChannel, guildLogChannel, errorLogChannel, moderationLogChannel, devLogChannel } from "../../../config/options.json"
import { Guild, MessageCreateOptions, TextChannel } from "discord.js"
import Illegitimate from "../Illegitimate"
@@ -7,15 +7,22 @@ const channels = {
bot: botLogChannel,
guild: guildLogChannel,
error: errorLogChannel,
mod: moderationLogChannel
mod: moderationLogChannel,
dev: devLogChannel
}
type Channel = keyof typeof channels
export default async function logToChannel(channel: Channel, message: MessageCreateOptions): Promise<void|null> {
const guild = Illegitimate.client.guilds.cache.get(guildid) as Guild
let logChannel: TextChannel
if (process.env.NODE_ENV === "dev") {
logChannel = guild.channels.cache.get(channels["dev"]) as TextChannel
} else {
logChannel = guild.channels.cache.get(channels[channel]) as TextChannel
}
const logChannel = guild.channels.cache.get(channels[channel]) as TextChannel
if (!logChannel) {
console.log(`[ERROR] Could not find channel used for ${channel} logging.`)
return