Fix where I broke /setup
This commit is contained in:
parent
14d46a8b29
commit
1433b723c3
@ -8,42 +8,44 @@ module.exports = {
|
||||
.setName('setup')
|
||||
.setDescription('Attempt automatic configuration of the bot.'),
|
||||
execute(interaction) {
|
||||
if (guildInfo[interaction.guildId] == undefined) {
|
||||
guildInfo[interaction.guildId] = {
|
||||
"treeMessageId": "",
|
||||
"treeChannelId": "",
|
||||
"rankMessageId": "",
|
||||
"rankChannelId": "",
|
||||
"treeName": "",
|
||||
"treeHeight": 0,
|
||||
"rankings": []
|
||||
};
|
||||
}
|
||||
interaction.channel.messages.fetch({ limit: 20 }).then(msgs => {
|
||||
let treeFound = false;
|
||||
let rankFound = false;
|
||||
msgs.reverse().forEach(msg => {
|
||||
if (msg.embeds.length > 0) {
|
||||
if (msg.embeds[0].data.description.includes("Your tree is")) {
|
||||
treeFound = true;
|
||||
guildInfo[interaction.guildId].treeChannelId = msg.channelId;
|
||||
guildInfo[interaction.guildId].treeMessageId = msg.id;
|
||||
fn.tree.parse(msg);
|
||||
} else if (msg.embeds[0].data.title == "Tallest Trees") {
|
||||
rankFound = true;
|
||||
guildInfo[interaction.guildId].rankChannelId = msg.channelId;
|
||||
guildInfo[interaction.guildId].rankMessageId = msg.id;
|
||||
fn.rankings.parse(msg);
|
||||
interaction.deferReply({ ephemeral: true }).then(function () {
|
||||
if (guildInfo[interaction.guildId] == undefined) {
|
||||
guildInfo[interaction.guildId] = {
|
||||
"treeMessageId": "",
|
||||
"treeChannelId": "",
|
||||
"rankMessageId": "",
|
||||
"rankChannelId": "",
|
||||
"treeName": "",
|
||||
"treeHeight": 0,
|
||||
"rankings": []
|
||||
};
|
||||
}
|
||||
interaction.channel.messages.fetch({ limit: 20 }).then(function (msgs) {
|
||||
let treeFound = false;
|
||||
let rankFound = false;
|
||||
msgs.reverse().forEach(msg => {
|
||||
if (msg.embeds.length > 0) {
|
||||
if (msg.embeds[0].data.description.includes("Your tree is")) {
|
||||
treeFound = true;
|
||||
guildInfo[interaction.guildId].treeChannelId = msg.channelId;
|
||||
guildInfo[interaction.guildId].treeMessageId = msg.id;
|
||||
fn.tree.parse(msg);
|
||||
} else if (msg.embeds[0].data.title == "Tallest Trees") {
|
||||
rankFound = true;
|
||||
guildInfo[interaction.guildId].rankChannelId = msg.channelId;
|
||||
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));
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
Loading…
Reference in New Issue
Block a user