const GuildSearchResultStateChanged = require("../Packets/GuildSearchResultStateChanged"); const GuildDataApplicantRemove = require("../Packets/GuildDataApplicantRemove"); const Game = require("../Game/Game"); const { players, guilds } = Game; const QUERY_GUILD_REQUEST_REVOKE = "DELETE FROM guildrequests WHERE guildID = ? AND playerID = ?"; module.exports = async function (ws, message, player) { const guildID = message.getUint16(1); const guild = guildID ? guilds[guildID] : player.guild; if (!guild || !guild.id) return; if (guild.id === player.guild.id) return; const playerID = message.getUint32(3); const targetPlayer = playerID ? players[playerID] : player; const guildJoinRequestRevokeQuery = await execute(QUERY_GUILD_REQUEST_REVOKE, [guild.id, targetPlayer.id]); if (!guildJoinRequestRevokeQuery.data) return console.info("shit"); guild.removeRequest(targetPlayer.id); const guildSearchResultStateChanged = { id: guild.id, hasApplied: false }; const guildSearchResultStateChangedPacket = GuildSearchResultStateChanged(guildSearchResultStateChanged); targetPlayer.map.registerIndividualNetworkPacket(targetPlayer.id, guildSearchResultStateChangedPacket); const guildDataApplicantRemove = { id: targetPlayer.id }; const guildDataApplicantRemovePacket = GuildDataApplicantRemove(guildDataApplicantRemove); const topic = Game.getTopic(guild.topic); topic.push(guildDataApplicantRemovePacket); };