From d8d75c01e84f7a536ddb3b3123eb74829f4c635d Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 2 Sep 2023 11:40:51 -0400 Subject: [PATCH 1/6] Versioning --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 86a974d..204d3e8 100755 --- a/package.json +++ b/package.json @@ -1,21 +1,21 @@ { "name": "silvanus", - "version": "1.2.8", - "description": "Grow A Tree Companion Bot", + "version": "1.3.0", + "description": "The ultimate Grow A Tree companion bot!", "main": "main.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", - "url": "git+https://github.com/voidf1sh/silvanus.git" + "url": "git+https://git.vfsh.dev/voidf1sh/silvanus.git" }, "author": "Skylar Grant", "license": "ISC", "bugs": { - "url": "https://github.com/voidf1sh/silvanus/issues" + "url": "https://git.vfsh.dev/voidf1sh/silvanus/issues" }, - "homepage": "https://github.com/voidf1sh/silvanus#readme", + "homepage": "https://git.vfsh.dev/voidf1sh/silvanus#readme", "dependencies": { "axios": "^1.4.0", "discord.js": "^14.11.0", -- 2.45.2 From 4f576f9b5d9288a1c77c454c56aa8c3f59710121 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 2 Sep 2023 11:43:05 -0400 Subject: [PATCH 2/6] Updating links --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index de2c534..be3d290 100755 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Silvanus is not affiliated with Grow A Tree or Limbo Labs. [Join Discord Server](https://discord.gg/g5JRGn7PxU) ## Silvanus Support Wiki -Find the most up-to-date guides and information about Silvanus at the [Silvanus Support Wiki](https://silvanus.vfsh.dev/). -[Silvanus Setup Guide](https://silvanus.vfsh.dev/en/setup) +Find the most up-to-date guides and information about Silvanus at the [Silvanus Wiki](https://git.vfsh.dev/voidf1sh/silvanus/wiki). +[Silvanus Setup Guide](https://git.vfsh.dev/voidf1sh/silvanus/wiki/Silvanus-Setup-Guide) -Please find the most up-to-date guides and information at the Silvanus Support Discord Server! \ No newline at end of file +Please find the most up-to-date guides and information at the [Silvanus Support Discord Server](https://discord.gg/g5JRGn7PxU)! \ No newline at end of file -- 2.45.2 From d268f522373f6c280fd5f7dd8864d4714bdf5360 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 2 Sep 2023 19:33:32 -0400 Subject: [PATCH 3/6] Catch errors on message send (Fix #4) --- main.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.js b/main.js index 6727767..8ef9bf1 100755 --- a/main.js +++ b/main.js @@ -69,7 +69,7 @@ client.on('interactionCreate', async interaction => { if (client.slashCommands.has(commandName)) { client.slashCommands.get(commandName).execute(interaction); } else { - interaction.reply('Sorry, I don\'t have access to that command.'); + interaction.reply('Sorry, I don\'t have access to that command.').catch(e => console.err(e)); console.error('Slash command attempted to run but not found: ' + commandName); } } @@ -79,7 +79,7 @@ client.on('interactionCreate', async interaction => { case 'refresh': // console.log(JSON.stringify(interaction)); await fn.refresh(interaction).catch(err => { - interaction.channel.send(fn.builders.errorEmbed("Oops! Something went wrong!")); + interaction.channel.send(fn.builders.errorEmbed("Oops! Something went wrong!")).catch(e => console.err(e)); }); break; case 'deleteping': @@ -103,10 +103,10 @@ client.on('interactionCreate', async interaction => { } } catch(err) { if (err === "Guild doesn't exist in database!") { - interaction.channel.send(fn.builders.errorEmbed(strings.error.noGuild)); + interaction.channel.send(fn.builders.errorEmbed(strings.error.noGuild)).catch(e => console.err(e)); console.error(err); } else { - interaction.channel.send("Oops! An error occurred... Sorry about that, please contact my owner @vfsh if this keeps happening."); + interaction.channel.send("Oops! An error occurred... Sorry about that, please contact my owner @vfsh if this keeps happening.").catch(e => console.err(e)); console.error(err); } } @@ -117,7 +117,7 @@ client.on('messageUpdate', async (oldMessage, message) => { await fn.messages.updateHandler(message).catch(async e => { switch (e) { case strings.error.noCompareMessage: - await message.channel.send(strings.error.noCompareMessage); + await message.channel.send(strings.error.noCompareMessage).catch(e => console.err(e)); break; default: break; -- 2.45.2 From 8538fced377f0e5f340e64968a3dc3be74fd8711 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 2 Sep 2023 19:35:15 -0400 Subject: [PATCH 4/6] Parse next water time from tree message Doesn't do anything yet. --- modules/functions.js | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/modules/functions.js b/modules/functions.js index c10491e..17a054f 100755 --- a/modules/functions.js +++ b/modules/functions.js @@ -615,11 +615,16 @@ const functions = { const indices = [description.indexOf("Your tree is ") + 13, description.indexOf("ft")]; const treeHeightStr = description.slice(indices[0], indices[1]); const treeHeightFloat = parseFloat(treeHeightStr).toFixed(1); + // Grab the tree's water timestamp + const waterTimestampStr = description.match(//g)[0]; + const waterTimestamp = waterTimestampStr.match(/[0-9]+/g); + if (isDev) console.log(`Water Timestamp: ${waterTimestamp}`); // Return the info gathered return { treeName: treeName, - treeHeight: treeHeightFloat + treeHeight: treeHeightFloat, + waterTimestamp: waterTimestamp }; } else { return false; @@ -696,6 +701,7 @@ const functions = { } }, async updateHandler(message) { + // If we don't have the entire message yet, fetch it if (message.partial) { message = await message.fetch().catch(e => { throw e; @@ -706,7 +712,7 @@ const functions = { // Check and store the message types const isLeaderboard = this.isLeaderboard(message); const isTree = this.isTree(message); - // Check if the message is a leaderboard + // Check if the message is a leaderboard and handle the update if (isLeaderboard) { if (isDev) console.log(`LU: ${message.guild.name}`); let guildInfo; @@ -762,26 +768,35 @@ const functions = { const comparedRankings = await functions.rankings.compare(guildInfo); const embed = functions.builders.comparisonEmbed(comparedRankings, guildInfo); await compareMessage.edit(embed).catch(e => console.error(e)); - } else if (isTree) { - // Check if the message is a tree - // if (isDev) console.log(`TU: ${isTree.treeName}: ${isTree.treeHeight}ft`); + } else if (isTree) { // Check if the message is a tree + if (isDev) console.log(`TU: ${isTree.treeName}: ${isTree.treeHeight}ft`); let guildInfo; + // Default to not updating the database let doDbUpdate = false; + // Check if the bot has the guildInfo for this Guild already if (message.client.guildInfos.has(message.guildId)) { guildInfo = message.client.guildInfos.get(message.guildId); + // If the name or height has changed, update the guildInfo and flag to run a database update if ((guildInfo.treeName != isTree.treeName) || (guildInfo.treeHeight != isTree.treeHeight)) { guildInfo.setTreeInfo(isTree.treeName, isTree.treeHeight, message.channel.id, message.id); doDbUpdate = true; } - } else { + // If the waterTimestamp has changed, update the database + // TODO... lost motivation + } else { // If the bot doesn't have a guildInfo for the Guild, we will create one for it and flag a database update guildInfo = new GuildInfo().setIds(message.guildId, message.guild.ownerId) .setTreeInfo(isTree.treeName, isTree.treeHeight, message.channel.id, message.id); doDbUpdate = true; } + // If the database update flag is set, update the database and rebuild the guildInfo collection + // TODO: This should likely only update the relevant guildInfo in the future. + // Actually, rebuilding the collection should be unnecessary, since it's already been updated. if (doDbUpdate) { const query = guildInfo.queryBuilder("setTreeInfo"); await dbfn.setGuildInfo(query); - await functions.collectionBuilders.guildInfos(message.client); + // I've commented this out to see if it breaks anything. + // Rebuilding shouldn't be necessary and is a waste of resources. + // await functions.collectionBuilders.guildInfos(message.client); } } } -- 2.45.2 From f8707a2b6f859a52c6f33943ee62604a8689b8a1 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 2 Sep 2023 21:12:28 -0400 Subject: [PATCH 5/6] Update in-bot documentation --- data/strings.json | 6 ++++-- modules/functions.js | 13 ++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/data/strings.json b/data/strings.json index 09723f3..f60e5c7 100755 --- a/data/strings.json +++ b/data/strings.json @@ -5,10 +5,12 @@ "help": { "title": "Silvanus Help", "aboutTitle": "About Silvanus", - "info": "Silvanus is the ultimate companion bot designed for Grow A Tree, the popular Discord clicker game. With Silvanus by your side, you can take your tree-growing adventure to new heights! Enjoy customizable notifications, effortless tree height comparisons, and handy math features to optimize your gameplay.\n\n[Privacy Policy](https://assets.vfsh.dev/privacy.txt)", + "aboutDescription": "Silvanus is a dedicated companion bot designed for Grow A Tree, the popular Discord clicker game. With Silvanus by your side, you can take your tree-growing adventure to new heights! Enjoy customizable notifications, effortless tree height comparisons, and handy math features to optimize your gameplay. Join over 130 servers already benefiting from Silvanus and make your Grow A Tree experience even more exciting!", + "aboutLinks": "**Links**\n* [Website](https://silvanus.vfsh.dev)\n* [Wiki](https://git.vfsh.dev/voidf1sh/silvanus/wiki)\n* [Git Repo](https://git.vfsh.dev/voidf1sh/silvanus)\n* [Support Server](https://discord.gg/g5JRGn7PxU)\n* [Top.gg](https://top.gg/bot/521624335119810561)\n* [Privacy Policy](https://assets.vfsh.dev/privacy.txt)\n* [Terms of Use](https://www.termsfeed.com/live/5e192b88-ece7-4ba3-8b50-7a1f997d781a)", + "info": "Silvanus is the ultimate companion bot designed for Grow A Tree, the popular Discord clicker game. With Silvanus by your side, you can take your tree-growing adventure to new heights! Enjoy customizable notifications, effortless tree height comparisons, and handy math features to optimize your gameplay.", "topggTitle": "Want to support Silvanus?", "topggBody": "Vote and leave a review for Silvanus [on Top.gg](https://top.gg/bot/521624335119810561)", - "setup": "For the most up to date guides and information, check out the Silvanus Support Wiki - https://silvanus.vfsh.dev/\n[Silvanus Setup Guide](https://silvanus.vfsh.dev/en/setup)\n\nNeed help and can't reach me on Discord? Send an email to SilvanusDev@gmail.com and I'll get back to you ASAP.", + "setup": "For the most up to date guides and information, check out the [Silvanus Support Wiki](https://git.vfsh.dev/voidf1sh/silvanus/wiki)\n\nNeed help and can't reach me on Discord? Send an email to `sky@vfsh.dev` and I'll get back to you ASAP.", "longDescription": "Silvanus, the ultimate companion bot for Grow A Tree, takes your tree-growing journey to the next level. Are you tired of cluttered channels filled with notifications? Silvanus has you covered! With its unique notification relay system, Silvanus listens for Grow A Tree's notifications in a hidden channel and sends customized, auto-deleting notifications to the channels of your choice. Customize your notifications and keep your server clean and organized.\n\nSilvanus simplifies leaderboard tree height comparisons with a simple command. No more manual calculations or guesswork. Silvanus shows you exactly how far you are from the next tree on the leaderboard, allowing you to gauge your progress effortlessly.", "allCommands": " - Compare your tree to others on the leaderboard\n - Setup a Notification Relay for the first time\n - Update an already configured Notification Relay\n - Disable the Notification Relay\n - Send a self-assignable role menu for relay pings\n - Calculates the time between waters for a tree of a given height\n - Calculates how long it would take a tree to grow to a given height\n - Set the channels to use with \n - View your server's configuration\n - Delete your server's configuration\n - Displays the bot's help page" }, diff --git a/modules/functions.js b/modules/functions.js index 17a054f..f7e2cc9 100755 --- a/modules/functions.js +++ b/modules/functions.js @@ -99,6 +99,12 @@ const functions = { await dbfn.setGuildInfo(query); await functions.collectionBuilders.guildInfos(client); console.log("Disabled notification relay for a guild I'm no longer in: " + guildInfo.guildId); + } else if (e === "ERRNOCHANNEL") { + guildInfo.setReminders(undefined, undefined, undefined, undefined, false); + const query = guildInfo.queryBuilder("setReminders"); + await dbfn.setGuildInfo(query); + await functions.collectionBuilders.guildInfos(client); + console.log("Disabled notification relay for a channel I no longer see: " + guildInfo.watchChannelId); } else { throw e; } @@ -229,11 +235,8 @@ const functions = { const embed = new EmbedBuilder() .setColor(strings.embeds.color) .setTitle(strings.help.aboutTitle) - .setDescription(`${strings.help.info}\n\n${strings.help.longDescription}`) + .setDescription(`${strings.help.aboutDescription}\n\n${strings.help.aboutLinks}`) .setFooter({ text: `v${package.version} - ${strings.embeds.footer}` }); - embed.addFields([ - { name: strings.help.topggTitle, value: strings.help.topggBody} - ]); const privateBool = private == 'true'; const messageContents = { embeds: [embed], ephemeral: privateBool }; return messageContents; @@ -882,7 +885,7 @@ const functions = { throw "ERRNOGUILD" }); // Fetch the Channel - const channel = await guild.channels.fetch(guildInfo.watchChannelId); + const channel = await guild.channels.fetch(guildInfo.watchChannelId).catch(e => { throw "ERRNOCHANNEL" }); // Create the filter function const filter = message => { // Discard any messages sent by Silvanus -- 2.45.2 From cfcbbbfe4384efce1f499f1b142ad1afc8326c5b Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 2 Sep 2023 21:13:07 -0400 Subject: [PATCH 6/6] Update to accomodate all .env files --- .dockerignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 163b5f6..9130ce6 100755 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,3 @@ node_modules npm-debug.log -env.dev -env.prod -.env \ No newline at end of file +.env* \ No newline at end of file -- 2.45.2