require
from NodeJS is using CommonJS module format, but require
from RequireJS is using AMD module format. They are non compatible.
Just adding RequireJS to your code will not make it work. You have to amend your code.
require
from RequireJS does not return a required module. You have to pass the function which will have the module injected to it. Quick fix for you code:
require(['./models/guilds', './models/economy.js', './models/staff.js', './models/muted.js',], (guildData, ecoData, staffData, mutedData) => {
function getDB(type,id){
console.log(type,id)
if (type === 'guild'){
return guildData.findById(id);
}
else if (type === 'eco'){
return ecoData.findById(id);
}
else if (type === 'staff'){
return staffData.findById(id);
}
else if (type === 'muted'){
return mutedData.findById(id);
}
}
});
CLICK HERE to find out more related problems solutions.