Fixes, ready for testing
This commit is contained in:
parent
d8e7ec2c1a
commit
e6aeb685ee
6
main.js
6
main.js
@ -72,10 +72,12 @@ client.on('interactionCreate', async interaction => {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'waterpingrole':
|
case 'waterpingrole':
|
||||||
await interaction.reply(fn.buttonHandlers.waterPing(interaction)).catch(err => console.error(err));
|
const waterPingStatus = await fn.buttonHandlers.waterPing(interaction);
|
||||||
|
await interaction.reply(waterPingStatus).catch(err => console.error(err));
|
||||||
break;
|
break;
|
||||||
case 'fruitpingrole':
|
case 'fruitpingrole':
|
||||||
await interaction.reply(fn.buttonHandlers.fruitPing(interaction)).catch(err => console.error(err));
|
const fruitPingStatus = await fn.buttonHandlers.fruitPing(interaction);
|
||||||
|
await interaction.reply(fruitPingStatus).catch(err => console.error(err));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -57,6 +57,7 @@ module.exports = {
|
|||||||
setRoles(waterRoleId, fruitRoleId) {
|
setRoles(waterRoleId, fruitRoleId) {
|
||||||
this.waterRoleId = waterRoleId;
|
this.waterRoleId = waterRoleId;
|
||||||
if (fruitRoleId) this.fruitRoleId = fruitRoleId;
|
if (fruitRoleId) this.fruitRoleId = fruitRoleId;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
queryBuilder(query) {
|
queryBuilder(query) {
|
||||||
let queryParts = [];
|
let queryParts = [];
|
||||||
@ -128,7 +129,7 @@ module.exports = {
|
|||||||
case "setRoles":
|
case "setRoles":
|
||||||
queryParts = [
|
queryParts = [
|
||||||
`UPDATE guild_info SET water_role_id = ${db.escape(this.waterRoleId)}, `,
|
`UPDATE guild_info SET water_role_id = ${db.escape(this.waterRoleId)}, `,
|
||||||
`fruit_role_id = ${db.escape(this.fruitRoleId)}, `,
|
`fruit_role_id = ${db.escape(this.fruitRoleId)} `,
|
||||||
`WHERE guild_id = ${db.escape(this.guildId)}`
|
`WHERE guild_id = ${db.escape(this.guildId)}`
|
||||||
];
|
];
|
||||||
return queryParts.join('');
|
return queryParts.join('');
|
||||||
|
@ -68,8 +68,8 @@ module.exports = {
|
|||||||
.setHeight(row.tree_height)
|
.setHeight(row.tree_height)
|
||||||
.setTreeMessage(row.tree_message_id, row.tree_channel_id)
|
.setTreeMessage(row.tree_message_id, row.tree_channel_id)
|
||||||
.setLeaderboardMessage(row.leaderboard_message_id, row.leaderboard_channel_id)
|
.setLeaderboardMessage(row.leaderboard_message_id, row.leaderboard_channel_id)
|
||||||
.setReminders(row.water_message, row.fruit_message, row.reminder_channel_id, row.watch_channel_id);
|
.setReminders(row.water_message, row.fruit_message, row.reminder_channel_id, row.watch_channel_id)
|
||||||
|
.setRoles(row.water_role_id, row.fruit_role_id);
|
||||||
db.end();
|
db.end();
|
||||||
resolve(guildInfo);
|
resolve(guildInfo);
|
||||||
});
|
});
|
||||||
@ -112,6 +112,7 @@ module.exports = {
|
|||||||
.setTreeMessage(row.tree_message_id, row.tree_channel_id)
|
.setTreeMessage(row.tree_message_id, row.tree_channel_id)
|
||||||
.setLeaderboardMessage(row.leaderboard_message_id, row.leaderboard_channel_id)
|
.setLeaderboardMessage(row.leaderboard_message_id, row.leaderboard_channel_id)
|
||||||
.setReminders(row.water_message, row.fruit_message, row.reminder_channel_id, row.watch_channel_id)
|
.setReminders(row.water_message, row.fruit_message, row.reminder_channel_id, row.watch_channel_id)
|
||||||
|
.setRoles(row.water_role_id, row.fruit_role_id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +135,7 @@ module.exports = {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
db.query(query, (err, res) => {
|
db.query(query, (err, res) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err + "\n" + query);
|
||||||
reject("Error setting the guild info: " + err.message);
|
reject("Error setting the guild info: " + err.message);
|
||||||
db.end();
|
db.end();
|
||||||
return;
|
return;
|
||||||
|
@ -507,6 +507,17 @@ const functions = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
roles: {
|
||||||
|
async fetchRole(guild, roleId) {
|
||||||
|
return await guild.roles.fetch(roleId).catch(err => console.error("Error fetching the role: " + err + "\n" + roleId));
|
||||||
|
},
|
||||||
|
async giveRole(member, role) {
|
||||||
|
await member.roles.add(role).catch(err => console.error("Error giving the role: " + err + "\n" + JSON.stringify(role)));
|
||||||
|
},
|
||||||
|
async takeRole(member, role) {
|
||||||
|
await member.roles.remove(role).catch(err => console.error("Error taking the role: " + err + "\n" + JSON.stringify(role)));
|
||||||
|
}
|
||||||
|
},
|
||||||
async refresh(interaction) {
|
async refresh(interaction) {
|
||||||
// const getGuildInfoResponse = await dbfn.getGuildInfo(interaction.guildId);
|
// const getGuildInfoResponse = await dbfn.getGuildInfo(interaction.guildId);
|
||||||
// let guildInfo = getGuildInfoResponse.data;
|
// let guildInfo = getGuildInfoResponse.data;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const { SlashCommandBuilder } = require('discord.js');
|
const { SlashCommandBuilder } = require('discord.js');
|
||||||
|
const dbfn = require('../modules/dbfn.js');
|
||||||
const fn = require('../modules/functions.js');
|
const fn = require('../modules/functions.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -18,6 +19,8 @@ module.exports = {
|
|||||||
if (interaction.client.guildInfos.has(interaction.guildId)) {
|
if (interaction.client.guildInfos.has(interaction.guildId)) {
|
||||||
let guildInfo = interaction.client.guildInfos.get(interaction.guildId);
|
let guildInfo = interaction.client.guildInfos.get(interaction.guildId);
|
||||||
guildInfo.setRoles(interaction.options.getRole('waterrole').id, interaction.options.getRole('fruitrole').id);
|
guildInfo.setRoles(interaction.options.getRole('waterrole').id, interaction.options.getRole('fruitrole').id);
|
||||||
|
await dbfn.setGuildInfo(guildInfo.queryBuilder("setRoles"));
|
||||||
|
await fn.collectionBuilders.guildInfos(interaction.client);
|
||||||
await interaction.editReply(fn.builders.embeds.treeRoleMenu(guildInfo)).catch(err => console.error(err));
|
await interaction.editReply(fn.builders.embeds.treeRoleMenu(guildInfo)).catch(err => console.error(err));
|
||||||
} else {
|
} else {
|
||||||
await interaction.editReply(fn.builders.errorEmbed("No information is known about your server yet, please run /setup or /compare")).catch(err => console.error(err));
|
await interaction.editReply(fn.builders.errorEmbed("No information is known about your server yet, please run /setup or /compare")).catch(err => console.error(err));
|
||||||
|
Loading…
Reference in New Issue
Block a user