Fix: Split channelEvent.ts into separate create/delete files
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 6s
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:
38
src/events/channelCreate.ts
Normal file
38
src/events/channelCreate.ts
Normal 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);
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -21,25 +21,7 @@ async function sendLog(client: any, guildId: string, event: string, embed: Embed
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Channel Create
|
export default {
|
||||||
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 = {
|
|
||||||
name: Events.ChannelDelete,
|
name: Events.ChannelDelete,
|
||||||
async execute(channel: GuildChannel) {
|
async execute(channel: GuildChannel) {
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
Reference in New Issue
Block a user