discordjs / RPC

A simple RPC client for Discord

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Subscriptions not working (VOICE_STATE_CREATE, VOICE_STATE_UPDATE, VOICE_STATE_DELETE)

XENONFFM opened this issue · comments

I'm currently working on an plugin which uses several subscriptions.

When I try to use the follwing ones, I get an error:
VOICE_STATE_CREATE, VOICE_STATE_UPDATE, VOICE_STATE_DELETE

        // @ts-ignore
        this.rpc.on("VOICE_STATE_CREATE", {channel_id: "id"}, (data: any) => {
          console.log(data);
        });
        // @ts-ignore
        this.rpc.on("VOICE_STATE_UPDATE", {channel_id: "id"}, (data: any) => {
          console.log(data);
        });
        // @ts-ignore
        this.rpc.on("VOICE_STATE_DELETE", {channel_id: "id"}, (data: any) => {
          console.log(data);
        });

        // @ts-ignore
        this.rpc.subscribe("VOICE_STATE_CREATE", {});
        // @ts-ignore
        this.rpc.subscribe("VOICE_STATE_UPDATE", {});
        // @ts-ignore
        this.rpc.subscribe("VOICE_STATE_DELETE", {});

Error: "Uncaught TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received an instance of Object"

The other subscription which I implemented idetical are working e.g. VOICE_SETTINGS_UPDATE, VOICE_CHANNEL_SELECT

Is this a problem with the rpc lib or do these subsriptions have to be implemented different?
Thanks for any help / clarification.

I implemented these wrong.
Solution:

// @ts-ignore
this.rpc.on("VOICE_STATE_CREATE", (data: any) => {
   console.log(data);
});

// @ts-ignore
this.rpc.subscribe("VOICE_STATE_CREATE", {channel_id: "id"});