V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
juventusryp
V2EX  ›  问与答

求教有使用 wechaty 的朋友吗,关于通过好友的一个问题

  •  
  •   juventusryp · 2022-07-19 11:15:18 +08:00 · 673 次点击
    这是一个创建于 619 天前的主题,其中的信息可能已经有所发展或是发生改变。

    问题描述

    • 使用 wechaty 开发微信机器人,想实现机器人自动通过好友功能时编辑器提示下面错误,想问下有朋友知道问题出现在哪里吗?
    'Friendship' only refers to a type, but is being used as a value here.ts(2693)
    

    相关代码

    
    import {
        WechatyBuilder,
        Friendship
    } from 'wechaty'
    
    const bot = WechatyBuilder.build({
        name: "PadLocalDemo",
        puppet,
      })
      .on('friendship', async friendship => {
        switch (friendship.type()) {
          case Friendship.Type.Receive:
            await friendship.accept()
    
          case Friendship.Type.Confirm:
            console.log(friendship.contact())
        }
      })
      
     bot.start()
     bot.ready()
    
    
    juventusryp
        1
    juventusryp  
    OP
       2022-07-19 12:39:03 +08:00
    已在群里获得解决
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4964 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 09:40 · PVG 17:40 · LAX 02:40 · JFK 05:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.