telegraf.js i18n- typeError:无法阅读Wizardscene中未定义的属性(读取' t')
一切都起作用,但是在场景的第二阶段,I18N不确定。 I18N和机器人的场景都已注册。
const createPostHere = new Scenes.WizardScene('createPostHere',
async (ctx) => {
ctx.wizard.state.post = {}
await ctx.reply(await ctx.i18n.t('createPost.promptTitle')) << everything works
ctx.wizard.next()
},
async (ctx) => {
ctx.wizard.state.post.title = ctx.message.text
await ctx.reply(await ctx.i18n.t('createPost.promptText')) << node crashes
ctx.wizard.next()
},
所有注册的一切
bot.use(stage.middleware());
bot.use(i18n.middleware())
我真的不知道问题在哪里
Everything works, but in the second stage of the scene, i18n is undefined. i18n is registered, as are the scenes in the bot.
const createPostHere = new Scenes.WizardScene('createPostHere',
async (ctx) => {
ctx.wizard.state.post = {}
await ctx.reply(await ctx.i18n.t('createPost.promptTitle')) << everything works
ctx.wizard.next()
},
async (ctx) => {
ctx.wizard.state.post.title = ctx.message.text
await ctx.reply(await ctx.i18n.t('createPost.promptText')) << node crashes
ctx.wizard.next()
},
Everything registered
bot.use(stage.middleware());
bot.use(i18n.middleware())
I really don`t know where is the problem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该在舞台中间件之前先使用I18N。像这样:
You should use i18n first before stage middleware. Like this: