Dateien nach "commands/level" hochladen
This commit is contained in:
parent
a87d20e238
commit
d7ed75660f
|
@ -0,0 +1 @@
|
|||
|
|
@ -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);
|
||||
} }
|
|
@ -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"))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue