diff --git a/Config/DefaultProfiles/allathena.json b/Config/DefaultProfiles/allathena.json index d5c454b..4f95d71 100644 --- a/Config/DefaultProfiles/allathena.json +++ b/Config/DefaultProfiles/allathena.json @@ -26100,41 +26100,11 @@ "xp": 0, "variants": [ { - "channel": "JerseyColor", - "active": "Fortnite", + "channel": "Parts", + "active": "Stage0", "owned": [ - "Fortnite", - "Argentina", - "Australia", - "Belgium", - "Brazil", - "Canada", - "Colombia", - "Denmark", - "Egypt", - "England", - "France", - "Germany", - "Iceland", - "Italy", - "Ireland", - "Japan", - "Korea", - "Mexico", - "Netherlands", - "NewZealand", - "Nigeria", - "Norway", - "Poland", - "Portugal", - "Russia", - "Saudi", - "Spain", - "Sweden", - "Switzerland", - "Terkey", - "Uruguay", - "USA" + "Stage0", + "Stage1" ] } ], @@ -26151,41 +26121,12 @@ "xp": 0, "variants": [ { - "channel": "JerseyColor", - "active": "Fortnite", + "channel": "ClothingColor", + "active": "Mat0", "owned": [ - "Fortnite", - "Argentina", - "Australia", - "Belgium", - "Brazil", - "Canada", - "Colombia", - "Denmark", - "Egypt", - "England", - "France", - "Germany", - "Iceland", - "Italy", - "Ireland", - "Japan", - "Korea", - "Mexico", - "Netherlands", - "NewZealand", - "Nigeria", - "Norway", - "Poland", - "Portugal", - "Russia", - "Saudi", - "Spain", - "Sweden", - "Switzerland", - "Terkey", - "Uruguay", - "USA" + "Mat0", + "Mat1", + "Mat2" ] } ], @@ -26202,41 +26143,11 @@ "xp": 0, "variants": [ { - "channel": "JerseyColor", - "active": "Fortnite", + "channel": "Parts", + "active": "Stage1", "owned": [ - "Fortnite", - "Argentina", - "Australia", - "Belgium", - "Brazil", - "Canada", - "Colombia", - "Denmark", - "Egypt", - "England", - "France", - "Germany", - "Iceland", - "Italy", - "Ireland", - "Japan", - "Korea", - "Mexico", - "Netherlands", - "NewZealand", - "Nigeria", - "Norway", - "Poland", - "Portugal", - "Russia", - "Saudi", - "Spain", - "Sweden", - "Switzerland", - "Terkey", - "Uruguay", - "USA" + "Stage1", + "Stage2" ] } ], @@ -26251,46 +26162,7 @@ "level": 1, "item_seen": true, "xp": 0, - "variants": [ - { - "channel": "JerseyColor", - "active": "Fortnite", - "owned": [ - "Fortnite", - "Argentina", - "Australia", - "Belgium", - "Brazil", - "Canada", - "Colombia", - "Denmark", - "Egypt", - "England", - "France", - "Germany", - "Iceland", - "Italy", - "Ireland", - "Japan", - "Korea", - "Mexico", - "Netherlands", - "NewZealand", - "Nigeria", - "Norway", - "Poland", - "Portugal", - "Russia", - "Saudi", - "Spain", - "Sweden", - "Switzerland", - "Terkey", - "Uruguay", - "USA" - ] - } - ], + "variants": [], "favorite": false }, "quantity": 1 @@ -26302,46 +26174,7 @@ "level": 1, "item_seen": true, "xp": 0, - "variants": [ - { - "channel": "JerseyColor", - "active": "Fortnite", - "owned": [ - "Fortnite", - "Argentina", - "Australia", - "Belgium", - "Brazil", - "Canada", - "Colombia", - "Denmark", - "Egypt", - "England", - "France", - "Germany", - "Iceland", - "Italy", - "Ireland", - "Japan", - "Korea", - "Mexico", - "Netherlands", - "NewZealand", - "Nigeria", - "Norway", - "Poland", - "Portugal", - "Russia", - "Saudi", - "Spain", - "Sweden", - "Switzerland", - "Terkey", - "Uruguay", - "USA" - ] - } - ], + "variants": [], "favorite": false }, "quantity": 1 @@ -26354,43 +26187,20 @@ "item_seen": true, "xp": 0, "variants": [ + { + "channel": "Pattern", + "active": "Mat0", + "owned": [] + }, + { + "channel": "Numeric", + "active": "Numeric.69", + "owned": [] + }, { "channel": "JerseyColor", - "active": "Fortnite", - "owned": [ - "Fortnite", - "Argentina", - "Australia", - "Belgium", - "Brazil", - "Canada", - "Colombia", - "Denmark", - "Egypt", - "England", - "France", - "Germany", - "Iceland", - "Italy", - "Ireland", - "Japan", - "Korea", - "Mexico", - "Netherlands", - "NewZealand", - "Nigeria", - "Norway", - "Poland", - "Portugal", - "Russia", - "Saudi", - "Spain", - "Sweden", - "Switzerland", - "Terkey", - "Uruguay", - "USA" - ] + "active": "Color.Germany", + "owned": [] } ], "favorite": false @@ -26404,46 +26214,7 @@ "level": 1, "item_seen": true, "xp": 0, - "variants": [ - { - "channel": "JerseyColor", - "active": "Fortnite", - "owned": [ - "Fortnite", - "Argentina", - "Australia", - "Belgium", - "Brazil", - "Canada", - "Colombia", - "Denmark", - "Egypt", - "England", - "France", - "Germany", - "Iceland", - "Italy", - "Ireland", - "Japan", - "Korea", - "Mexico", - "Netherlands", - "NewZealand", - "Nigeria", - "Norway", - "Poland", - "Portugal", - "Russia", - "Saudi", - "Spain", - "Sweden", - "Switzerland", - "Terkey", - "Uruguay", - "USA" - ] - } - ], + "variants": [], "favorite": false }, "quantity": 1 @@ -26456,43 +26227,20 @@ "item_seen": true, "xp": 0, "variants": [ + { + "channel": "Pattern", + "active": "Mat0", + "owned": [] + }, + { + "channel": "Numeric", + "active": "Numeric.14", + "owned": [] + }, { "channel": "JerseyColor", - "active": "Fortnite", - "owned": [ - "Fortnite", - "Argentina", - "Australia", - "Belgium", - "Brazil", - "Canada", - "Colombia", - "Denmark", - "Egypt", - "England", - "France", - "Germany", - "Iceland", - "Italy", - "Ireland", - "Japan", - "Korea", - "Mexico", - "Netherlands", - "NewZealand", - "Nigeria", - "Norway", - "Poland", - "Portugal", - "Russia", - "Saudi", - "Spain", - "Sweden", - "Switzerland", - "Terkey", - "Uruguay", - "USA" - ] + "active": "Color.Terkey", + "owned": [] } ], "favorite": false @@ -27304,51 +27052,7 @@ "level": 1, "item_seen": true, "xp": 0, - "variants": [ - { - "channel": "JerseyColor", - "active": "000", - "owned": [ - "000", - "001", - "002", - "003", - "004", - "005", - "006", - "007", - "008", - "009", - "010", - "011", - "012", - "013", - "014", - "015", - "016", - "017", - "018", - "019", - "020", - "021", - "022", - "023", - "024", - "025", - "026", - "027", - "028", - "029", - "030", - "031", - "036", - "032", - "033", - "034", - "035" - ] - } - ], + "variants": [], "favorite": false }, "quantity": 1 @@ -27360,51 +27064,7 @@ "level": 1, "item_seen": true, "xp": 0, - "variants": [ - { - "channel": "JerseyColor", - "active": "000", - "owned": [ - "000", - "001", - "002", - "003", - "004", - "005", - "006", - "007", - "008", - "009", - "010", - "011", - "012", - "013", - "014", - "015", - "016", - "017", - "018", - "019", - "020", - "021", - "022", - "023", - "024", - "025", - "026", - "027", - "028", - "029", - "030", - "031", - "036", - "032", - "033", - "034", - "035" - ] - } - ], + "variants": [], "favorite": false }, "quantity": 1 @@ -27416,51 +27076,7 @@ "level": 1, "item_seen": true, "xp": 0, - "variants": [ - { - "channel": "JerseyColor", - "active": "000", - "owned": [ - "000", - "001", - "002", - "003", - "004", - "005", - "006", - "007", - "008", - "009", - "010", - "011", - "012", - "013", - "014", - "015", - "016", - "017", - "018", - "019", - "020", - "021", - "022", - "023", - "024", - "025", - "026", - "027", - "028", - "029", - "030", - "031", - "036", - "032", - "033", - "034", - "035" - ] - } - ], + "variants": [], "favorite": false }, "quantity": 1 @@ -27472,51 +27088,7 @@ "level": 1, "item_seen": true, "xp": 0, - "variants": [ - { - "channel": "JerseyColor", - "active": "000", - "owned": [ - "000", - "001", - "002", - "003", - "004", - "005", - "006", - "007", - "008", - "009", - "010", - "011", - "012", - "013", - "014", - "015", - "016", - "017", - "018", - "019", - "020", - "021", - "022", - "023", - "024", - "025", - "026", - "027", - "028", - "029", - "030", - "031", - "036", - "032", - "033", - "034", - "035" - ] - } - ], + "variants": [], "favorite": false }, "quantity": 1 @@ -27528,51 +27100,7 @@ "level": 1, "item_seen": true, "xp": 0, - "variants": [ - { - "channel": "JerseyColor", - "active": "000", - "owned": [ - "000", - "001", - "002", - "003", - "004", - "005", - "006", - "007", - "008", - "009", - "010", - "011", - "012", - "013", - "014", - "015", - "016", - "017", - "018", - "019", - "020", - "021", - "022", - "023", - "024", - "025", - "026", - "027", - "028", - "029", - "030", - "031", - "036", - "032", - "033", - "034", - "035" - ] - } - ], + "variants": [], "favorite": false }, "quantity": 1 @@ -27584,51 +27112,7 @@ "level": 1, "item_seen": true, "xp": 0, - "variants": [ - { - "channel": "JerseyColor", - "active": "000", - "owned": [ - "000", - "001", - "002", - "003", - "004", - "005", - "006", - "007", - "008", - "009", - "010", - "011", - "012", - "013", - "014", - "015", - "016", - "017", - "018", - "019", - "020", - "021", - "022", - "023", - "024", - "025", - "026", - "027", - "028", - "029", - "030", - "031", - "036", - "032", - "033", - "034", - "035" - ] - } - ], + "variants": [], "favorite": false }, "quantity": 1 diff --git a/Config/config.json b/Config/config.json index 22f491f..eb8679f 100644 --- a/Config/config.json +++ b/Config/config.json @@ -14,6 +14,7 @@ "bEnableDebugLogs": false, "bEnableRebootUser": true, + "bEnableCrossBans": false, "//": "If you want to use the backend on reboot, leave 3551 as the port", "port": 3551, diff --git a/DiscordBot/commands/Admin/delete.js b/DiscordBot/commands/Admin/delete.js index bb82729..35bc252 100644 --- a/DiscordBot/commands/Admin/delete.js +++ b/DiscordBot/commands/Admin/delete.js @@ -35,7 +35,9 @@ module.exports = { await Users.deleteOne({ username: username }); await Profiles.deleteOne({ username: username }); - await SACCodes.deleteOne({ owneraccountId: accountId }); + await SACCodes.deleteOne({ owneraccountId: accountId }).catch(error => { + // Nothing Uwu or just use: log.debug('No SAC codes found or error occurred:', error); + }); const embed = new MessageEmbed() .setTitle("Account deleted") diff --git a/DiscordBot/commands/Admin/deletediscord.js b/DiscordBot/commands/Admin/deletediscord.js index fc07388..7815d3b 100644 --- a/DiscordBot/commands/Admin/deletediscord.js +++ b/DiscordBot/commands/Admin/deletediscord.js @@ -36,7 +36,9 @@ module.exports = { await Users.deleteOne({ discordId: discordId }) await Profiles.deleteOne({ discordId: discordId }) - await SACCodes.deleteOne({ owneraccountId: accountId }); + await SACCodes.deleteOne({ owneraccountId: accountId }).catch(error => { + // Nothing Uwu or just use: log.debug('No SAC codes found or error occurred:', error); + }); const embed = new MessageEmbed() .setTitle("Account deleted") diff --git a/DiscordBot/index.js b/DiscordBot/index.js index 41b6563..65262ce 100644 --- a/DiscordBot/index.js +++ b/DiscordBot/index.js @@ -1,9 +1,10 @@ const { Client, Intents } = require("discord.js"); -const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MEMBERS] }); +const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_BANS] }); const fs = require("fs"); const path = require("path"); const config = JSON.parse(fs.readFileSync("./Config/config.json").toString()); const log = require("../structs/log.js"); +const Users = require("../model/user.js"); client.once("ready", () => { log.bot("Bot is up and running!"); @@ -46,6 +47,57 @@ client.on("interactionCreate", async interaction => { executeCommand(path.join(__dirname, "commands"), interaction.commandName); }); +client.on("guildBanAdd", async (ban) => { + if (!config.bEnableCrossBans) + return; + + const memberBan = await ban.fetch(); + + if (memberBan.user.bot) + return; + + const userData = await Users.findOne({ discordId: memberBan.user.id }); + + if (userData && userData.banned !== true) { + await userData.updateOne({ $set: { banned: true } }); + + let refreshToken = global.refreshTokens.findIndex(i => i.accountId == userData.accountId); + + if (refreshToken != -1) + global.refreshTokens.splice(refreshToken, 1); + let accessToken = global.accessTokens.findIndex(i => i.accountId == userData.accountId); + + if (accessToken != -1) { + global.accessTokens.splice(accessToken, 1); + let xmppClient = global.Clients.find(client => client.accountId == userData.accountId); + if (xmppClient) + xmppClient.client.close(); + } + + if (accessToken != -1 || refreshToken != -1) { + await functions.UpdateTokens(); + } + + log.debug(`user ${memberBan.user.username} (ID: ${memberBan.user.id}) was banned on the discord and also in the game (Cross Ban active).`); + } +}); + +client.on("guildBanRemove", async (ban) => { + if (!config.bEnableCrossBans) + return; + + if (ban.user.bot) + return; + + const userData = await Users.findOne({ discordId: ban.user.id }); + + if (userData && userData.banned === true) { + await userData.updateOne({ $set: { banned: false } }); + + log.debug(`User ${ban.user.username} (ID: ${ban.user.id}) is now unbanned.`); + } +}); + //AntiCrash System client.on("error", (err) => { console.log("Discord API Error:", err); diff --git a/index.js b/index.js index fee1438..068cac8 100644 --- a/index.js +++ b/index.js @@ -47,13 +47,20 @@ global.kv = kv; global.exchangeCodes = []; +let updateFound = false; + const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, "./package.json")).toString()); if (!packageJson) throw new Error("Failed to parse package.json"); const version = packageJson.version; const checkUpdates = async () => { + if (updateFound) return; + try { - await CheckForUpdate.checkForUpdate(version); + const updateAvailable = await CheckForUpdate.checkForUpdate(version); + if (updateAvailable) { + updateFound = true; + } } catch (err) { log.error("Failed to check for updates"); } diff --git a/package-lock.json b/package-lock.json index aef0611..eeee81a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "reloadbackend", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "reloadbackend", - "version": "1.0.2", + "version": "1.0.3", "license": "GPL-3.0", "dependencies": { "axios": "^1.7.7", diff --git a/package.json b/package.json index cdd9efc..abbf95f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "reloadbackend", - "version": "1.0.2", + "version": "1.0.3", "description": "Created by Burlone, This is a modded backend, all main backend credits to lawin", "main": "index.js", "dependencies": { diff --git a/routes/main.js b/routes/main.js index 11c7cf1..096d39c 100644 --- a/routes/main.js +++ b/routes/main.js @@ -217,8 +217,7 @@ app.post("/api/v1/assets/Fortnite/*/*", async (req, res) => { if (req.body.hasOwnProperty("FortCreativeDiscoverySurface") && req.body.FortCreativeDiscoverySurface == 0) { const discovery_api_assets = require("./../responses/Discovery/discovery_api_assets.json"); res.json(discovery_api_assets) - } - else { + } else { res.json({ "FortCreativeDiscoverySurface": { "meta": { diff --git a/routes/reports.js b/routes/reports.js index 3e6ce6c..b57c119 100644 --- a/routes/reports.js +++ b/routes/reports.js @@ -128,4 +128,4 @@ app.post("/fortnite/api/game/v2/toxicity/account/:unsafeReporter/report/:reporte } }); -module.exports = app; +module.exports = app; \ No newline at end of file diff --git a/structs/checkforupdate.js b/structs/checkforupdate.js index a011179..738e265 100644 --- a/structs/checkforupdate.js +++ b/structs/checkforupdate.js @@ -3,16 +3,44 @@ const fetch = require("node-fetch"); class CheckForUpdate { static async checkForUpdate(currentVersion) { - const packageJson = await fetch('https://raw.githubusercontent.com/Project-Reload/Reload-Backend/refs/heads/main/package.json') - .then(res => res.json()); + try { + const response = await fetch('https://raw.githubusercontent.com/Project-Reload/Reload-Backend/main/package.json'); + if (!response.ok) { + log.error(`Failed to fetch package.json. Status: ${response.status}`); + return false; + } - const latestVersion = packageJson.version.replace(/\./g, ""); - const currentVersionFormatted = currentVersion.replace(/\./g, ""); + const packageJson = await response.json(); + const latestVersion = packageJson.version; - if (parseFloat(latestVersion) > parseFloat(currentVersionFormatted)) { - log.checkforupdate(`A new version of the Backend has been released! ${currentVersion} -> ${packageJson.version}, Download it from the GitHub repo.`); + if (isNewerVersion(latestVersion, currentVersion)) { + log.checkforupdate(`A new version of the Backend has been released! ${currentVersion} -> ${latestVersion}, Download it from the GitHub repo.`); + return true; + } else { + + } + + return false; + } catch (error) { + log.error(`Error while checking for updates: ${error.message}`); + return false; } } } +function isNewerVersion(latest, current) { + const latestParts = latest.split('.').map(Number); + const currentParts = current.split('.').map(Number); + + for (let i = 0; i < latestParts.length; i++) { + if (latestParts[i] > (currentParts[i] || 0)) { + return true; + } else if (latestParts[i] < (currentParts[i] || 0)) { + return false; + } + } + + return false; +} + module.exports = CheckForUpdate; \ No newline at end of file