From d7ed75660fb9108b3fa92a60bab95a321df903bb Mon Sep 17 00:00:00 2001 From: M_Viper Date: Wed, 7 Feb 2024 14:47:08 +0000 Subject: [PATCH] Dateien nach "commands/level" hochladen --- commands/level/lol | 1 + commands/level/profile.js | 34 ++++++++++++++++++++++++++++++++++ commands/level/rank.js | 24 ++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 commands/level/lol create mode 100644 commands/level/profile.js create mode 100644 commands/level/rank.js diff --git a/commands/level/lol b/commands/level/lol new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/commands/level/lol @@ -0,0 +1 @@ + diff --git a/commands/level/profile.js b/commands/level/profile.js new file mode 100644 index 0000000..cb0e30f --- /dev/null +++ b/commands/level/profile.js @@ -0,0 +1,34 @@ +const Levels = require("discord-xp"); +const Discord = require ("discord.js") +const Canvas = require('canvas'); + + const canvas = Canvas.createCanvas(867, 892); + const ctx = canvas.getContext('2d'); + module.exports = { + name: "lb", + description: "Chat-Level erhalten", category: "Level[Beta]", + // users will need premium to execute this + run: async (bot, message, args) => { + + + const rawLeaderboard = await Levels.fetchLeaderboard(message.guild.id, 10); + const leaderboard = await Levels.computeLeaderboard(bot, rawLeaderboard); + if (rawLeaderboard.length < 1) return message.channel.send("Es ist noch niemand in der Rangliste."); + + const lb = leaderboard.map(e => `${e.position}. ${e.username}#${e.discriminator}\nLevel: ${e.level}\nXP: ${e.xp.toLocaleString()}`); + + const background = await Canvas.loadImage('https://cdn.discordapp.com/attachments/823585354569351208/843202808287199232/image1.jpg'); + ctx.drawImage(background, 0, 0, canvas.width, canvas.height); + + ctx.strokeStyle = '#74037b'; + ctx.strokeRect(0, 0, canvas.width, canvas.height); + ctx.font = 'normal normal bold 30px Arial'; + ctx.fillStyle = '#ffffff'; + ctx.fillText(`${lb.join("\n\n")}`, canvas.width / 3.0, canvas.height / 5.0); + ctx.beginPath(); + ctx.arc(125, 125, 100, 0, Math.PI * 2, true); + ctx.closePath(); + ctx.clip(); + const attachment = new Discord.MessageAttachment(canvas.toBuffer(), `abotlb.jpg`); + message.channel.send(attachment); + } } \ No newline at end of file diff --git a/commands/level/rank.js b/commands/level/rank.js new file mode 100644 index 0000000..dd54d9a --- /dev/null +++ b/commands/level/rank.js @@ -0,0 +1,24 @@ +const canvacord = require('canvacord') + +const Levels = require('discord-xp') + +const {MessageAttachment} = require('discord.js') +module.exports = { + name: 'rank', + category: "Level[Beta]", + run: async (client, message, args) => { + const userData = await Levels.fetch(message.author.id, message.guild.id) + const requiredXP = (userData.level +1) * (userData.level +1) *100 // Enter the formula for calculating the experience here. I used mine, which is used in discord-xp. + const rank = new canvacord.Rank() + .setAvatar(message.author.displayAvatarURL({format: "png", size: 1024})) + .setProgressBar("#F0F6FF", "COLOR") + .setBackground("IMAGE", "https://cdn.discordapp.com/attachments/823585354569351208/843216311257137172/image0.jpg") + .setCurrentXP(userData.xp) + .setLevel(userData.level) + .setRequiredXP(requiredXP) + .setUsername(message.author.username) + .setDiscriminator(message.author.discriminator) + const img = await rank.build() + message.channel.send(new MessageAttachment(img, "AbotRankCard.png")) + } +} \ No newline at end of file