Bug fix so message updates will create guild entry

This commit is contained in:
Skylar Grant 2023-06-03 14:19:34 -04:00
parent f7230ec0fb
commit 3c01d37bd5
2 changed files with 18 additions and 6 deletions

View File

@ -134,18 +134,28 @@ module.exports = {
return queryParts.join('');
break;
case "setTreeMessage":
// queryParts = [
// `UPDATE guild_info SET tree_message_id = ${db.escape(this.treeMessageId)}, `,
// `tree_channel_id = ${db.escape(this.treeChannelId)} `,
// `WHERE guild_id = ${db.escape(this.guildId)}`
// ];
queryParts = [
`UPDATE guild_info SET tree_message_id = ${db.escape(this.treeMessageId)}, `,
`tree_channel_id = ${db.escape(this.treeChannelId)} `,
`WHERE guild_id = ${db.escape(this.guildId)}`
`INSERT INTO guild_info (guild_id, tree_message_id, tree_channel_id)`,
`VALUES (${db.escape(this.guildId)}, ${db.escape(this.treeMessageId)}, ${db.escape(this.treeChannelId)})`,
`ON DUPLICATE KEY UPDATE tree_message_id = ${db.escape(this.treeMessageId)}, tree_channel_id = ${db.escape(this.treeChannelId)}`
];
return queryParts.join('');
break;
case "setLeaderboardMessage":
// queryParts = [
// `UPDATE guild_info SET leaderboard_message_id = ${db.escape(this.leaderboardMessageId)}, `,
// `leaderboard_channel_id = ${db.escape(this.leaderboardChannelId)} `,
// `WHERE guild_id = ${db.escape(this.guildId)}`
// ];
queryParts = [
`UPDATE guild_info SET leaderboard_message_id = ${db.escape(this.leaderboardMessageId)}, `,
`leaderboard_channel_id = ${db.escape(this.leaderboardChannelId)} `,
`WHERE guild_id = ${db.escape(this.guildId)}`
`INSERT INTO guild_info (guild_id, leaderboard_message_id, leaderboard_channel_id)`,
`VALUES (${db.escape(this.guildId)}, ${db.escape(this.leaderboardMessageId)}, ${db.escape(this.leaderboardChannelId)})`,
`ON DUPLICATE KEY UPDATE leaderboard_message_id = ${db.escape(this.leaderboardMessageId)}, leaderboard_channel_id = ${db.escape(this.leaderboardChannelId)}`
];
return queryParts.join('');
break;

View File

@ -686,6 +686,7 @@ const functions = {
if (doDbUpdate) {
const query = guildInfo.queryBuilder("setLeaderboardMessage");
await dbfn.setGuildInfo(query);
await functions.collectionBuilders.guildInfos(message.client);
}
await dbfn.uploadLeaderboard(isLeaderboard);
// Update the comparison message
@ -741,6 +742,7 @@ const functions = {
if (doDbUpdate) {
const query = guildInfo.queryBuilder("setTreeInfo");
await dbfn.setGuildInfo(query);
await functions.collectionBuilders.guildInfos(message.client);
}
}
}