juventusryp
V2EX  ›  问与答

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

  •  
  •   juventusryp · Jul 19, 2022 · 1460 views
    This topic created in 1422 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   ·   2629 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 15:52 · PVG 23:52 · LAX 08:52 · JFK 11:52
    ♥ Do have faith in what you're doing.