npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

djs-simple-xp

v1.0.0-alpha.1

Published

The Discord XP System is a customizable, extensible system for managing XP, levels, and multipliers for users in a Discord bot. This system provides a structured approach to handle XP-related features in your Discord bot with support for different XP calc

Downloads

3

Readme

Discord XP System

The Discord XP System is a customizable, extensible system for managing XP, levels, and multipliers for users in a Discord bot. This system provides a structured approach to handle XP-related features in your Discord bot with support for different XP calculation methods and the ability to set multipliers for individual users or entire servers.

Table of Contents

Features

  • Calculate XP and levels using various methods, including linear, exponential, logarithmic, or custom calculations.
  • Set multipliers to adjust XP gains for individual users and entire servers.
  • Seamless integration with Discord.js and MongoDB for data storage.
  • Customizable configuration options to tailor the system to your needs.
  • Event-driven architecture for easy integration into your Discord bot.

Getting Started

Installation

To get started, you'll need to install the discord-xp-system package from npm:

npm install discord-xp-system

Usage

const { Client } = require('discord.js');
const { XpSystem } = require('discord-xp-system');

const client = new Client();
const xpSystem = new XpSystem({
  initialXP: 100,
  xpMode: 'per_user',
  xpCalculation: 'linear',
  mongoUri: 'mongodb://localhost:27017/xp-database',
  defaultMultiplier: 1, // Default multiplier
});

client.login('YOUR_BOT_TOKEN');

client.on('message', (message) => {
  if (message.content.startsWith('!addxp')) {
    // Add XP to a user
    const user = message.author;
    const guild = message.guild;
    const xpAmount = 100;
    xpSystem.xp.addXp(user, guild, xpAmount);
  }
});

Configuration

You can customize your XP system by configuring various options when creating an instance of XpSystem. Here's what each configuration option does:

  • initialXP: The initial XP when a user starts.
  • xpMode: XP mode (per user or per guild).
  • xpCalculation: XP calculation logic (linear, exponential, logarithmic, custom).
  • customXpCalculation: Custom XP calculation function (optional).
  • mongoUri: MongoDB URI for database connection.
  • defaultMultiplier: Default multiplier for XP gain.

XP Calculation

You can choose from several XP calculation methods:

  • Linear: Linear progression logic.
  • Exponential: Exponential progression logic.
  • Logarithmic: Logarithmic progression logic.
  • Custom: Provide your own XP calculation function.

Multipliers

The system supports multipliers to adjust XP gains during special events or promotions. You can set both user-specific and server-specific multipliers.

User-Specific Multipliers

You can set a user-specific multiplier to adjust XP gains for individual users. This is useful for providing special XP rates to specific users.

xpSystem.multipliers.setUserMultiplier(userId, multiplier);

Server-Specific Multipliers

Server-specific multipliers allow you to adjust XP gains for an entire server. This can be handy for events that affect all users in a server.

xpSystem.multipliers.setServerMultiplier(serverId, multiplier);

Database

The XP System uses MongoDB for data storage. Make sure to provide a valid MongoDB URI when configuring the system.

Examples

For more advanced usage and integration into your Discord bot, check out the examples provided in the examples/ directory of this package.

Contributing

Contributions are welcome! Feel free to open issues or pull requests on the GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Enjoy using the Discord XP System in your Discord bot! If you have any questions or encounter any issues, feel free to reach out for assistance.