Closed opinsky closed 4 years ago
I just tried a fresh install and copy-pasted the example code and it just worked. Can you say how to reproduce the issue? Are you sure you imported everything correctly?
I'm having exactly the same issue.
This is my code:
const Telegraf = require('telegraf')
const firestoreSession = require('telegraf-session-firestore')
const { Firestore } = require('@google-cloud/firestore')
const moment = require('moment')
const { BOT_TOKEN, NODE_ENV } = process.env
const db = new Firestore({
projectId: '****',
keyFilename: '******'
})
const bot = new Telegraf(BOT_TOKEN)
bot.use(firestoreSession(db.collection('sessions'), { lazy: true }))
bot.start(ctx => ctx.reply('Bienvenido'))
bot.hears('hi', ctx => ctx.reply('Hola'))
bot.on('message', ctx => ctx.reply('Comando no soportado'))
bot.launch()
Does it have something to do with some Typescript configuration?
I had the same and fixed it by calling firestoreSession.default
:
bot.use(firestoreSession.default(db.collection('sessions'), { lazy: true }))
I'm very sorry for being so silent on this, I really didn't have time to fix this in the past weeks. I could by now reproduce your issue and I have a fix ready that I will publish soon (needs to be tested first). I will keep you updated here, thank you for your patience
I bumped major because this is a breaking change. Please update your dependency and let me know if it works for you now. The workaround relying on .default
should now be obsolete.
when I try to run the example file, i get this error:
bot.use( firestoreSession(db.collection('sessions'), { lazy: true }) ) ^
TypeError: firestoreSession is not a function at Object. (/mnt/c/Users/opins/Documents/Development/changebot2/index.js:12:10)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
it is probably something stupid on my side, but not 100% sure.