Binato/server/packets/MultiplayerInvite.ts

19 lines
819 B
TypeScript
Raw Normal View History

2023-09-10 18:32:24 +01:00
import PrivateChannel from "../objects/PrivateChannel";
import User from "../objects/User";
export default function MultiplayerInvite(user:User, invitedUserId:number) {
const invitedUser = user.shared.users.getById(invitedUserId);
if (invitedUser instanceof User) {
let channel = user.shared.privateChatManager.GetChannelByName(`${user.username}${invitedUser.username}`);
if (!(channel instanceof PrivateChannel)) {
// Try it the other way around
channel = user.shared.privateChatManager.GetChannelByName(`${invitedUser.username}${user.username}`);
}
if (!(channel instanceof PrivateChannel)) {
channel = user.shared.privateChatManager.AddChannel(user, invitedUser);
}
channel.SendMessage(user, `Come join my multiplayer match: [osump://${user.match?.matchId}/ ${user.match?.gameName}]`);
}
}