Compare commits
No commits in common. "8538fced377f0e5f340e64968a3dc3be74fd8711" and "36f44f4b4190bae58854610264365d9e4c61802a" have entirely different histories.
8538fced37
...
36f44f4b41
@ -10,7 +10,7 @@ Silvanus is not affiliated with Grow A Tree or Limbo Labs.
|
|||||||
[Join Discord Server](https://discord.gg/g5JRGn7PxU)
|
[Join Discord Server](https://discord.gg/g5JRGn7PxU)
|
||||||
|
|
||||||
## Silvanus Support Wiki
|
## Silvanus Support Wiki
|
||||||
Find the most up-to-date guides and information about Silvanus at the [Silvanus Wiki](https://git.vfsh.dev/voidf1sh/silvanus/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://git.vfsh.dev/voidf1sh/silvanus/wiki/Silvanus-Setup-Guide)
|
[Silvanus Setup Guide](https://silvanus.vfsh.dev/en/setup)
|
||||||
|
|
||||||
Please find the most up-to-date guides and information at the [Silvanus Support Discord Server](https://discord.gg/g5JRGn7PxU)!
|
Please find the most up-to-date guides and information at the Silvanus Support Discord Server!
|
10
main.js
10
main.js
@ -69,7 +69,7 @@ client.on('interactionCreate', async interaction => {
|
|||||||
if (client.slashCommands.has(commandName)) {
|
if (client.slashCommands.has(commandName)) {
|
||||||
client.slashCommands.get(commandName).execute(interaction);
|
client.slashCommands.get(commandName).execute(interaction);
|
||||||
} else {
|
} else {
|
||||||
interaction.reply('Sorry, I don\'t have access to that command.').catch(e => console.err(e));
|
interaction.reply('Sorry, I don\'t have access to that command.');
|
||||||
console.error('Slash command attempted to run but not found: ' + commandName);
|
console.error('Slash command attempted to run but not found: ' + commandName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ client.on('interactionCreate', async interaction => {
|
|||||||
case 'refresh':
|
case 'refresh':
|
||||||
// console.log(JSON.stringify(interaction));
|
// console.log(JSON.stringify(interaction));
|
||||||
await fn.refresh(interaction).catch(err => {
|
await fn.refresh(interaction).catch(err => {
|
||||||
interaction.channel.send(fn.builders.errorEmbed("Oops! Something went wrong!")).catch(e => console.err(e));
|
interaction.channel.send(fn.builders.errorEmbed("Oops! Something went wrong!"));
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'deleteping':
|
case 'deleteping':
|
||||||
@ -103,10 +103,10 @@ client.on('interactionCreate', async interaction => {
|
|||||||
}
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
if (err === "Guild doesn't exist in database!") {
|
if (err === "Guild doesn't exist in database!") {
|
||||||
interaction.channel.send(fn.builders.errorEmbed(strings.error.noGuild)).catch(e => console.err(e));
|
interaction.channel.send(fn.builders.errorEmbed(strings.error.noGuild));
|
||||||
console.error(err);
|
console.error(err);
|
||||||
} else {
|
} else {
|
||||||
interaction.channel.send("Oops! An error occurred... Sorry about that, please contact my owner @vfsh if this keeps happening.").catch(e => console.err(e));
|
interaction.channel.send("Oops! An error occurred... Sorry about that, please contact my owner @vfsh if this keeps happening.");
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ client.on('messageUpdate', async (oldMessage, message) => {
|
|||||||
await fn.messages.updateHandler(message).catch(async e => {
|
await fn.messages.updateHandler(message).catch(async e => {
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case strings.error.noCompareMessage:
|
case strings.error.noCompareMessage:
|
||||||
await message.channel.send(strings.error.noCompareMessage).catch(e => console.err(e));
|
await message.channel.send(strings.error.noCompareMessage);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -615,16 +615,11 @@ const functions = {
|
|||||||
const indices = [description.indexOf("Your tree is ") + 13, description.indexOf("ft")];
|
const indices = [description.indexOf("Your tree is ") + 13, description.indexOf("ft")];
|
||||||
const treeHeightStr = description.slice(indices[0], indices[1]);
|
const treeHeightStr = description.slice(indices[0], indices[1]);
|
||||||
const treeHeightFloat = parseFloat(treeHeightStr).toFixed(1);
|
const treeHeightFloat = parseFloat(treeHeightStr).toFixed(1);
|
||||||
// Grab the tree's water timestamp
|
|
||||||
const waterTimestampStr = description.match(/<t:[0-9]+:R>/g)[0];
|
|
||||||
const waterTimestamp = waterTimestampStr.match(/[0-9]+/g);
|
|
||||||
if (isDev) console.log(`Water Timestamp: ${waterTimestamp}`);
|
|
||||||
|
|
||||||
// Return the info gathered
|
// Return the info gathered
|
||||||
return {
|
return {
|
||||||
treeName: treeName,
|
treeName: treeName,
|
||||||
treeHeight: treeHeightFloat,
|
treeHeight: treeHeightFloat
|
||||||
waterTimestamp: waterTimestamp
|
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -701,7 +696,6 @@ const functions = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async updateHandler(message) {
|
async updateHandler(message) {
|
||||||
// If we don't have the entire message yet, fetch it
|
|
||||||
if (message.partial) {
|
if (message.partial) {
|
||||||
message = await message.fetch().catch(e => {
|
message = await message.fetch().catch(e => {
|
||||||
throw e;
|
throw e;
|
||||||
@ -712,7 +706,7 @@ const functions = {
|
|||||||
// Check and store the message types
|
// Check and store the message types
|
||||||
const isLeaderboard = this.isLeaderboard(message);
|
const isLeaderboard = this.isLeaderboard(message);
|
||||||
const isTree = this.isTree(message);
|
const isTree = this.isTree(message);
|
||||||
// Check if the message is a leaderboard and handle the update
|
// Check if the message is a leaderboard
|
||||||
if (isLeaderboard) {
|
if (isLeaderboard) {
|
||||||
if (isDev) console.log(`LU: ${message.guild.name}`);
|
if (isDev) console.log(`LU: ${message.guild.name}`);
|
||||||
let guildInfo;
|
let guildInfo;
|
||||||
@ -768,35 +762,26 @@ const functions = {
|
|||||||
const comparedRankings = await functions.rankings.compare(guildInfo);
|
const comparedRankings = await functions.rankings.compare(guildInfo);
|
||||||
const embed = functions.builders.comparisonEmbed(comparedRankings, guildInfo);
|
const embed = functions.builders.comparisonEmbed(comparedRankings, guildInfo);
|
||||||
await compareMessage.edit(embed).catch(e => console.error(e));
|
await compareMessage.edit(embed).catch(e => console.error(e));
|
||||||
} else if (isTree) { // Check if the message is a tree
|
} else if (isTree) {
|
||||||
if (isDev) console.log(`TU: ${isTree.treeName}: ${isTree.treeHeight}ft`);
|
// Check if the message is a tree
|
||||||
|
// if (isDev) console.log(`TU: ${isTree.treeName}: ${isTree.treeHeight}ft`);
|
||||||
let guildInfo;
|
let guildInfo;
|
||||||
// Default to not updating the database
|
|
||||||
let doDbUpdate = false;
|
let doDbUpdate = false;
|
||||||
// Check if the bot has the guildInfo for this Guild already
|
|
||||||
if (message.client.guildInfos.has(message.guildId)) {
|
if (message.client.guildInfos.has(message.guildId)) {
|
||||||
guildInfo = message.client.guildInfos.get(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)) {
|
if ((guildInfo.treeName != isTree.treeName) || (guildInfo.treeHeight != isTree.treeHeight)) {
|
||||||
guildInfo.setTreeInfo(isTree.treeName, isTree.treeHeight, message.channel.id, message.id);
|
guildInfo.setTreeInfo(isTree.treeName, isTree.treeHeight, message.channel.id, message.id);
|
||||||
doDbUpdate = true;
|
doDbUpdate = true;
|
||||||
}
|
}
|
||||||
// If the waterTimestamp has changed, update the database
|
} else {
|
||||||
// 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)
|
guildInfo = new GuildInfo().setIds(message.guildId, message.guild.ownerId)
|
||||||
.setTreeInfo(isTree.treeName, isTree.treeHeight, message.channel.id, message.id);
|
.setTreeInfo(isTree.treeName, isTree.treeHeight, message.channel.id, message.id);
|
||||||
doDbUpdate = true;
|
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) {
|
if (doDbUpdate) {
|
||||||
const query = guildInfo.queryBuilder("setTreeInfo");
|
const query = guildInfo.queryBuilder("setTreeInfo");
|
||||||
await dbfn.setGuildInfo(query);
|
await dbfn.setGuildInfo(query);
|
||||||
// I've commented this out to see if it breaks anything.
|
await functions.collectionBuilders.guildInfos(message.client);
|
||||||
// Rebuilding shouldn't be necessary and is a waste of resources.
|
|
||||||
// await functions.collectionBuilders.guildInfos(message.client);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
package.json
10
package.json
@ -1,21 +1,21 @@
|
|||||||
{
|
{
|
||||||
"name": "silvanus",
|
"name": "silvanus",
|
||||||
"version": "1.3.0",
|
"version": "1.2.8",
|
||||||
"description": "The ultimate Grow A Tree companion bot!",
|
"description": "Grow A Tree Companion Bot",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://git.vfsh.dev/voidf1sh/silvanus.git"
|
"url": "git+https://github.com/voidf1sh/silvanus.git"
|
||||||
},
|
},
|
||||||
"author": "Skylar Grant",
|
"author": "Skylar Grant",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://git.vfsh.dev/voidf1sh/silvanus/issues"
|
"url": "https://github.com/voidf1sh/silvanus/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://git.vfsh.dev/voidf1sh/silvanus#readme",
|
"homepage": "https://github.com/voidf1sh/silvanus#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
"discord.js": "^14.11.0",
|
"discord.js": "^14.11.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user