Begin implementing role menu

This commit is contained in:
Skylar Grant 2023-02-12 11:46:06 -05:00
parent 1a9d14e3e3
commit c93077016d
4 changed files with 38 additions and 2 deletions

View File

@ -18,7 +18,9 @@ module.exports = {
this.leaderboardMessageId = ""; this.leaderboardMessageId = "";
this.leaderboardChannelId = ""; this.leaderboardChannelId = "";
this.waterMessage = ""; this.waterMessage = "";
this.waterRoleId = "";
this.fruitMessage = ""; this.fruitMessage = "";
this.fruitRoleId = "";
this.reminderChannelId = ""; this.reminderChannelId = "";
this.watchChannelId = ""; this.watchChannelId = "";
} }
@ -52,6 +54,10 @@ module.exports = {
this.watchChannelId = watchChannelId; this.watchChannelId = watchChannelId;
return this; return this;
} }
setRoles(waterRoleId, fruitRoleId) {
this.waterRoleId = waterRoleId;
if (fruitRoleId) this.fruitRoleId = fruitRoleId;
}
queryBuilder(query) { queryBuilder(query) {
let queryParts = []; let queryParts = [];
switch (query) { switch (query) {
@ -119,6 +125,14 @@ module.exports = {
]; ];
return queryParts.join(''); return queryParts.join('');
break; break;
case "setRoles":
queryParts = [
`UPDATE guild_info SET water_role_id = ${db.escape(this.waterRoleId)}, `,
`fruit_role_id = ${db.escape(this.fruitRoleId)}, `,
`WHERE guild_id = ${db.escape(this.guildId)}`
];
return queryParts.join('');
break;
default: default:
break; break;
} }

View File

@ -537,9 +537,10 @@ const functions = {
const collector = channel.createMessageCollector({ filter }); const collector = channel.createMessageCollector({ filter });
collector.on('collect', message => { collector.on('collect', message => {
if (message.embeds.length == 0) return; if (message.embeds.length == 0) return;
console.log(message.embeds);
if (message.embeds[0].data.description.includes(strings.notifications.water)) { if (message.embeds[0].data.description.includes(strings.notifications.water)) {
this.sendReminder(guildInfo, guildInfo.waterMessage, guildInfo.reminderChannelId, guild); this.sendReminder(guildInfo, guildInfo.waterMessage, guildInfo.reminderChannelId, guild);
} else if (message.embeds[0].data.descriprion.includes(strings.notifications.fruit)) { } else if (message.embeds[0].data.description.includes(strings.notifications.fruit)) {
this.sendReminder(guildInfo, guildInfo.fruitMessage, guildInfo.reminderChannelId, guild); this.sendReminder(guildInfo, guildInfo.fruitMessage, guildInfo.reminderChannelId, guild);
} }
}); });

View File

@ -41,6 +41,7 @@ module.exports = {
console.log(query); console.log(query);
await dbfn.setGuildInfo(query); await dbfn.setGuildInfo(query);
await interaction.editReply(`I'll watch <#${watchChannel.id}> for Grow A Tree Notifications and relay them to <#${reminderChannel.id}>.`).catch(e => console.error(e)); await interaction.editReply(`I'll watch <#${watchChannel.id}> for Grow A Tree Notifications and relay them to <#${reminderChannel.id}>.`).catch(e => console.error(e));
fn.collectionBuilders.guildInfos(interaction.client);
} }
} catch (err) { } catch (err) {
console.error("Error occurred while setting up a notification relay: " + err); console.error("Error occurred while setting up a notification relay: " + err);

View File

@ -0,0 +1,20 @@
const { SlashCommandBuilder } = require('discord.js');
const fn = require('../modules/functions.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('rolemenu')
.setDescription('Send a self-assignable role selection menu')
.addRoleOption(o =>
o.setName('waterrole')
.setDescription('The role for water reminder pings')
.setRequired(true))
.addRoleOption(o =>
o.setName('fruitrole')
.setDescription('The role for fruit alert pings')
.setRequired(false)),
async execute(interaction) {
await interaction.deferReply().catch(err => console.error(err));
await interaction.editReply(fn.builders.embeds.treeRoleMenu()).catch(err => console.error(err));
},
};