so im stuck at this error. Im making a telegram bot with the telegram bot api and now im trying to set up a firebae DB to save the score of a group member - so the score is not resetted after restarting the bot. can someone tell me what the problem is? i read a lot of other issues here with similiar problems, but none of these answers fixed my problem.
bot.js
var TelegramBot = require('node-telegram-bot-api');
var firebase = require('firebase');
var token = 'mytoken';
// Setup polling way
var bot = new TelegramBot(token, {polling: true});
var app = firebase.intializeApp({
serviceAccount: "C:/Mayer/scorebot/telegramscorebot.json",
databaseURL: "https://blazing-heat-2008.firebaseio.com/"
});
/* function Person(name, score) {
this.name = name;
this.score = score;
}
var member = new Array();
member[0] = new Person("name1", 0);
member[1] = new Person("name2", 0);
member[2] = new Person("name3", 0);
member[3] = new Person("name4", 0);
member[4] = new Person("name5", 0); */
bot.onText(/\/echo (.+)/, function (msg, match) {
var fromId = msg.from.id;
if (match[1] == 'test') {
var resp = match[1];
bot.sendMessage(fromId, resp); }
else {
bot.sendMessage(fromId, 'error!!');}
});
bot.onText(/\/vote (.+)/, function (msg, match) {
var fromId = msg.from.id;
for (var i = 0; i <= 4; i++) {
if(member[i].name == match[1]){
member[i].score += 1;
bot.sendMessage(fromId, member[i].name + ' hat einen Score von ' + member[i].score);}
}
});
package.json
{
"name": "scorebot",
"version": "1.0.0",
"description": "",
"main": "bot.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node bot.js"
},
"author": "me",
"license": "ISC",
"dependencies": {
"bower": "1.7.9",
"firebase": "3.0.2"
}
}
Error message
bot.js:8 var app = firebase.intializeApp({
^
TypeError: firebase.intializeApp is not a function
at Object.<anonymous> (C:\Mayer\scorebot\bot.js:8:20)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:141:18)
at node.js:933:3
initializeApp. Creates and initializes a Firebase app instance. See Add Firebase to your app and Initialize multiple projects for detailed documentation.
Unlike the Firebase Web SDK, there is no need to manually call the initializeApp method with your project credentials. The native Android & iOS SDKs automatically connect to your Firebase project using the credentials provided during the Getting Started installation steps.
You have a typo in firebase.intializeApp.
It should be initializeApp.
var app = firebase.initializeApp({...});
See the docs here: https://www.npmjs.com/package/firebase
You need to require the 'app' when in the browser context like so...
const firebase = require('firebase/app');
const app = firebase.initializeApp({ ... });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With