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

discord-birthday

v1.2.3

Published

discord-birthday is a powerful package that allows you to create a birthday system on your discord bot easily and quickly.

Downloads

10

Readme

Discord Birthday

discord-birthday is a powerful package that allows you to create a birthday system on your discord bot easily and quickly.

Installation

Download package

npm install discord-birthday
npm install @ayrozdzn/discord-birthday
yarn add discord-birthday

Connect to your discord bot

const { Birthday, Timezone } = require("discord-birthday"); // or @ayrozdzn/discord-birthday
const { Client } = require("discord.js");

const client = new Client({ ... });

client.birthday = new Birthday(client, {
    timezone: Timezone.UTC,
    hour: 10,
    minute: 0,
});

| Parameter | Type | Optional | Default | Description | |--|--|--|--|--| | client | Client | | | The discord client | | timezone | Timezone | ✓ | Timezone.UTC | Your timezone | | hour | Number | ✓ | 10 | A number between 0 and 23 | | minute | Number | ✓ | 0 | A number between 0 and 59 |

Methods

setUserBirthday

client.birthday.setUserBirthday(user, date, seeAge)

| Parameter | Type | Optional | Default | Description | |--|--|--|--|--| | user | User | | | The user whose birthday is to be set | | date | Date | | | The birthday date | | seeAge | Boolean | ✓ | true | Set the visibility variable accessible after |

returns : Birthday

getUserBirthday

client.birthday.getUserBirthday(user).then((birthday) => {
    console.log(birthday)
    /*
    {
        user: <User>,
        seeAge: <Boolean>,
        date: <Date>,
        age: <Number>,
        nextBirthday: <Date>,
        daysBeforeNext: <Number>,
        guilds: <Array<Guild>>,
    }
    */
}).catch((err) => console.error(err));

| Parameter | Type | Description | |--|--|--| | user | User | The user whose birthday is to be collected |

returns : Promise <Object>

deleteUserBirthday

client.birthday.deleteUserBirthday(user)

| Parameter | Type | Description | |--|--|--| | user | User | The user whose birthday is to be delete |

returns : Birthday

getGuildBirthdays

client.birthday.getGuildBirthdays(guild).then((birthdays) => {
    console.log(birthdays)
    /*
    [
        {
            member: <GuildMember>,
            seeAge: <Boolean>,
            date: <Date>,
            age: <Number>,
            nextBirthday: <Date>,
            daysBeforeNext: <Number>,
            guild: <Guild>
        },
        ...
    ]
    */
}).catch((err) => console.error(err));

| Parameter | Type | Description | |--|--|--| | guild | Guild | The guild in which the birthdays are to be collected |

returns : Promise <Array[Object]>

activateMemberBirthday

client.birthday.activateMemberBirthday(member) // return error if already activated or member has no birthday set

| Parameter | Type | Description | |--|--|--| | member | GuildMember | The member whose birthday is to be activated |

returns : Birthday

deactivateMemberBirthday

client.birthday.deactivateMemberBirthday(member) // return error if already deactivated or member has no birthday set

| Parameter | Type | Description | |--|--|--| | member | GuildMember | The member whose birthday is to be deactivated |

returns : Birthday

checkMemberGuildBirthdaysStatus

const status = client.birthday.checkMemberGuildBirthdaysStatus(member) // returns true or false

| Parameter | Type | Description | |--|--|--| | member | GuildMember | The member whose birthday is checked |

returns : boolean

setGuildBirthdayChannel

client.birthday.setGuildBirthdayChannel(channel)

| Parameter | Type | Description | |--|--|--| | channel | TextChannel | The channel in which the birthdays will be wished |

returns : Birthday

getGuildBirthdayChannel

client.birthday.getGuildBirthdayChannel(guild).then((channel) => {
    console.log(channel) /* <NonThreadGuildBasedChannel> */
}).catch((err) => console.error(err));

| Parameter | Type | Description | |--|--|--| | guild | Guild | The guild in which the channel is to be collected |

returns : Promise <GuildChannel>

deleteGuildBirthdayChannel

client.birthday.deleteGuildBirthdayChannel(guild)

| Parameter | Type | Description | |--|--|--| | guild | Guild | The guild in which the birthdays channel will be delete |

returns : Birthday

Events

isBirthday

client.birthday.on("isBirthday", (user, guilds) => {
    console.log(`The birthday of ${user.tag} has been wished in ${guilds.length}`);
    guilds.forEach(guild => {
        guild.channels.get("...").send({content: `It's the birthday of ${member.user.tag}`})
    })
});

| Parameter | Type | Description | |--|--|--| | user | User | The user whose birthday has been wished | | guilds | Array <Guild> | Array of all guild where the birthday has been wished |

birthdayUserSet

client.birthday.on("birthdayUserSet", (user, date) => {
    console.log(`The birthday of ${user.tag} is ${date.toDateString()}`);
});

| Parameter | Type | Description | |--|--|--| | user | User | The user whose birthday has been set up | | date | Date | The birthday date |

birthdayUserDelete

client.birthday.on("birthdayUserDelete", (user) => {
    console.log(`The birthday of ${user.tag} has been delete`);
});

| Parameter | Type | Description | |--|--|--| | user | User | The user whose birthday has been deleted |

birthdayMemberActivate

client.birthday.on("birthdayMemberActivate", (member) => {
    console.log(`The birthday of ${member.user.tag} has been activated in ${member.guild.name}`);
});

| Parameter | Type | Description | |--|--|--| | member | GuildMember | The member whose birthday has been activated |

birthdayMemberDeactivate

client.birthday.on("birthdayMemberDeactivate", (member) => {
    console.log(`The birthday of ${member.user.tag} has been deactivated in ${member.guild.name}`);
});

| Parameter | Type | Description | |--|--|--| | member | GuildMember | The member whose birthday has been deactivated |

birthdayGuildChannelSet

client.birthday.on("birthdayGuildChannelSet", (channel) => {
    console.log(`The birthday channel ${channel.name} has been set for the guild ${channel.guild.name}`);
});

| Parameter | Type | Description | |--|--|--| | channel | GuildChannel | The channel whose birthday channel has been set up |

birthdayGuildChannelDelete

client.birthday.on("birthdayGuildChannelSet", (guild) => {
    console.log(`The birthday channel of ${guild.name} has been delete`);
});

| Parameter | Type | Description | |--|--|--| | guild | Guild | The Guild whose birthday channel has been delete |