liamcottle / rustplus.js

Unofficial NodeJS library for controlling Smart Switches in the PC game Rust
224 stars 46 forks source link

sendRequestAsync for sendTeamMessage returns error "message_not_sent" even though the message sent successfully #31

Closed NWaterbury closed 3 years ago

NWaterbury commented 3 years ago

AppMessage {response: AppResponse} response:AppResponse {seq: 1, error: AppError} error:AppError {error: 'message_not_sent'} error:'message_not_sent'

rustplus.on('connected', () => { rustplus.sendRequestAsync({ sendTeamMessage: { message: "Message for Team Chats", } }, 2000) .then((message) => { console.log(message); }) .catch((error) => { console.log(error); }) })

liamcottle commented 3 years ago

You will get the message_not_sent error if you are not in a team. Can you try this again making sure you are in a team?

NWaterbury commented 3 years ago

I was leader of the team and the message was successfully sent in game and in the console, but the error was still received.

liamcottle commented 3 years ago

Cant really say what happened here then sorry. As far as I know, you only get that error message if you're not in a team, and the message wasn't sent as a result.

NWaterbury commented 3 years ago

.. Have you attempted to repro it?

liamcottle commented 3 years ago

Just tried it now, and it works as expected.

rustplus.on('connected', () => {

    // log team info
    rustplus.sendRequestAsync({
        getTeamInfo: {},
    }, 2000).then((message) => {
        console.log(message);
    }).catch((error) => {
        console.log(error);
    });

    // send message to team chat
    rustplus.sendRequestAsync({
        sendTeamMessage: {
            message: "Message for Team Chats",
        },
    }, 2000).then((message) => {
        console.log(message);
    }).catch((error) => {
        console.log(error);
    }).then(() => {
        rustplus.disconnect();
    });

});

rustplus.connect();

Logged in to server without a Team, message was not sent and not shown in game.

AppResponse {
  seq: 1,
  teamInfo: AppTeamInfo {
    members: [ [Member] ],
    mapNotes: [],
    leaderMapNotes: [],
    leaderSteamId: Long { low: 0, high: 0, unsigned: true }
  }
}
AppError { error: 'message_not_sent' }

Created a Team via tab menu. Message was sent, and was shown in game.

AppResponse {
  seq: 1,
  teamInfo: AppTeamInfo {
    members: [ [Member] ],
    mapNotes: [],
    leaderMapNotes: [],
    leaderSteamId: Long { low: redacted, high: redacted, unsigned: true }
  }
}
AppResponse { seq: 2, success: AppSuccess {} }

I've also checked the decompiled code of the Rust game, and there's been no changes to Chat.cs or SendTeamChat.cs in Assembly-CSharp.dll.

The only way for it to be possible to receive message_not_sent is if Chat.sayAs in the game server returns false, which it shouldn't since the chat message was shown in game.

Can you post the output of getTeamInfo before sending a team message?