diff --git a/README.md b/README.md index 12195de..7ef5c94 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ This guide will assume you've left `app` in `src` (the way it should be). | Version | Release Date | | ------- | ------------ | | 5.0.0 | 3/10/2022 | +| 5.0.1 | 3/15/2022 | ## Contributing Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. diff --git a/src/app/cfg/app.js b/src/app/cfg/app.js index bff5308..036fbe6 100644 --- a/src/app/cfg/app.js +++ b/src/app/cfg/app.js @@ -15,8 +15,8 @@ const app = { version: { major: 5, minor: 0, - revision: 0, - buildType: "A", + revision: 1, + buildType: "R", toString: function() { var major = app.version.major, minor = app.version.minor, @@ -590,4 +590,4 @@ const app = { ] } -module.exports = app; +module.exports = app; \ No newline at end of file diff --git a/src/app/cmds/General/userinfo.js b/src/app/cmds/General/userinfo.js index fb5fe54..f3675c1 100644 --- a/src/app/cmds/General/userinfo.js +++ b/src/app/cmds/General/userinfo.js @@ -29,7 +29,6 @@ module.exports = { user.tag = `${user.username}#${user.discriminator}`; // Manually add this so it looks cool var embed = { - thumbnail: { url: `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.${app.functions.isAnimated(user.avatar) ? "gif": "png"}?size=1024` }, title: `${app.config.system.emotes.information} **${user.tag} ${(user.bot ? "*[BOT]*" : "")}**`, color: (user["accent_color"]) ? user["accent_color"] : app.config.system.embedColors.blue, fields: [ @@ -40,6 +39,12 @@ module.exports = { ] }; + if (user.avatar != null) + embed["thumbnail"] = { url: `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}.${app.functions.isAnimated(user.avatar) ? "gif": "png"}?size=1024` }; + else + embed["thumbnail"] = { url: `https://cdn.discordapp.com/embed/avatars/${user.discriminator % 5}.png?size=1024` }; + + if (user.banner != null) embed["image"] = { url: `https://cdn.discordapp.com/banners/${user.id}/${user.banner}.${app.functions.isAnimated(user.banner) ? "gif": "png"}?size=600` }; diff --git a/src/app/cmds/Moderation/config.js b/src/app/cmds/Moderation/config.js index 87e6498..fdcc1a5 100644 --- a/src/app/cmds/Moderation/config.js +++ b/src/app/cmds/Moderation/config.js @@ -325,15 +325,15 @@ module.exports = { msgCollector.stop("cancelled by user"); m.react(app.config.system.emotes.success).catch(err => {}); } else if (m.content == "next") { - var tmpContent = JSON.parse(serverSettings.get("other")[val]) || { msg: defaults[val][msg], channel: null }; + var tmpContent = (serverSettings.get("other")[val]) ? JSON.parse(serverSettings.get("other")[val]) || { msg: defaults[val]["msg"], channel: null } : { msg: defaults[val]["msg"], channel: null }; if (tmpContent["msg"]) { msgCollector.stop("done"); - await collectJoinLeaveChannel(val, null); + await collectJoinLeaveChannel(val, tmpContent); m.react(app.config.system.emotes.success).catch(err => {}); } else m.react(app.config.system.emotes.error).catch(err => {}); } else { msgCollector.stop("done"); - var tmpContent = { msg: m.content || defaults[val][msg], channel: null }; + var tmpContent = { msg: m.content || defaults[val]["msg"], channel: null }; await collectJoinLeaveChannel(val, tmpContent); m.react(app.config.system.emotes.success).catch(err => {}); } @@ -432,7 +432,7 @@ module.exports = { embeds: [{ title: `${app.config.system.emotes.success} Configure ${app.name}`, color: app.config.system.embedColors.lime, - description: `Woohoo! We're done here!\nYour ${evtType} message & channel are both ready to go!` + description: `Woohoo! We're done here!\nYour ${evtType} message & channel are both ready to go!\n\n\`${evtData["msg"]}\`` }], components: [], author: message.author diff --git a/src/app/cmds/Owner/botcontrols.js b/src/app/cmds/Owner/botcontrols.js index 014cd4d..0203548 100644 --- a/src/app/cmds/Owner/botcontrols.js +++ b/src/app/cmds/Owner/botcontrols.js @@ -29,7 +29,7 @@ module.exports = { title: `${app.config.system.emotes.warning} **${type}**`, color: app.config.system.embedColors.yellow, fields: [ - { name: `Are you sure you wish for me to ${type}?`, value: `To confirm, use the buttons.${((type == "Restart") ? "\n*This will not reload the main bot file.*" : "")}` } + { name: `Are you sure you wish for me to ${type}?`, value: `To confirm, use the buttons.` } ] }], components: [row] @@ -51,10 +51,9 @@ module.exports = { }, 1, true, (async() => { app.logger.debug("SYS", `${app.name} ${actionDoing.toLowerCase()} as of ${new Date()}.`); if (type == "Restart") { - await process.exitHandler({ app: app, cleanup: true, exit: false }, 0); + try { app.modules.fs.writeFileSync(process.cwd() + "/cache/restart.tmp", msg.channel.id + "-" + msg.id); } catch (Ex) {}; + await process.exitHandler({ app: app, cleanup: true, exit: false, restart: true }, 0); - await app.functions.clearCache(); - await app.botStart(msg.channel.id + "-" + msg.id); } else { process.exitHandler({ app: app, cleanup: true, exit: true }, 0); }; })); denied = false, buttonStuffWaiting = false; diff --git a/src/app/evts/channelCreate.js b/src/app/evts/channelCreate.js index d7a4499..ce60bec 100644 --- a/src/app/evts/channelCreate.js +++ b/src/app/evts/channelCreate.js @@ -31,7 +31,7 @@ module.exports = async(app, newChannel) => { //define channelLog const channelLog = fetchedLogs.entries.find(entry => // To avoid false positives, we look for a timeframe of when the channel was created. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 ); if (channelLog) { const { executor } = channelLog; diff --git a/src/app/evts/channelDelete.js b/src/app/evts/channelDelete.js index 13a859b..146f9ad 100644 --- a/src/app/evts/channelDelete.js +++ b/src/app/evts/channelDelete.js @@ -30,7 +30,7 @@ module.exports = async(app, oldChannel) => { if (fetchedLogs) { //define channelLog const channelLog = fetchedLogs.entries.find(entry => // To avoid false positives, we look for a timeframe of when the channel was deleted. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 ); if (channelLog) { const { executor } = channelLog; diff --git a/src/app/evts/channelUpdate.js b/src/app/evts/channelUpdate.js index 59ec311..5f46808 100644 --- a/src/app/evts/channelUpdate.js +++ b/src/app/evts/channelUpdate.js @@ -49,7 +49,7 @@ module.exports = async(app, oldChannel, newChannel) => { //define channelLog const channelLog = fetchedLogs.entries.find(entry => // To avoid false positives, we look for a timeframe of when the channel was updated. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 ); if (channelLog) { const { executor } = channelLog; diff --git a/src/app/evts/emojiCreate.js b/src/app/evts/emojiCreate.js index 7e4b525..6eda9a4 100644 --- a/src/app/evts/emojiCreate.js +++ b/src/app/evts/emojiCreate.js @@ -31,7 +31,7 @@ module.exports = async(app, newEmoji) => { //define emojiLog const emojiLog = fetchedLogs.entries.find(entry => // To avoid false positives, we look for a timeframe of when the emoji was created. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 ); if (emojiLog) { const { executor } = emojiLog; diff --git a/src/app/evts/emojiDelete.js b/src/app/evts/emojiDelete.js index 235d067..b2d6901 100644 --- a/src/app/evts/emojiDelete.js +++ b/src/app/evts/emojiDelete.js @@ -31,7 +31,7 @@ module.exports = async(app, oldEmoji) => { //define emojiLog const emojiLog = fetchedLogs.entries.find(entry => // To avoid false positives, we look for a timeframe of when the emoji was created. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 ); if (emojiLog) { const { executor } = emojiLog; diff --git a/src/app/evts/emojiUpdate.js b/src/app/evts/emojiUpdate.js index 832a75c..b24d3f2 100644 --- a/src/app/evts/emojiUpdate.js +++ b/src/app/evts/emojiUpdate.js @@ -41,7 +41,7 @@ module.exports = async(app, oldEmoji, newEmoji) => { //define emojiLog const emojiLog = fetchedLogs.entries.find(entry => // To avoid false positives, we look for a timeframe of when the emoji was updated. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 ); if (emojiLog) { const { executor } = emojiLog; diff --git a/src/app/evts/guildBanAdd.js b/src/app/evts/guildBanAdd.js index ff21cb2..52c9410 100644 --- a/src/app/evts/guildBanAdd.js +++ b/src/app/evts/guildBanAdd.js @@ -33,7 +33,7 @@ module.exports = async(app, ban) => { //define banLog const banLog = fetchedLogs.entries.find(entry => { // To avoid false positives, we look for a timeframe of when the ban was created, and if the user banned is the correct entry. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 }); if (banLog) { const { executor } = banLog; diff --git a/src/app/evts/guildBanRemove.js b/src/app/evts/guildBanRemove.js index 074641a..58ddc20 100644 --- a/src/app/evts/guildBanRemove.js +++ b/src/app/evts/guildBanRemove.js @@ -33,7 +33,7 @@ module.exports = async(app, ban) => { //define banLog const banLog = fetchedLogs.entries.find(entry => { // To avoid false positives, we look for a timeframe of when the ban was created, and if the user banned is the correct entry. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 }); if (banLog) { const { executor } = banLog; diff --git a/src/app/evts/guildMemberRemove.js b/src/app/evts/guildMemberRemove.js index 0a9c92a..c383717 100644 --- a/src/app/evts/guildMemberRemove.js +++ b/src/app/evts/guildMemberRemove.js @@ -35,7 +35,7 @@ module.exports = async(app, oldMember) => { //define kickLog const kickLog = fetchedLogs.entries.find(entry => { // To avoid false positives, we look for a timeframe of when the ban was created, and if the user banned is the correct entry. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 }); if (kickLog) { const { executor } = kickLog; diff --git a/src/app/evts/guildMemberUpdate.js b/src/app/evts/guildMemberUpdate.js index 34a4a1d..feeb201 100644 --- a/src/app/evts/guildMemberUpdate.js +++ b/src/app/evts/guildMemberUpdate.js @@ -42,7 +42,7 @@ module.exports = async(app, oldMember, newMember) => { else if (oldMember.roles.cache.size < newMember.roles.cache.size) embed.fields.push({ name: "Roles Added", value: roleUpdated.join(", ") || "Failed to get roles added" }); // ooo features }; - if (!embed.fields.length > 3) return; // Since we aren't subscribing to all updates, stop here if it was something else non-related to what we have. + if (embed.fields.length < 3) return; // Since we aren't subscribing to all updates, stop here if it was something else non-related to what we have. embed.fields.push({ name: "Updated At", value: new Date().toString() }) @@ -53,7 +53,7 @@ module.exports = async(app, oldMember, newMember) => { //define memberLog const memberLog = fetchedLogs.entries.filter(e => e.action === "MEMBER_UPDATE" || e.action === "MEMBER_ROLE_UPDATE").find(entry => // To avoid false positives, we look for a timeframe of when the member was updated. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 ); if (memberLog) { const { executor } = memberLog; diff --git a/src/app/evts/guildUpdate.js b/src/app/evts/guildUpdate.js index 2129dca..0de5636 100644 --- a/src/app/evts/guildUpdate.js +++ b/src/app/evts/guildUpdate.js @@ -87,7 +87,7 @@ module.exports = async(app, oldGuild, newGuild) => { //define guildLog const guildLog = fetchedLogs.entries.find(entry => // To avoid false positives, we look for a timeframe of when the guild was updated. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 ); if (guildLog) { const { executor } = guildLog; diff --git a/src/app/evts/messageDelete.js b/src/app/evts/messageDelete.js index b24efa2..5c1e0a9 100644 --- a/src/app/evts/messageDelete.js +++ b/src/app/evts/messageDelete.js @@ -38,9 +38,9 @@ module.exports = async(app, message) => { }).catch(err => {}); if (fetchedLogs) { const deleteLog = fetchedLogs.entries.find(entry => // To avoid false positives, we sort by message author, message channel, and a timeframe of when the message was deleted. - (message.author) ? entry.executor.id !== message.author.id : true && + ((message.author) ? entry.executor.id !== message.author.id : true) && entry.extra.channel.id === message.channel.id && - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 ); if (deleteLog) { // If none, we may be missing permissions to fetch audit log. const { executor } = deleteLog; diff --git a/src/app/evts/ready.js b/src/app/evts/ready.js index 3fcd363..8b46566 100644 --- a/src/app/evts/ready.js +++ b/src/app/evts/ready.js @@ -1,4 +1,6 @@ module.exports = (app) => { + if (!app.client) return app.logger.error("SYS", "CLIENT IS NOT READY YET!!"); + app.config["tokendata"] = undefined; // This makes it so no crazy people can find the token (tho, the only way is through eval and uh.. you should keep that to yourself..) // app.client.connections.success = true; // clearInterval(client.connections.updateTime); @@ -41,7 +43,7 @@ module.exports = (app) => { setTimeout(async function() { // Reaction Roles - app.logger.info("DISCORD", `Initializing Reaction Roles...`); + if (app.client.isReady()) app.logger.info("DISCORD", `Initializing Reaction Roles...`); var serverSettings = await app.DBs.serverSettings.findAll({ where: {}, raw: true }); // WARNING: Do not expose this variable. for (server in serverSettings) { server = serverSettings[server]; @@ -78,25 +80,40 @@ module.exports = (app) => { // Cache invites app.logger.info("DISCORD", `Caching all invites of ${app.client.guilds.cache.size} servers...`); - var inviteCount = 0; - await app.client.guilds.cache.forEach(async guild => { - try { - if (!guild) return; - if (guild.partial) await guild.fetch().catch(err => app.logger.error("DISCORD", "Something went wrong while fetching the guild " + guild.id + " | " + err.message)); + var inviteCount = 0, + serverCount = 0, + done = false, + guilds = Array.from(app.client.guilds.cache.keys()); + + for (var i = 0; i < guilds.length; i++) { + const guild = app.client.guilds.cache.get(guilds[i]); + + // check guild existence, etc. + if (!guild) break; + if (guild.partial) await guild.fetch().catch(err => app.logger.error("DISCORD", "Something went wrong while fetching the guild " + guild.id + " | " + err.message)); + + if (i != 0 && (i % 15) == 0) + await app.functions.sleep(1500); + + // try to get invites + try { const firstInvites = await guild.invites.fetch(); app.client.guildInvites.set(guild.id, new Map(firstInvites.map((invite) => [invite.code, invite.uses]))); app.logger.debug("DISCORD", `Cached ${firstInvites.size} invites from ${guild.id}.`); inviteCount += firstInvites.size; + serverCount = (serverCount + 1); } catch (err) { if (err.code !== app.modules["discord.js"].Constants.APIErrors.MISSING_PERMISSIONS) { app.logger.error("DISCORD", `Failed to cache invites for ${guild.name} (${guild.id}) | ${err.message}.`); }; - return; + } finally { + if ((i + 1) === guilds.length) + done = true; }; - }); - setTimeout(async function() { app.logger.success("DISCORD", `Cached ${inviteCount} invites from ${app.client.guildInvites.size} servers.`); }, (app.client.guilds.cache.size / 2) * 100); - + }; + while (!done) await app.functions.sleep(1500); + app.logger.success("DISCORD", `Cached ${inviteCount} invites from ${((serverCount == app.client.guilds.cache.size) ? serverCount : serverCount + "/" + app.client.guilds.cache.size)} servers.`); }, 3500); // Wait an addition 3.5 seconds }, 2000); diff --git a/src/app/evts/roleCreate.js b/src/app/evts/roleCreate.js index ee5bfaf..e6d8497 100644 --- a/src/app/evts/roleCreate.js +++ b/src/app/evts/roleCreate.js @@ -34,7 +34,7 @@ module.exports = async(app, newRole) => { //define roleLog const roleLog = fetchedLogs.entries.find(entry => // To avoid false positives, we look for a timeframe of when the role was created. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 ); if (roleLog) { const { executor } = roleLog; diff --git a/src/app/evts/roleDelete.js b/src/app/evts/roleDelete.js index fcdce49..b2988bf 100644 --- a/src/app/evts/roleDelete.js +++ b/src/app/evts/roleDelete.js @@ -31,7 +31,7 @@ module.exports = async(app, oldRole) => { //define roleLog const roleLog = fetchedLogs.entries.find(entry => // To avoid false positives, we look for a timeframe of when the role was deleted. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 ); if (roleLog) { const { executor } = roleLog; diff --git a/src/app/evts/roleUpdate.js b/src/app/evts/roleUpdate.js index 7c5daea..f405194 100644 --- a/src/app/evts/roleUpdate.js +++ b/src/app/evts/roleUpdate.js @@ -67,7 +67,7 @@ module.exports = async(app, oldRole, newRole) => { //define roleLog const roleLog = fetchedLogs.entries.find(entry => // To avoid false positives, we look for a timeframe of when the role was updated. - Date.now() - entry.createdTimestamp < 20000 + Date.now() - entry.createdTimestamp < 5000 ); if (roleLog) { const { executor } = roleLog; diff --git a/src/app/functions/bootloader.js b/src/app/functions/bootloader.js index 92f8c89..af14701 100644 --- a/src/app/functions/bootloader.js +++ b/src/app/functions/bootloader.js @@ -195,16 +195,21 @@ class BootLoader { verification: app.db.define('verification', { serverID: { // The executing server type: Sequelize.STRING, - primaryKey: true + defaultValue: null, + unique: false }, userID: { // The executing user type: Sequelize.STRING, defaultValue: null, - allowNull: true + allowNull: true, + unique: true, + primaryKey: true + }, messageID: { // Allows us to edit the same message (if in a server) type: Sequelize.STRING, defaultValue: null, + unique: true, allowNull: true }, userCode: { // The code generated @@ -329,4 +334,4 @@ class BootLoader { } -module.exports = BootLoader; +module.exports = BootLoader; \ No newline at end of file diff --git a/src/bot.js b/src/bot.js index 4e684ea..33012b6 100644 --- a/src/bot.js +++ b/src/bot.js @@ -14,7 +14,7 @@ var logger; process.waitingForCleanup = false; -async function bot(debug, lastMessageID = null) { +async function bot(debug) { // ========== PRE-BOOT @@ -22,37 +22,6 @@ async function bot(debug, lastMessageID = null) { if (debug) console.log("- PRE-BOOT"); if (debug) console.log(` -- App is starting as of ${new Date(startTime).toString()} -- `); - // Change directory - try { - if (process.cwd().split("\\").slice(-1) != "src") // attempt to change into 'src' - process.chdir(process.cwd() + "/src"); - } catch (Ex) {}; // Assume it's okay to continue. - - // Do our require - if (debug) console.log("-> Init: Bootloader"); - const BootLoader = require("./app/functions/bootloader.js"); - const bootloader = new BootLoader(); - await bootloader.printLogo(); // Print that healthy logo. Logo got back - - - if (debug) console.log("-> Init: Logger"); - const Log = require("./app/functions/logger.js"); - if (debug) console.log("-> Start: Logging"); - logger = new Log(); - logger.info("SYS", `Logging is now enabled!`); - - await logger.warnAboutDebug(debug); // warn about debugging (if it applies) - - if (debug) console.log("-> Init: App"); - const app = require("./app/cfg/app.js"); - app.debugMode = debug; - app.logger = logger; - app.bootloader = bootloader; - app.startTime = startTime; - app.botStart = (lastMessage) => bot(debug, lastMessage); - if (lastMessageID != null) app.lastMessageID = lastMessageID; - logger.info("SYS", `App core successfully loaded!`); - async function exitHandler(options, exitCode) { // if (process.waitingForCleanup) return; // stops from trying to keep process a million times @@ -124,6 +93,18 @@ async function bot(debug, lastMessageID = null) { }; process.waitingForCleanup = false; + + if (options.restart) { + require("child_process") + .spawn( + process.argv.shift(), + process.argv, { + cwd: process.cwd(), + detached: true, + stdio: "inherit" + } + ); + }; }; process.waitingForCleanupTM = setInterval(function() { @@ -146,12 +127,6 @@ async function bot(debug, lastMessageID = null) { // Kinda dumb how I had to shove it into the bot function but it's whatever. process.stdin.resume(); // Let's not close immediately, thanks. - process.once('exit', exitHandler.bind(null, { cleanup: true, exit: true })); // Let's catch the app before it exits. - process.once('SIGINT', exitHandler.bind(null, { app: app, exit: true, cleanup: true })); // Let's catch CTRL+C. - // catches "kill pid" (for example: nodemon restart) - process.once('SIGUSR1', exitHandler.bind(null, { exit: true })); - process.once('SIGUSR2', exitHandler.bind(null, { exit: true })); - process.on('uncaughtException', error => { const errreason = new Error(error.message); const errstack = ` Caused By:\n ${error.stack}`; @@ -172,6 +147,45 @@ async function bot(debug, lastMessageID = null) { else console.log(`[i] [SYS] ${msg}`); }); // Catch all them nasty unhandledRejection errors :/ + + + // Change directory + try { + if (process.cwd().split("\\").slice(-1) != "src") // attempt to change into 'src' + process.chdir(process.cwd() + "/src"); + } catch (Ex) {}; // Assume it's okay to continue. + + // Do our require + if (debug) console.log("-> Init: Bootloader"); + const BootLoader = require("./app/functions/bootloader.js"); + const bootloader = new BootLoader(); + await bootloader.printLogo(); // Print that healthy logo. Logo got back + + + if (debug) console.log("-> Init: Logger"); + const Log = require("./app/functions/logger.js"); + if (debug) console.log("-> Start: Logging"); + logger = new Log(); + logger.info("SYS", `Logging is now enabled!`); + + await logger.warnAboutDebug(debug); // warn about debugging (if it applies) + + if (debug) console.log("-> Init: App"); + const app = require("./app/cfg/app.js"); + app.debugMode = debug; + app.logger = logger; + app.bootloader = bootloader; + app.startTime = startTime; + logger.info("SYS", `App core successfully loaded!`); + + process.once('exit', exitHandler.bind(null, { cleanup: true, exit: true })); // Let's catch the app before it exits. + process.once('SIGINT', exitHandler.bind(null, { app: app, exit: true, cleanup: true })); // Let's catch CTRL+C. + process.once('SIGTERM', exitHandler.bind(null, { app: app, exit: true, cleanup: true })); + // catches "kill pid" (for example: nodemon restart) + process.once('SIGUSR1', exitHandler.bind(null, { exit: true, cleanup: true })); + process.once('SIGUSR2', exitHandler.bind(null, { exit: true, cleanup: true })); + + if (debug) console.log("-> Init: Dependencies"); const dependencies = app["dependencies"]; if (debug) console.log(` > Dependencies: ${dependencies.length}`); @@ -198,7 +212,7 @@ async function bot(debug, lastMessageID = null) { if (debug) console.log("-> Init: Discord Client..."); - const { Client, Intents } = app.modules["discord.js"]; + const { Client } = app.modules["discord.js"]; const client = new Client({ partials: ["MESSAGE", "CHANNEL", "REACTION", "GUILD_MEMBER", "USER"], intents: 32767 // btw, this forces discord.js to do ALL intents. not recommended. @@ -207,6 +221,15 @@ async function bot(debug, lastMessageID = null) { if (debug) console.log(` > New Discord Client created.`); + if (debug) console.log("-> Check: If Restarted..."); + lastMessageID = null; + try { lastMessageID = await app.modules.fs.readFileSync(process.cwd() + "/cache/restart.tmp", "utf8"); } catch (Ex) {}; + if (lastMessageID != null) app.lastMessageID = lastMessageID; + try { app.modules.fs.unlinkSync(process.cwd() + "/cache/restart.tmp"); } catch (Ex) {}; + + if (debug) console.log(` > Cheked If Restart completed.`); + + if (debug) console.log("-> Init: Extras"); const extras = await require('./app/extras/extras.json'); // this is probably inefficent, but it works ig app.extras = {};