V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
juventusryp
V2EX  ›  问与答

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

  •  
  •   juventusryp · Jul 19, 2022 · 1385 views
    This topic created in 1382 days ago, the information mentioned may be changed or developed.

    问题描述

    • 使用 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
       Jul 19, 2022
    已在群里获得解决
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2450 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 02:40 · PVG 10:40 · LAX 19:40 · JFK 22:40
    ♥ Do have faith in what you're doing.