Giter Site home page Giter Site logo

discord-xp's Introduction

Hey, I'm MrAugu (a.k.a. Augu)

I am a high school student who loves coding.

GitHub Activity

 mraugu

Activity summary by GitHub Readme Stats.

discord-xp's People

Contributors

androz2091 avatar gruselhaus avatar lebyy avatar marcrock22 avatar mraugu avatar mrauro avatar myst82015 avatar needhamgary avatar shoxie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

discord-xp's Issues

Leveling.xpFor() is not a function??

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

Calculator doesn't work

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

Leaderboard duplicate entries

`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 need help

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);˙

Bad typings

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.

Before importing in event.
image

After importing in event with discord-xp-typescript
image

As I install discord-xp into my project my imports auto change to type any.

Before installing package.
image

After installing the package.
image

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

RangeError: Target level should be a positive number.

RangeError: Target level should be positive number.

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

Cant delete user or guild

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

0's on leaderboard not showing

@MrAugu The package is replacing all the 0's on the leaderboard with a comma.
Example:
image
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:
image

Roles on levelling

Can I add roles on leveling by checking certain levels for users ?
Also I need an invite to your server

Leaderboard Command Acting Weird

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?

Image:
Screen Shot 2020-11-06 at 12 05 02 PM

Feel free to contact me via Discord at DarkMageXOfficial#4355

Thanks,
DarkMageX

How to use mongoose

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

[Bug] Throw errors instead of logging to console in appendXp() / subtractXp()

Package version

1.1.16

Issue description

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.

DiscordCanary_l8YAVMMKUl

canvacord example is outdated

👋 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)
})

Failed to append xp

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"

Expired Discord link.

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.

.setURL() not working

I am getting a error whenever I run the code.
I have attached the error and please tell me how to resolve it.
Screenshot 2022-01-17 231816

Manual override of db gets reset

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);

e.id is undefined.

Hello, i've created some leaderboard command, well, it was working for a moment, but now it's broken,
image
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"
        }] });```

Leaderboards user returning as Unknown#0000

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")});
}
}`

Xp per rank

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.

Getting the position(rank) of a member/user

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

Update NPM Package.

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.

Update MQuery

Could you update the version of MQuery required to use this? The current one is being labelled as vulnerable.
image

typescript

There is an error trying to use it in the typecast. @types/discode-xp cannot be downloaded.

Accepting Suggestions

Is there anything you would like to see added to discord-xp module? If yes, then state any suggestions in this issue.

Error with computeLeaderboard

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)
(Use node --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")}`);}

}`

lastUpdated in db

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
    );

No-XP Channel

How can you set specific channels to not be able to gain XP from? like bot commands, etc.

Limiting Experience Update Frequency

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.

Discord Invite Link Isn't Working

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.