I am a med school school student who coding part-time.
Activity summary by GitHub Readme Stats.
A lightweight and easy to use economy framework for discord bots, uses MongoDB.
License: MIT License
I am a med school school student who coding part-time.
Activity summary by GitHub Readme Stats.
Hello everyone.
So I run in a problem where I can't locate where can be wrong, and this happens almost a month.. So maybe here I will manage to find, help or solution how can I fix this.
IN console always getting this error :
Failed to append xp: ValidationError: level: Cast to Number failed for value "NaN" at path "level"
when trying to install version 1.1.17 it returns the error "No matching version found for discord-xp@^1.1.17."
Hey, I wanted to join your discord support sever but link is expired / invalid. I got something to be asked and it's a lot of better to do it on your server, thank you
1.1.16
When I try using appendXp()
or subtractXp()
and the XP value is below 0, it logs a message to the console saying:
Failed to subtract XP: ValidationError: level: Cast to Number failed for value "NaN" (type number) at path "level"
It would be better if it threw an Error instead, so it would be easier to use it in cases like these, where you have to inform the user about it by catching it using a try-catch block.
Prototype pollution Schema.path in automattic/mongoose - GHSA-f825-f98c-gj3g
Depends on vulnerable versions of mongoose
mongoose <6.4.6
This is the code im using
`const Discord = require('discord.js')
const client = new Discord.Client()
const Levels = require("discord-xp");
Levels.setURL("mongodb://ug8yoeq4nlrnbbcawthl:gAGzjsntMZz6uIHLeyy3@bbrs0e7qsv3xczd-mongodb.services.clever-cloud.com:27017/");
module.exports = {
name: 'leaderboard',
asliases: ['ss', 'SS'],
async execute(message, args) {
const rawLeaderboard = await Levels.fetchLeaderboard(message.guild.id, 10); // We grab top 10 users with most xp in the current server.
if (rawLeaderboard.length < 1) return reply("Nobody's in leaderboard yet.");
const leaderboard = Levels.computeLeaderboard(client, rawLeaderboard); // We process the leaderboard.
const lb = leaderboard.map(e => ${e.position}. ${e.username}#${e.discriminator}\nLevel: ${e.level}\nXP: ${e.xp.toLocaleString()}
); // We map the outputs.
message.channel.send(**Leaderboard**:\n\n${lb.join("\n\n")}
);
}
}`
How can you set specific channels to not be able to gain XP from? like bot commands, etc.
when I'm using
Levels.xpFor(user.level);
It is giving error:
(node:4) UnhandledPromiseRejectionWarning: RangeError: Target level should be a positive number.
at Function.xpFor (/app/node_modules/discord-xp/index.js:303:32)
at Function.fetch (/app/node_modules/discord-xp/index.js:189:35)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Client.module.exports (/app/command.js:16:18)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I don't know why it's happening.
can somebody help?
Im using version: 1.1.13
Hey,
I noticed that the package version on GitHub and the package version on NPM doesn't match.
Is there any way you update the one on NPM ? It's not the latest version.
Thanks for understanding.
Kind regards.
Whenever I run the leaderboard command i get this error:
UnhandledPromiseRejectionWarning: TypeError: A client was not provided.
at Function.computeLeaderboard (C:\Users\****\****\****\node_modules\discord-xp\index.js:262:24)
at Object.execute (C:\Users\****\****\****\commands\leaderboard.js:13:42)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:10512) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a
catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag
`--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:10512) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Code:
let servericon = message.guild.iconURL;
const rawLeaderboard = await Levels.fetchLeaderboard(message.guild.id, 10);
if (rawLeaderboard.length < 1) return reply("Nobody's in leaderboard yet.");
const leaderboard = await Levels.computeLeaderboard(client, rawLeaderboard, true); // <- Error here!
const lb = leaderboard.map(e => `${e.position}. ${e.username}#${e.discriminator}`);
const lb2 = leaderboard.map(e => `Level: ${e.level} XP: ${e.xp.toLocaleString()}`);
const leaderboardEmbed = new MessageEmbed()
.setColor('#0077ff')
.setTitle('Leaderboard')
addFields({
name: `Name:`,
value: lb,
inline: true
}, {
name: `Level`,
value: lb2,
inline: true
}, )
.setThumbnail(servericon)
.setFooter('© All rights reserved', 'https://i.imgur.com/00MbJdg.png')
message.channel.send(leaderboardEmbed);˙
Hi! I created my cluster at mongoose But how can i get the URL
Which i need
Kindly guide me thanks
Your discord server invite shows as invalid
Hello, I was wondering if it is possible to limit the amount of time it takes for the experience to update, to ensure the bot does not get rate limited.
Is there anything you would like to see added to discord-xp
module? If yes, then state any suggestions in this issue.
I tried pulling the latest time a user got updated but it doesn't seem to update.
I am trying to set a delay on the xp gaining.
It stays the same time even though xp is getting added to the user.
I a trying to pull calculate it using the following code:
const user = await Levels.fetch(message.author.id, message.guild.id);
if (Date.now() - user.lastUpdated > 60000) {
console.log("added xp");
const hasLeveledup = await Levels.appendXp(
message.author.id,
message.guild.id,
randomXP
);
How do I add a working rank for my rank command
Solved
How do I fix this???
I get this error
(node:16100) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fetch' of undefined
at Function.computeLeaderboard (C:\Users\Stijn Dusseldorp\Desktop\Code\Discord-Bot\node_modules\discord-xp\index.js:271:41)
at Object.execute (C:\Users\Stijn Dusseldorp\Desktop\Code\Discord-Bot\commands\leaderboard.js:11:42)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Usenode --trace-warnings ...
to show where the warning was created)
(node:16100) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:16100) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
When I execute this piece of code
`const Levels = require('discord-xp')
module.exports = {
name: 'leaderboard',
description: 'Displays the servers top 10 leveled users',
async execute(message, args, Discord, client) {
const rawLeaderboard = await Levels.fetchLeaderboard(message.guild.id, 10); // We grab top 10 users with most xp in the current server.
if (rawLeaderboard.length < 1) return reply("Nobody's in leaderboard yet.");
const leaderboard = await Levels.computeLeaderboard(client, rawLeaderboard, true); // We process the leaderboard.
const lb = leaderboard.map(e => `${e.position}. ${e.username}#${e.discriminator}\nLevel: ${e.level}\nXP: ${e.xp.toLocaleString()}`); // We map the outputs.
message.channel.send(`**Leaderboard**:\n\n${lb.join("\n\n")}`);}
}`
@MrAugu The package is replacing all the 0's on the leaderboard with a comma.
Example:
If it's a code error (which I don't think it is because it was working perfectly fine before today), here's my code:
On the message the bot creates duplicates of that. If I manually delete the dbs it won't break only for new users.
in guildDelete event I try to delete guild with
await <Levels>.deleteGuild(guild id here)
and it gives me time out error, latest discord-xp and mongoose 6.0.6
When I use the calculator I get the error (node:23572) UnhandledPromiseRejectionWarning: TypeError: options.message.inlineReply is not a function
. I have used the code from the example code section
I'm currently trying to make a leaderboard command. The one that was provided on the npm website didn't work for me, so I decided to try it myself. This is the code that I currently have:
And it returns this in the logs:
I don't know why this is happening or if I can fix it so any help is appreciated!
Is there a way to set a determined XP for each rank to rank up, instead of default XP for level 1 50XP, cause I want to use the XP package for a points system.
So I use following code -
var output = await leveling.Fetch(user.id)
var required = parseInt(output.level) + parseInt(1)
var xpRequired = leveling.xpFor(required);
My npm package is latest version but i get this error
Hello, i've created some leaderboard command, well, it was working for a moment, but now it's broken,
any ideas?
My code below:
const LB = await DiscordXp.computeLeaderboard(client, rawLB, true);
if (rawLB.length < 1) return interaction.reply({ content: "\`[ ❌ ]\` Na tym serwerze nikt nie ma poziomów!", ephemeral: true });
const l = LB.map(e => `\`${e.position}.\` <@${e.id}>:\n **Poziom: ${e.level}**\n **XP: ${e.xp.toString()}**`);
interaction.reply({ embeds: [{
title: "Leaderboard serwera " + interaction.guild.name,
description: `${l.join("\n\n")}`,
color: "PURPLE"
}] });```
Can I add roles on leveling by checking certain levels for users ?
Also I need an invite to your server
Hey There! 👋
it would be awesome if you guys add a new method for getting someone's rank or leaderboard positron. I've made a RankCard and I can't be setting the position or the rank of them in the server.
If there is going to be a method, our work will be much eaiser. If there is other ways, Please include
is there a way to fetch current xp?
Hello, I think it would be quite nice to add a way to view how much xp a user needs to level up!
So... I created a leaderboard command in my code, and it works fine. Problem is that it only correctly identifies me in the server leaderboard, and several other users in my server have xp but are notated as "Unknown#0000" in the leaderboard. I copied the code for the leaderboard command from the discord-xp npm site word for word, but it's giving me this issue. Is there some way to fix this?
Feel free to contact me via Discord at DarkMageXOfficial#4355
Thanks,
DarkMageX
Hey! I have a problem. Whenever I try to manually override the Database, if I run 'mvl-rank' (the command for my rank card) my stats will get reset back to what they were prior to the override.
my rank card code:
const { guild } = message;
const target = message.mentions.users.first() || message.author;
const user = await Levels.fetch(target.id, message.guild.id);
const guildinfo = guild.members.cache.get(target.id);
const join = new Date(guildinfo.joinedTimestamp);
const currentDate = new Date();
const elapsetime = currentDate - join;
const joins = Math.floor((((elapsetime / 1000) / 60) / 60) / 24);
const joined = joins + 1; // If it is actually just one day off
//message.channel.send(joined.toString() + " Days ago")
if (!user) return message.channel.send(`You currently don't have xp. Go send some messages`);
const neededXp = Levels.xpFor(parseInt(user.level) + 1);
`const Levels = require('discord-xp');
module.exports = {
name: 'leaderboard',
aliases: ['ldrboard'],
description: 'Displays the servers top 5 leveled users.',
async execute(message, args, db, client) {
const rawLeaderboard = await Levels.fetchLeaderboard(message.guild.id, 5);
if (rawLeaderboard.length < 1) return reply("Nobody's in leaderboard yet.");
const leaderboard = await Levels.computeLeaderboard(client, rawLeaderboard, true); // We process the leaderboard.
const lb = leaderboard.map(e => `${e.position}. ${e.username}#${e.discriminator}\nLevel: ${e.level}\nXP: ${e.xp.toLocaleString()}`); // We map the outputs.
message.channel.send(`**Leaderboard**:\n\n${lb.join("\n\n")}`);
},
};`
Whenever I use this command I get duplicated values as such
https://prnt.sc/13h7t1q
I believe the Discord invite link referenced in your README has expired, it would be awesome if you could replace it with another link that will never expire.
👋 canvacord has reached v6 which comes with breaking changes, also moving away from canvas for image generation for flexibility and it means that existing examples dont really work anymore.
Here is an example on how use builtin xp card builder in v6. While I am not familiar with discord.js, this example is based on the previous example mentioned in this repository.
const { RankCardBuilder, Font } = require('canvacord');
// place it outside of the command function
Font.loadDefault(); // or load your own font!
const target = message.mentions.users.first() || message.author; // Grab the target.
const user = await Levels.fetch(target.id, message.guild.id, true); // Selects the target from the database.
const rank = new RankCardBuilder() // Build the Rank Card
.setAvatar(target.displayAvatarURL({format: 'png', size: 512}))
.setCurrentXP(user.cleanXp) // Current User Xp for the current level
.setRequiredXP(user.cleanNextLevelXp) //The required Xp for the next level
.setRank(user.position) // Position of the user on the leaderboard
.setLevel(user.level) // Current Level of the user
.setUsername(target.username)
.setDisplayName(target.displayName);
rank.build({ format: 'png' })
.then(data => {
// consume the image
});
For flexibility, canvacord now has setProgressCalculator to determine the width of the progress bar.
.setProgressCalculator(() => {
return Math.floor(Math.random() * 100); // return random width (0-100)
})
There is an error trying to use it in the typecast. @types/discode-xp cannot be downloaded.
I installed the (typescript) package in my project with no issues. When I import it into my messageCreate
event, all of my current mongoose schema imports type never | null
as of version 1.1.19. See attached images.
After importing in event with discord-xp-typescript
As I install discord-xp
into my project my imports auto change to type any
.
I updated ALL of my existing node_modules to latest versions before creating this issue.
Node version is 16.19.0
Discord.js v14.7.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.