'use strict';

global.freeroam = {
    commands: jcmp.events.Call('get_command_manager')[0],
    chat: jcmp.events.Call('get_chat')[0],
    config: require('./gm/config'),
    utils: require('./gm/utility'),
    colours: require('./vendor/randomColor'),
    workarounds: require('./gm/_workarounds'),
    bans: new Set(),
    passiveModeBans: new Set(),
    timeManager: new (require('./gm/timeManager'))(13, 0),
    groupManager: new (require('./gm/groupManager'))()
};

// temp
/*freeroam.chat.addCustomCSS(`
#chat>#chat-box {
    background:none!important;
}
`);*/

// add custom CSS
freeroam.chat.addCustomCSS(`
.admin-logo {
  background-image: url('data:image/png;base64,[encoded data, 6060 characters]');
  background-size: cover;
  margin-top: 4px;
  width: 14px;
  height: 14px;
  margin-right: 4px;
  float: left;
}

.admin-logo.large {
  width: 24px;
  height: 24px;
  margin-top: 4px;
  margin-right: 8px;
  float: left;
}

.group-message {
  font-size: 16px;
}`)

process.on('uncaughtException', e => console.error(e.stack || e));

// load all commands from the 'commands' directory
freeroam.commands.loadFromDirectory(`${__dirname}/commands`, (f, ...a) => require(f)(...a));

// load all event files from the 'events' directory
freeroam.utils.loadFilesFromDirectory(`${__dirname}/events`);

freeroam.timeManager.start();
freeroam.groupManager.setRestrictedNames(freeroam.config.groupRestrictedNames);

setInterval(() => {}, 500);
