import express from 'express';
import { ChatSystem } from '../../../../features/chat';
import { ChatColors } from '../../../../const/chat-colors';
import { permissionSystem } from '../../../../features/permission';

export async function LeadChat(req: express.Request, res: express.Response) {
    const message = req.body.message;
    const from = req.body.from;

    mp.players.toArrayFast().forEach((player) => {
        if (permissionSystem.doesPlayerHavePermission(player, 'account.admin.lachat')) {
            ChatSystem.Message(player, `${ChatColors.custom(ChatColors.pureOrange, 'lead admin chat')}*![LEAD] ${from}: ${message}`, 'discord', 'staff');
        }
    });

    res.sendStatus(200);
}
