import { GuildChannel } from 'discord.js';
import { EventHandler } from '../utils/types';
import { context } from '../config/context';

const event: EventHandler = {
  name: 'channelUpdate',
  execute(oldChannel: GuildChannel, newChannel: GuildChannel) {
    if (!newChannel.guild) return;
    const nameChanged = oldChannel.name !== newChannel.name;
    if (nameChanged) {
      context.logging.logSystem(
        newChannel.guild,
        `Channel umbenannt: ${oldChannel.name} -> ${newChannel.name} (${newChannel.id})`
      );
    }
  }
};

export default event;
