Jasper
Jasper
DIAdiscord.js - Imagine an app
Created by Jasper on 7/20/2023 in #djs-questions
How to make embeds send correctly
and so on.
7 replies
DIAdiscord.js - Imagine an app
Created by Jasper on 7/20/2023 in #djs-questions
How to make embeds send correctly
What I want it to do is for it to print once as
User1: x points
User2: x points
User3: x points
User4: x points
User5: x points
User1: x points
User2: x points
User3: x points
User4: x points
User5: x points
User6: y points
User7: y points
User8: y points
User9: y points
User10: y points
User6: y points
User7: y points
User8: y points
User9: y points
User10: y points
7 replies
DIAdiscord.js - Imagine an app
Created by Jasper on 7/20/2023 in #djs-questions
How to make embeds send correctly
and so on
7 replies
DIAdiscord.js - Imagine an app
Created by Jasper on 7/20/2023 in #djs-questions
How to make embeds send correctly
Currently it does work, but it sends whenever a single .addFields is complete, which means it prints like this:
User1: x points
User1: x points
User1: x points
User2: x points
User1: x points
User2: x points
User1: x points
User2: x points
User3: x points
User1: x points
User2: x points
User3: x points
...
User6: y points
User6: y points
User6: y points
User7: y points
User6: y points
User7: y points
7 replies
DIAdiscord.js - Imagine an app
Created by Jasper on 7/20/2023 in #djs-questions
How to make embeds send correctly
This is the current code so far.
async function setPointEmbed(message: Message<boolean>, client: Client, type: string) {
const embedsRequired = Math.ceil(Object.keys(global.points).length / 5);
console.log(embedsRequired);
if (embedsRequired === 0) {
message.channel.send("No points have been scored yet!");
return;
}
var tempPointEmbed = [];
for (var key in global.points) {
tempPointEmbed.push({ name: (await client.users.fetch(key)).username.toString(), value: points[key].toString() })
};
for (var i = 0; i < embedsRequired; i++) {
console.log("test")
if (i === 0) {
if (type === "final") { pointEmbed.setTitle("Final scores") }
else if (type === "current") { pointEmbed.setTitle("Current scores") }
else { throw Error("Invalid type of pointsDisplay entered") }
}
else { pointEmbed.setTitle(null)}
pointEmbed.setFields([]);
for (var j = 0; j < 5; j++) {
pointEmbed.addFields(tempPointEmbed[j + (i * 5)]);
}
message.channel.send({ embeds: [pointEmbed] });
}
async function setPointEmbed(message: Message<boolean>, client: Client, type: string) {
const embedsRequired = Math.ceil(Object.keys(global.points).length / 5);
console.log(embedsRequired);
if (embedsRequired === 0) {
message.channel.send("No points have been scored yet!");
return;
}
var tempPointEmbed = [];
for (var key in global.points) {
tempPointEmbed.push({ name: (await client.users.fetch(key)).username.toString(), value: points[key].toString() })
};
for (var i = 0; i < embedsRequired; i++) {
console.log("test")
if (i === 0) {
if (type === "final") { pointEmbed.setTitle("Final scores") }
else if (type === "current") { pointEmbed.setTitle("Current scores") }
else { throw Error("Invalid type of pointsDisplay entered") }
}
else { pointEmbed.setTitle(null)}
pointEmbed.setFields([]);
for (var j = 0; j < 5; j++) {
pointEmbed.addFields(tempPointEmbed[j + (i * 5)]);
}
message.channel.send({ embeds: [pointEmbed] });
}
7 replies