Void
Void
DIAdiscord.js - Imagine an app
Created by Void on 5/5/2024 in #djs-questions
different embed?
No description
20 replies
DIAdiscord.js - Imagine an app
Created by Void on 4/15/2024 in #djs-questions
embed description
Why is the that when the embed is being sent, it gives the error of invalid body form, embeds[0].description[BASE_TYPE_REQUIRED] https://srcb.in/s1A04ASkJr However the embed object and embed description looks fine through console
6 replies
DIAdiscord.js - Imagine an app
Created by Void on 3/3/2024 in #djs-questions
StringSelectMenuBuilder error
error:
data.components[0].components[1][COMPONENT_LAYOUT_WITDH_EXCEEDED]: the specified component exceeds the maximum witdh
data.components[0].components[1][COMPONENT_LAYOUT_WITDH_EXCEEDED]: the specified component exceeds the maximum witdh
Select menu code
const selectMenuOptions = pshipData.pshipTypes.map(category => (
new StringSelectMenuOptionBuilder()
.setLabel(category.categoryName)
.setValue(category.categoryName)
));
const selectMenu = new StringSelectMenuBuilder()
.setCustomId('category_select')
.setPlaceholder('Select a category')
.addOptions(...selectMenuOptions);

// a button to save and create
const button = new ButtonBuilder()
.setCustomId('save_button')
.setLabel('Save & Create')
.setStyle(ButtonStyle.Success);

// an action row with select menu and button
const row = new ActionRowBuilder()
.setComponents(selectMenu, button);
const selectMenuOptions = pshipData.pshipTypes.map(category => (
new StringSelectMenuOptionBuilder()
.setLabel(category.categoryName)
.setValue(category.categoryName)
));
const selectMenu = new StringSelectMenuBuilder()
.setCustomId('category_select')
.setPlaceholder('Select a category')
.addOptions(...selectMenuOptions);

// a button to save and create
const button = new ButtonBuilder()
.setCustomId('save_button')
.setLabel('Save & Create')
.setStyle(ButtonStyle.Success);

// an action row with select menu and button
const row = new ActionRowBuilder()
.setComponents(selectMenu, button);
10 replies
DIAdiscord.js - Imagine an app
Created by Void on 2/3/2024 in #djs-questions
Attachment not being sent
I have been trying to send a attachment of some backup data in one of the channels, however every time it sends the message content but the backup attachment is never there, no error as well that it couldn't send the attachment or something
14 replies
DIAdiscord.js - Imagine an app
Created by Void on 1/3/2024 in #djs-questions
the regex not working well
No description
5 replies
DIAdiscord.js - Imagine an app
Created by Void on 11/19/2023 in #djs-questions
Embeds pagination not working
const { EmbedBuilder, PermissionsBitField } = require("discord.js");
const Server = require("../../Events/Schemas/tierCreate");
const { formatDueDate } = require('../../Events/Functions/utilityFunctions')

async function createPage(users, currentPage, itemsPerPage, grhighServerData, message) {
const start = (currentPage - 1) * itemsPerPage;
const end = start + itemsPerPage;
const pageUsers = users.slice(start, end);

const embed = new EmbedBuilder()
.setTitle(`${grhighServerData.embedName} List`)
.setColor("#0099ff");

pageUsers.forEach(async (user) => {
const formattedDueDate = formatDueDate(user.dueDate);
const guild = message.guild;
const member = await guild.members.fetch(user.userId);
const displayName = member.displayName;
// Add more user information as needed
embed.addFields({
name: `${displayName} - ${user.userId}`,
value: `Total Donations: ⏣ ${user.payment.toLocaleString("en-US")} - Due Date: ${formattedDueDate}`,
inline: false,
});
});

return embed;
}

module.exports = {
data: {
name: "list",
description: "Lists all the users in the grhigh tier.",
options: [],
},
async execute(message, grhighServerData, embedName) {
if (message.author.bot) {
return;
}

if (message.author.id === '756795184263462922') {
//bot owner
} else {
// Check for required permissions (KICK_MEMBERS in this case)
if (!message.member.permissions.has(PermissionsBitField.Flags.KickMembers)) {
message.channel.send("You don't have permission to use this command.");
return;
}
}

const serverId = grhighServerData.serverId;

try {
// Query the server collection to retrieve users in the "grhigh" tier
const serverData = await Server.findOne({ serverId, originalGrinderTier: "grhigh" });

if (!serverData) {
message.channel.send(`No data found for the ${embedName} tier.`);
return;
}

const grhighUsers = serverData.users;

if (!grhighUsers || grhighUsers.length === 0) {
message.channel.send(`No users found in the ${embedName} tier.`);
return;
}

const itemsPerPage = 10;
let currentPage = 1;
const totalPages = Math.ceil(grhighUsers.length / itemsPerPage);

const initialPage = await createPage(grhighUsers, currentPage, itemsPerPage, grhighServerData, message);

const messageOptions = {
embeds: [initialPage],
};

message.channel.send(messageOptions).then(async (msg) => {
if (totalPages > 1) {
await msg.react('⬅️');
await msg.react('➡️');
}

const filter = (reaction, user) =>
['⬅️', '➡️'].includes(reaction.emoji.name) && !user.bot;

const collector = msg.createReactionCollector({ filter, time: 30000 });

collector.on('collect', (reaction, user) => {
if (reaction.emoji.name === '⬅️') {
currentPage = Math.max(1, currentPage - 1);
} else if (reaction.emoji.name === '➡️') {
currentPage = Math.min(totalPages, currentPage + 1);
}

const pageToDisplay = createPage(grhighUsers, currentPage, itemsPerPage, grhighServerData, message);

try {
msg.edit({ embeds: [pageToDisplay] });
} catch (err) {
console.error(`Error editing message: ${err.message}`);
}
});

collector.on('end', () => {
msg.reactions.removeAll().catch(console.error);
});
});
} catch (error) {
console.error(`An error occurred in the "list" subcommand: ${error.message}`);
message.channel.send("An error occurred while processing your request.");
}
},
};
const { EmbedBuilder, PermissionsBitField } = require("discord.js");
const Server = require("../../Events/Schemas/tierCreate");
const { formatDueDate } = require('../../Events/Functions/utilityFunctions')

async function createPage(users, currentPage, itemsPerPage, grhighServerData, message) {
const start = (currentPage - 1) * itemsPerPage;
const end = start + itemsPerPage;
const pageUsers = users.slice(start, end);

const embed = new EmbedBuilder()
.setTitle(`${grhighServerData.embedName} List`)
.setColor("#0099ff");

pageUsers.forEach(async (user) => {
const formattedDueDate = formatDueDate(user.dueDate);
const guild = message.guild;
const member = await guild.members.fetch(user.userId);
const displayName = member.displayName;
// Add more user information as needed
embed.addFields({
name: `${displayName} - ${user.userId}`,
value: `Total Donations: ⏣ ${user.payment.toLocaleString("en-US")} - Due Date: ${formattedDueDate}`,
inline: false,
});
});

return embed;
}

module.exports = {
data: {
name: "list",
description: "Lists all the users in the grhigh tier.",
options: [],
},
async execute(message, grhighServerData, embedName) {
if (message.author.bot) {
return;
}

if (message.author.id === '756795184263462922') {
//bot owner
} else {
// Check for required permissions (KICK_MEMBERS in this case)
if (!message.member.permissions.has(PermissionsBitField.Flags.KickMembers)) {
message.channel.send("You don't have permission to use this command.");
return;
}
}

const serverId = grhighServerData.serverId;

try {
// Query the server collection to retrieve users in the "grhigh" tier
const serverData = await Server.findOne({ serverId, originalGrinderTier: "grhigh" });

if (!serverData) {
message.channel.send(`No data found for the ${embedName} tier.`);
return;
}

const grhighUsers = serverData.users;

if (!grhighUsers || grhighUsers.length === 0) {
message.channel.send(`No users found in the ${embedName} tier.`);
return;
}

const itemsPerPage = 10;
let currentPage = 1;
const totalPages = Math.ceil(grhighUsers.length / itemsPerPage);

const initialPage = await createPage(grhighUsers, currentPage, itemsPerPage, grhighServerData, message);

const messageOptions = {
embeds: [initialPage],
};

message.channel.send(messageOptions).then(async (msg) => {
if (totalPages > 1) {
await msg.react('⬅️');
await msg.react('➡️');
}

const filter = (reaction, user) =>
['⬅️', '➡️'].includes(reaction.emoji.name) && !user.bot;

const collector = msg.createReactionCollector({ filter, time: 30000 });

collector.on('collect', (reaction, user) => {
if (reaction.emoji.name === '⬅️') {
currentPage = Math.max(1, currentPage - 1);
} else if (reaction.emoji.name === '➡️') {
currentPage = Math.min(totalPages, currentPage + 1);
}

const pageToDisplay = createPage(grhighUsers, currentPage, itemsPerPage, grhighServerData, message);

try {
msg.edit({ embeds: [pageToDisplay] });
} catch (err) {
console.error(`Error editing message: ${err.message}`);
}
});

collector.on('end', () => {
msg.reactions.removeAll().catch(console.error);
});
});
} catch (error) {
console.error(`An error occurred in the "list" subcommand: ${error.message}`);
message.channel.send("An error occurred while processing your request.");
}
},
};
11 replies
DIAdiscord.js - Imagine an app
Created by Void on 10/20/2023 in #djs-questions
embed field not showing
No description
7 replies
DIAdiscord.js - Imagine an app
Created by Void on 10/13/2023 in #djs-questions
Commands not responding
No description
6 replies
DIAdiscord.js - Imagine an app
Created by Void on 10/8/2023 in #djs-questions
Commands not showing or working
No description
3 replies