Files
pirate-corsaire-server/Packets/GuildDataIdentityModified.js
T
2026-08-24 22:20:36 +02:00

35 lines
1.5 KiB
JavaScript

/*
@Packet name GuildDataIdentityModified
@Packet identifier 186
@Description Includes data about modified guild identity (tag, name, description) and the timestamps of the end of cooldowns
@Data -
@Structure -
*/
module.exports = function (data) {
const identityLength = data.bufferTag.byteLength + 1 + data.bufferName.byteLength + 1 + data.bufferDescription.byteLength + 1;
const packetLength = 3 * (4 + 1) + identityLength + 1 + 1;
const buffer = new ArrayBuffer(packetLength);
const view = new DataView(buffer);
view.setUint8(0, 186);
view.setUint8(1, packetLength);
view.setUint8(2, data.r[0]);
view.setUint32(3, data.timestamps.tagEditedAt);
view.setUint8(7, data.r[1]);
view.setUint32(8, data.timestamps.nameEditedAt);
view.setUint8(12, data.r[2]);
view.setUint32(13, data.timestamps.descriptionEditedAt);
view.setUint8(17, data.bufferTag.byteLength);
new Uint8Array(buffer, 18).set(data.bufferTag);
view.setUint8(18 + data.bufferTag.byteLength, data.bufferName.byteLength);
new Uint8Array(buffer, 18 + data.bufferTag.byteLength + 1).set(data.bufferName);
view.setUint8(18 + data.bufferTag.byteLength + data.bufferName.byteLength + 1, data.bufferDescription.byteLength);
new Uint8Array(buffer, 18 + data.bufferTag.byteLength + 1 + data.bufferName.byteLength + 1).set(data.bufferDescription);
console.info("buffer", buffer)
console.info(data.timestamps)
return buffer;
};