Compare commits

...

4 commits

Author SHA1 Message Date
Ayden Jahola
2895dc0f85
update README 2024-10-29 13:43:00 +00:00
Ayden Jahola
0c08cd28ac
update readme 2024-10-29 13:40:12 +00:00
Ayden Jahola
e551656955
server settings: add action items channels to display 2024-10-29 09:16:17 +00:00
Ayden Jahola
618332cfcd
action items: make target channel be part of server settings model 2024-10-29 09:12:44 +00:00
5 changed files with 52 additions and 13 deletions

View file

@ -59,3 +59,7 @@ make sure to run `/setup` or otherwise the verification process wont work.
## Usage ## Usage
run `/help` command to get list of all avaiable commands, or visit the [commands](./commands/) directory to view them. run `/help` command to get list of all avaiable commands, or visit the [commands](./commands/) directory to view them.
## Dashboard (WIP)
I am currently working on a dashboard to manage the bot as well, currently this is in the `dashboard` branch and still work in progress. if you know how to build discord bot dashboards then please feel free to contribute.

View file

@ -29,11 +29,11 @@ module.exports = {
}); });
} }
const actionItemChannelId = serverSettings.actionItemsChannelId; const actionItemsChannelId = serverSettings.actionItemsChannelId;
if (interaction.channelId !== actionItemChannelId) { if (interaction.channelId !== actionItemsChannelId) {
return interaction.reply({ return interaction.reply({
content: `This command can only be used in the <#${actionItemChannelId}> channel.`, content: `This command can only be used in the <#${actionItemsChannelId}> channel.`,
ephemeral: true, ephemeral: true,
}); });
} }
@ -75,7 +75,7 @@ module.exports = {
userTaskMap.get(user).push(task); userTaskMap.get(user).push(task);
} }
// Generate initial task list message // initial message content
let messageContent = `📝 **Action Items:**\n\n`; let messageContent = `📝 **Action Items:**\n\n`;
userTaskMap.forEach((tasks, user) => { userTaskMap.forEach((tasks, user) => {
messageContent += `👤 **Assigned to:** ${user}\n`; messageContent += `👤 **Assigned to:** ${user}\n`;
@ -85,8 +85,7 @@ module.exports = {
messageContent += "\n"; messageContent += "\n";
}); });
// Fetch the specific channel to send the action items message const targetChannelId = serverSettings.actionItemsTargetChannelId;
const targetChannelId = "1164670538006933505";
const targetChannel = await interaction.guild.channels.fetch( const targetChannel = await interaction.guild.channels.fetch(
targetChannelId targetChannelId
); );
@ -97,14 +96,12 @@ module.exports = {
}); });
} }
// Send the action items message to the specified channel
const actionMessage = await targetChannel.send({ const actionMessage = await targetChannel.send({
content: messageContent + `✅ React with a checkmark to complete tasks!`, content: messageContent + `✅ React with a checkmark to complete tasks!`,
}); });
await actionMessage.react("✅"); await actionMessage.react("✅");
// Create reaction collector
const filter = (reaction, user) => { const filter = (reaction, user) => {
return reaction.emoji.name === "✅" && userTaskMap.has(user); return reaction.emoji.name === "✅" && userTaskMap.has(user);
}; };
@ -122,7 +119,6 @@ module.exports = {
const nextTaskIndex = completedTasks.size; const nextTaskIndex = completedTasks.size;
completedTasks.add(nextTaskIndex); completedTasks.add(nextTaskIndex);
// Update message content
let updatedMessageContent = `📝 **Action Items:**\n\n`; let updatedMessageContent = `📝 **Action Items:**\n\n`;
userTaskMap.forEach((userTasks, assignedUser) => { userTaskMap.forEach((userTasks, assignedUser) => {
updatedMessageContent += `👤 **Assigned to:** ${assignedUser}\n`; updatedMessageContent += `👤 **Assigned to:** ${assignedUser}\n`;
@ -132,14 +128,12 @@ module.exports = {
updatedMessageContent += "\n"; updatedMessageContent += "\n";
}); });
// Edit the message to reflect the completion
await actionMessage.edit({ await actionMessage.edit({
content: content:
updatedMessageContent + updatedMessageContent +
`✅ React with a checkmark to complete tasks!`, `✅ React with a checkmark to complete tasks!`,
}); });
// Notify the user about the completion
await interaction.followUp({ await interaction.followUp({
content: `${user} has completed task **${tasks[nextTaskIndex]}**!`, content: `${user} has completed task **${tasks[nextTaskIndex]}**!`,
ephemeral: true, ephemeral: true,

View file

@ -64,6 +64,14 @@ module.exports = {
? serverSettings.emailDomains.join(", ") ? serverSettings.emailDomains.join(", ")
: "None"; : "None";
const actionItemsChannel = interaction.guild.channels.cache.get(
serverSettings.actionItemsChannelId
);
const actionItemsTargetChannel = interaction.guild.channels.cache.get(
serverSettings.actionItemsTargetChannelId
);
const settingsEmbed = new EmbedBuilder() const settingsEmbed = new EmbedBuilder()
.setColor("#0099ff") .setColor("#0099ff")
.setTitle("🌟 Current Server Settings 🌟") .setTitle("🌟 Current Server Settings 🌟")
@ -85,7 +93,19 @@ module.exports = {
value: serverSettings.verifiedRoleName || "None", value: serverSettings.verifiedRoleName || "None",
inline: true, inline: true,
}, },
{ name: "📧 Email Domains", value: emailDomains, inline: true } { name: "📧 Email Domains", value: emailDomains, inline: true },
{
name: "📋 Action Items Channel",
value: actionItemsChannel ? `<#${actionItemsChannel.id}>` : "None",
inline: true,
},
{
name: "🎯 Action Items Target Channel",
value: actionItemsTargetChannel
? `<#${actionItemsTargetChannel.id}>`
: "None",
inline: true,
}
) )
.setTimestamp() .setTimestamp()
.setFooter({ .setFooter({

View file

@ -42,6 +42,14 @@ module.exports = {
"Select the allowed channel for action items. (Optional)" "Select the allowed channel for action items. (Optional)"
) )
.setRequired(false) .setRequired(false)
)
.addChannelOption((option) =>
option
.setName("actionitemstargetchannel")
.setDescription(
"Select the target channel where action items are going to be sent. (Optional)"
)
.setRequired(false)
), ),
async execute(interaction) { async execute(interaction) {
@ -67,6 +75,9 @@ module.exports = {
.map((domain) => domain.trim()); .map((domain) => domain.trim());
const actionitemschannel = const actionitemschannel =
interaction.options.getChannel("actionitemschannel"); interaction.options.getChannel("actionitemschannel");
const actionitemstargetchannel = interaction.options.getChannel(
"actionitemstargetchannel"
);
try { try {
// Store the channel IDs instead of names // Store the channel IDs instead of names
@ -82,6 +93,9 @@ module.exports = {
actionItemsChannelId: actionitemschannel actionItemsChannelId: actionitemschannel
? actionitemschannel.id ? actionitemschannel.id
: null, : null,
actionItemsTargetChannelId: actionitemstargetchannel
? actionitemstargetchannel.id
: null,
}, },
{ upsert: true, new: true } { upsert: true, new: true }
); );
@ -95,7 +109,13 @@ module.exports = {
**Allowed Email Domains**: ${emailDomains.join(", ")}\n **Allowed Email Domains**: ${emailDomains.join(", ")}\n
**Action Item Channel**: ${ **Action Item Channel**: ${
actionitemschannel ? `<#${actionitemschannel.id}>` : "None" actionitemschannel ? `<#${actionitemschannel.id}>` : "None"
}`, }\n
**Action Item Target Channel**: ${
actionitemstargetchannel
? `<#${actionitemstargetchannel.id}>`
: "None"
}
`,
ephemeral: true, ephemeral: true,
}); });
} catch (error) { } catch (error) {

View file

@ -8,6 +8,7 @@ const ServerSettingsSchema = new mongoose.Schema({
generalChannelId: { type: String, required: false }, generalChannelId: { type: String, required: false },
emailDomains: { type: [String], required: false }, emailDomains: { type: [String], required: false },
actionItemsChannelId: { type: String, required: false }, actionItemsChannelId: { type: String, required: false },
actionItemsTargetChannelId: { type: String, required: false },
}); });
const ServerSettings = mongoose.model("ServerSettings", ServerSettingsSchema); const ServerSettings = mongoose.model("ServerSettings", ServerSettingsSchema);