Skip to content

Commit

Permalink
fix: leaderboard image
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik K committed Dec 1, 2023
1 parent b22b068 commit 3faeb68
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/commands/game/leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const command: ChatInputCommand = {
option
.setName("game")
.setDescription("Which game do you want leaderboards from?")
.addChoices({ name: "Higher & Ligher", value: "higherlower" })
.addChoices({ name: "Higher or Lower", value: "higherlower" })
.setRequired(true),
)
.addStringOption((option) =>
Expand Down Expand Up @@ -53,8 +53,7 @@ const command: ChatInputCommand = {
client,
});

let data2: any;
data2 = await UserModel.find({
let data2 = await UserModel.find({
"higherlower.highscore": { $gt: 1 },
}).sort({ "higherlower.highscore": -1 });

Expand All @@ -65,16 +64,17 @@ const command: ChatInputCommand = {
score: number;
avatar: string;
}[] = [];
for (var i = 0; i < 10; i++) {
for (let i = 0; i < 10; i++) {
z++;

let data = data2[z];
let data: any = data2[z];
console.log(data);
let user = await client.users.fetch(data.userID);

users.push({
top: z,
avatar:
user.avatarURL() ||
user.displayAvatarURL() ||
"https://cdn.discordapp.com/embed/avatars/0.png",
tag: user.username,
score: data.higherlower.highscore,
Expand All @@ -94,20 +94,19 @@ const command: ChatInputCommand = {
})
.addUserData(users);

let imga;
leaderboard.build().then((img: any) => {
const imageBuffer = leaderboard.build()
console.log(imageBuffer)
//write("./src/data/Images/leaderboard.png", img);
imga = new AttachmentBuilder(img, {
const image = new AttachmentBuilder(imageBuffer, {
name: "leaderboard.png",
});
});

page.add(
new EmbedBuilder()
.setTitle(`Leaderboard`)
.setImage("attachment://leaderboard.png")
.setColor("#F00605"),
imga,
image,
);
}

Expand Down

0 comments on commit 3faeb68

Please sign in to comment.