const ExitCodes = require('../../exit-codes/exit-codes.js'); const LOG = require('../../logger/logger.js')('setup-test-server'); const DB = require('../db.js'); process.on('unhandledRejection', async (reason, promise) => { LOG.error('unhandled promise rejection:', reason); ExitCodes.exit(ExitCodes.GENERAL_ERROR); }); (async () => { await DB.connect(); try { let servers = await DB.getAllServers(); let targetServer = servers.find(server => server.name == 'no chicoms'); LOG.debug('target server:', { targetServer }); let members = await DB.getMembers(targetServer.id); let targetMember = members.find(member => member.display_name == 'Elipzer'); LOG.debug('target member:', { targetMember }); let roleId = await DB.createRole(targetServer.id, 'Admin', '#ee0000', 2); await DB.assignRolePrivilege(targetServer.id, roleId, 'modify_profile'); await DB.assignRolePrivilege(targetServer.id, roleId, 'modify_channels'); await DB.assignRolePrivilege(targetServer.id, roleId, 'modify_members'); await DB.assignRoleToMember(targetServer.id, roleId, targetMember.id); LOG.info('role created and assigned'); } catch (e) { LOG.error('error creating permissions'); } await DB.end(); })();