Tentative deploy
This commit is contained in:
parent
e6aeb685ee
commit
2694d4b691
@ -138,5 +138,23 @@ module.exports = {
|
||||
break;
|
||||
}
|
||||
}
|
||||
generateSetupInfo() {
|
||||
let setupInfoParts = [
|
||||
`Here is your server's configuration:`,
|
||||
`Tree Name: ${this.treeName}`,
|
||||
`Tree Height: ${this.treeHeight}`,
|
||||
`Tree Channel: <#${this.treeChannelId}>`,
|
||||
`[Tree Link](https://discord.com/channels/${this.guildId}/${this.treeChannelId}/${this.treeMessageId})`,
|
||||
`Leaderboard Channel: <#${this.leaderboardChannelId}>`,
|
||||
`[Leaderboard Link](https://discord.com/channels/${this.guildId}/${this.leaderboardChannelId}/${this.leaderboardMessageId})`,
|
||||
`Notification Watch Channel: <#${this.watchChannelId}>`,
|
||||
`Notification Relay Channel: <#${this.reminderChannelId}>`,
|
||||
`Water Message: ${this.waterMessage}`,
|
||||
`Fruit Message: ${this.fruitMessage}`,
|
||||
`Water Role: <@&${this.waterRoleId}>`,
|
||||
`Fruit Role: <@&${this.fruitRoleId}>`
|
||||
]
|
||||
return setupInfoParts.join('\n');
|
||||
}
|
||||
}
|
||||
}
|
@ -145,6 +145,35 @@ module.exports = {
|
||||
});
|
||||
});
|
||||
},
|
||||
setTreeInfo(guildInfo) {
|
||||
const db = mysql.createConnection({
|
||||
host: process.env.DBHOST,
|
||||
user: process.env.DBUSER,
|
||||
password: process.env.DBPASS,
|
||||
database: process.env.DBNAME,
|
||||
port: process.env.DBPORT
|
||||
});
|
||||
db.connect((err) => {
|
||||
if (err) throw `Error connecting to the database: ${err.message}`;
|
||||
});
|
||||
// Returns a Promise, resolve({ "status": "", "data": null })
|
||||
// guildInfo = { "guildId": "123", "treeName": "name", "treeHeight": 123, "treeMessageId": "123", "treeChannelId": "123", "leaderboardMessageId": "123", "leaderboardChannelId": "123"}
|
||||
// Set a server's tree information in the database)
|
||||
const insertGuildInfoQuery = `INSERT INTO guild_info (guild_id, tree_name, tree_height, tree_message_id, tree_channel_id) VALUES (${db.escape(guildInfo.guildId)}, ${db.escape(guildInfo.treeName)}, ${db.escape(guildInfo.treeHeight)},${db.escape(guildInfo.treeMessageId)}, ${db.escape(guildInfo.treeChannelId)}) ON DUPLICATE KEY UPDATE tree_name = ${db.escape(guildInfo.treeName)},tree_height = ${db.escape(guildInfo.treeHeight)},tree_message_id = ${db.escape(guildInfo.treeMessageId)},tree_channel_id = ${db.escape(guildInfo.treeChannelId)}`;
|
||||
// TODO run this query and return a promise, then resolve with { "status": , "data": null }
|
||||
return new Promise((resolve, reject) => {
|
||||
db.query(insertGuildInfoQuery, (err, res) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
db.end();
|
||||
reject("Error setting the guild info: " + err.message);
|
||||
return;
|
||||
}
|
||||
db.end();
|
||||
resolve({ "status": "Successfully set the guild information", "data": null });
|
||||
});
|
||||
});
|
||||
},
|
||||
setLeaderboardInfo(guildInfo) {
|
||||
const db = mysql.createConnection({
|
||||
host: process.env.DBHOST,
|
||||
|
@ -549,13 +549,6 @@ const functions = {
|
||||
});
|
||||
});
|
||||
},
|
||||
getInfo(interaction) {
|
||||
let guildInfo = interaction.client.guildInfos.get(interaction.guild.id);
|
||||
let guildInfoString = "";
|
||||
guildInfoString += `Tree Message: https://discord.com/channels/${guildId}/${guildInfo.treeChannelId}/${guildInfo.treeMessageId}\n`;
|
||||
guildInfoString += `Rank Message: https://discord.com/channels/${guildId}/${guildInfo.leaderboardChannelId}/${guildInfo.leaderboardMessageId}\n`;
|
||||
return `Here is your servers setup info:\n${guildInfoString}`;
|
||||
},
|
||||
getWaterTime(size) {
|
||||
return Math.floor(Math.pow(size * 0.07 + 5, 1.1)); // Seconds
|
||||
},
|
||||
@ -602,17 +595,6 @@ const functions = {
|
||||
console.error(err);
|
||||
});
|
||||
},
|
||||
async refreshComparisonMessage(client, guildInfo) {
|
||||
if (guildInfo.comparisonChannelId != "" && guildInfo.comparisonMessageId != "") {
|
||||
const guild = await client.guilds.fetch(guildInfo.guildId);
|
||||
const comparisonChannel = await guild.channels.fetch(guildInfo.comparisonChannelId);
|
||||
const comparisonMessage = await comparisonChannel.messages.fetch(guildInfo.comparisonMessageId);
|
||||
const embed = comparisonMessage.embeds[0];
|
||||
const actionRow = this.builders.actionRows.comparisonActionRow(guildInfo);
|
||||
await comparisonMessage.edit({ components: [actionRow] });
|
||||
return;
|
||||
}
|
||||
},
|
||||
async setupCollectors(client) {
|
||||
let guildInfos = client.guildInfos;
|
||||
guildInfos.set("collectors", []);
|
||||
|
@ -5,17 +5,18 @@ module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('setupinfo')
|
||||
.setDescription('View information about how the bot is set up in your server'),
|
||||
execute(interaction) {
|
||||
interaction.deferReply({ephemeral: true}).then(() => {
|
||||
fn.getInfo(interaction).then(res => {
|
||||
const embed = fn.builders.embed(res);
|
||||
interaction.editReply(embed);
|
||||
}).catch(err => {
|
||||
interaction.editReply(err);
|
||||
async execute(interaction) {
|
||||
await interaction.deferReply({ ephemeral: true }).catch(err => console.error(err));
|
||||
try {
|
||||
if (interaction.client.guildInfos.has(interaction.guildId)) {
|
||||
let guildInfo = interaction.client.guildInfos.get(interaction.guildId);
|
||||
await interaction.editReply(fn.builders.embed(guildInfo.generateSetupInfo()));
|
||||
} else {
|
||||
await interaction.editReply(fn.builders.errorEmbed("Guild doesn't exist in database!"));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
await interaction.editReply(fn.builders.errorEmbed("There was an error running the command."));
|
||||
}
|
||||
},
|
||||
};
|
Loading…
Reference in New Issue
Block a user