Fix where I broke /setup

This commit is contained in:
Skylar Grant 2023-01-23 21:50:30 -05:00
parent 14d46a8b29
commit 1433b723c3

View File

@ -8,42 +8,44 @@ module.exports = {
.setName('setup') .setName('setup')
.setDescription('Attempt automatic configuration of the bot.'), .setDescription('Attempt automatic configuration of the bot.'),
execute(interaction) { execute(interaction) {
if (guildInfo[interaction.guildId] == undefined) { interaction.deferReply({ ephemeral: true }).then(function () {
guildInfo[interaction.guildId] = { if (guildInfo[interaction.guildId] == undefined) {
"treeMessageId": "", guildInfo[interaction.guildId] = {
"treeChannelId": "", "treeMessageId": "",
"rankMessageId": "", "treeChannelId": "",
"rankChannelId": "", "rankMessageId": "",
"treeName": "", "rankChannelId": "",
"treeHeight": 0, "treeName": "",
"rankings": [] "treeHeight": 0,
}; "rankings": []
} };
interaction.channel.messages.fetch({ limit: 20 }).then(msgs => { }
let treeFound = false; interaction.channel.messages.fetch({ limit: 20 }).then(function (msgs) {
let rankFound = false; let treeFound = false;
msgs.reverse().forEach(msg => { let rankFound = false;
if (msg.embeds.length > 0) { msgs.reverse().forEach(msg => {
if (msg.embeds[0].data.description.includes("Your tree is")) { if (msg.embeds.length > 0) {
treeFound = true; if (msg.embeds[0].data.description.includes("Your tree is")) {
guildInfo[interaction.guildId].treeChannelId = msg.channelId; treeFound = true;
guildInfo[interaction.guildId].treeMessageId = msg.id; guildInfo[interaction.guildId].treeChannelId = msg.channelId;
fn.tree.parse(msg); guildInfo[interaction.guildId].treeMessageId = msg.id;
} else if (msg.embeds[0].data.title == "Tallest Trees") { fn.tree.parse(msg);
rankFound = true; } else if (msg.embeds[0].data.title == "Tallest Trees") {
guildInfo[interaction.guildId].rankChannelId = msg.channelId; rankFound = true;
guildInfo[interaction.guildId].rankMessageId = msg.id; guildInfo[interaction.guildId].rankChannelId = msg.channelId;
fn.rankings.parse(msg); guildInfo[interaction.guildId].rankMessageId = msg.id;
fn.rankings.parse(msg);
}
} }
});
if (treeFound && !(rankFound)) {
interaction.editReply(fn.builders.embed(strings.status.treeNoLeaderboard));
} else if (!(treeFound) && rankFound) {
interaction.editReply(fn.builders.embed(strings.status.leaderboardNoTree));
} else if (treeFound && rankFound) {
interaction.editReply(fn.builders.embed(strings.status.treeAndLeaderboard));
} }
}); });
if (treeFound && !(rankFound)) {
interaction.reply(fn.builders.embed(strings.status.treeNoLeaderboard));
} else if (!(treeFound) && rankFound) {
interaction.reply(fn.builders.embed(strings.status.leaderboardNoTree));
} else if (treeFound && rankFound) {
interaction.reply(fn.builders.embed(strings.status.treeAndLeaderboard));
}
}); });
}, },
}; };