0

您好我正在尝试创建一个自定义插件stanzajs来发送具有自定义属性的消息,但它会引发错误:Unhandled Rejection (TypeError): Cannot read properties of undefined (reading 'textSub')

customPlugin.js

export default function customStanza(client, stanzas) {
  const NS = "xmpp:customAttr";
  const customAttribute = stanzas.define({
    name: "custom",
    element: "custom",
    namespace: NS,
    fields: {
      value: stanzas.utils.textSub(NS, "value"),
      layout: stanzas.utils.attribute("layout"),
    },
  });

  stanzas.withMessage((Message) => {
    stanzas.extend(Message, customAttribute);
  });
}

//用法

client.use(customStanza);
4

0 回答 0