Fix: Split channelEvent.ts into separate create/delete files
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 6s

The combined file with named exports caused 'once' property error.
Each event file must use 'export default'.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-23 10:47:48 +01:00
parent 6b259ddaa2
commit 6608d05f6f
2 changed files with 39 additions and 19 deletions

View File

@@ -0,0 +1,38 @@
import { Events, GuildChannel, EmbedBuilder } from 'discord.js';
async function sendLog(client: any, guildId: string, event: string, embed: EmbedBuilder) {
const DB = client.DB;
const settings: any = DB.get('SELECT log_events FROM guild_settings WHERE guild_id = ?', guildId);
if (!settings?.log_events) return;
const activeEvents = settings.log_events.split(',').filter(Boolean);
if (!activeEvents.includes(event)) return;
const logSettings: any = DB.get('SELECT log_channel FROM guild_settings WHERE guild_id = ?', guildId);
if (!logSettings?.log_channel) return;
const channel = client.guilds.cache.get(guildId)?.channels.cache.get(logSettings.log_channel);
if (!channel || !channel.isTextBased()) return;
try {
await (channel as any).send({ embeds: [embed] });
} catch (error) {
console.error(`[LOG] Error sending log (${event}):`, error);
}
}
export default {
name: Events.ChannelCreate,
async execute(channel: GuildChannel) {
const embed = new EmbedBuilder()
.setTitle('📁 Channel erstellt')
.setColor(0x27ae60)
.addFields(
{ name: 'Name', value: channel.name, inline: true },
{ name: 'Typ', value: channel.type.toString(), inline: true }
)
.setTimestamp();
await sendLog(channel.client, channel.guild!.id, 'channels', embed);
},
};

View File

@@ -21,25 +21,7 @@ async function sendLog(client: any, guildId: string, event: string, embed: Embed
}
}
// Channel Create
export const channelCreateEvent = {
name: Events.ChannelCreate,
async execute(channel: GuildChannel) {
const embed = new EmbedBuilder()
.setTitle('📁 Channel erstellt')
.setColor(0x27ae60)
.addFields(
{ name: 'Name', value: channel.name, inline: true },
{ name: 'Typ', value: channel.type.toString(), inline: true }
)
.setTimestamp();
await sendLog(channel.client, channel.guild!.id, 'channels', embed);
},
};
// Channel Delete
export const channelDeleteEvent = {
export default {
name: Events.ChannelDelete,
async execute(channel: GuildChannel) {
const embed = new EmbedBuilder()