4.1.0 • Published 4 years ago

teamy v4.1.0

Weekly downloads
10
License
AGPL-3.0-or-later
Repository
github
Last release
4 years ago

NPM

teamy

A powerful library to manage teams with your own database\ Made by HarmoGlace

Table of Contents

Installation

With npm

$ npm install teamy

With yarn

$ yarn add teamy

Recommended node version: 14.12.0 (Current)\ Required node version: 14.4.0

Example usage

For a basic teams system using enmap as database provider:

const { TeamsManager } = require('teamy');
const Enmap = require('enmap');
const points = new Enmap({name: 'points'});

const manager = new TeamsManager({
        teams: [
            {
                id: 'cool_team',
                name: 'A pretty cool team'
            },
            {
                id: 'another_cool_team',
                name: 'Another cool team'
            }
        ],
        functions: { // Can be async functions or can return a promise
            setPoints: (team, points) => points.set(team.id, points),
            getPoints: (team) => points.get(team)
        }
});

const coolTeam = manager.get('cool_team');

coolTeam.points.add(500);

coolTeam.points.get(); // returns 500

manager.toArray() // returns an array of all teams

manager.resolve('a pretty cool team') // returns 'a pretty cool team' Team

For an advanced system with parent teams and sub teams and team detection with a role (using discord.js) :

const { TeamsManager } = require('teamy');
const { Client } = require('discord.js');
const client = new Client();
const Enmap = require('enmap');
const pointsDB = new Enmap({name: 'points'});

const manager = new TeamsManager({
    type: 'advanced',
    teams: [
            {
                id: 'parent1',
                role: '123456789', // Optional
                subs: [
                    {
                        id: 'sub1',
                        role: '123456789' // optional, used to detect member role if a client and a guildId are given
                    }
                ]
            },
            {
                id: 'parent2',
                subs: [
                    {
                        id: 'sub2',
                        role: '23456789'
                    }
                ]
            }
        ],
    functions: { // Needed. Used to save points, you can use the database that you want, here it is enmap
        setPoints: (team, points) => pointsDB.set(team.id, points),
        getPoints: (team) => pointsDB.get(team.id)
    },
    client,
    guild: '123456789' // guild Id where these teams belong to. It will be used to get roles
});

const sub1 = manager.get('sub1');

sub1.points.add(153);

sub1.points.get() // return 153

sub1.parent // returns parent Team

client.on('message', message => {
    const team = manager.functions.getMemberTeam(message.member); // returns the member team or null if none is found. See below example for an easier way to do it
})

API Reference

The api reference is available at teamy.harmoglace.fr

How to have a team property on GuildMembers with implement TeamsManager option optional

Type: Boolean\ Options passed to the TeamsManager, if set to true, it will enable team and teams properties on each GuildMember.\ For that you need to instantiate your client after creating the TeamsManager\ Example (using a basic manager and with enmap as DB provider):

const { TeamsManager } = require('teamy');
const Enmap = require('enmap');
const points = new Enmap({name: 'points'});

const manager = new TeamsManager({
        teams: [
            {
                id: 'cool_team',
                name: 'A pretty cool team'
            },
            {
                id: 'another_cool_team',
                name: 'Another cool team'
            }
        ],
        functions: {
            setPoints: (team, points) => points.set(team.id, points),
            getPoints: (team) => points.get(team),
   
            getMemberTeam: (member, teams) => teams.find(team => member.roles.cache.has(team.roleId)
        },
        guild: '123456',  // guild Id where all roles are from
        implement: true
});

const { Client } = require('discord.js');
const client = new Client();

manager.client = client;

client.on('message', message => {
    message.member.team; // Returns the member team or null if none is found
})

How to contribute

Please note that teamy is still in development.\ If you are here it means that you want to help me, thank you !

To contribute, create a fork of your this project, edit the things that you want and create a Pull Request.

Feedback

Report an issue

If you want to report an issue, open an issue here using the bug report template\ Please check that you have the required node version at least and that you have the latest version of teamy

Suggest something

If you want to suggest something you are welcome !\ Open an issue here using the suggestion template.

Support

Do you need help ? Join the Teamy Discord server

4.1.0

4 years ago

4.1.0-beta.2

4 years ago

4.1.0-beta.0

4 years ago

4.1.0-beta.1

4 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

4.0.0-beta.8

4 years ago

4.0.0-beta.7

4 years ago

4.0.0-beta.6

4 years ago

4.0.0-beta.5

4 years ago

4.0.0-beta.4

4 years ago

4.0.0-beta.3

4 years ago

4.0.0-beta.2

4 years ago

4.0.0-beta.1

4 years ago

4.0.0-beta.0

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.3.3

4 years ago

2.3.2

4 years ago

2.3.0

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.3.1

4 years ago

2.1.0

4 years ago

2.0.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.10

4 years ago

0.5.8

4 years ago

0.5.7

4 years ago

0.5.9

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.4

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.1.3

4 years ago

0.3.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago