1.2.3 • Published 2 years ago

discord-birthday v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Discord Birthday

npm.io npm.io npm.io

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,
});
ParameterTypeOptionalDefaultDescription
clientClientThe discord client
timezoneTimezoneTimezone.UTCYour timezone
hourNumber10A number between 0 and 23
minuteNumber0A number between 0 and 59

Methods

setUserBirthday

client.birthday.setUserBirthday(user, date, seeAge)
ParameterTypeOptionalDefaultDescription
userUserThe user whose birthday is to be set
dateDateThe birthday date
seeAgeBooleantrueSet 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));
ParameterTypeDescription
userUserThe user whose birthday is to be collected

returns : Promise [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)

deleteUserBirthday

client.birthday.deleteUserBirthday(user)
ParameterTypeDescription
userUserThe 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));
ParameterTypeDescription
guildGuildThe guild in which the birthdays are to be collected

returns : Promise [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\[[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)\]

activateMemberBirthday

client.birthday.activateMemberBirthday(member) // return error if already activated or member has no birthday set
ParameterTypeDescription
memberGuildMemberThe 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
ParameterTypeDescription
memberGuildMemberThe member whose birthday is to be deactivated

returns : Birthday

checkMemberGuildBirthdaysStatus

const status = client.birthday.checkMemberGuildBirthdaysStatus(member) // returns true or false
ParameterTypeDescription
memberGuildMemberThe member whose birthday is checked

returns : boolean

setGuildBirthdayChannel

client.birthday.setGuildBirthdayChannel(channel)
ParameterTypeDescription
channelTextChannelThe 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));
ParameterTypeDescription
guildGuildThe guild in which the channel is to be collected

returns : Promise [GuildChannel](https://discord.js.org/#/docs/discord.js/main/class/GuildChannel)

deleteGuildBirthdayChannel

client.birthday.deleteGuildBirthdayChannel(guild)
ParameterTypeDescription
guildGuildThe 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}`})
    })
});
ParameterTypeDescription
userUserThe user whose birthday has been wished
guildsArray \[Guild](https://discord.js.org/#/docs/discord.js/main/class/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()}`);
});
ParameterTypeDescription
userUserThe user whose birthday has been set up
dateDateThe birthday date

birthdayUserDelete

client.birthday.on("birthdayUserDelete", (user) => {
    console.log(`The birthday of ${user.tag} has been delete`);
});
ParameterTypeDescription
userUserThe 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}`);
});
ParameterTypeDescription
memberGuildMemberThe 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}`);
});
ParameterTypeDescription
memberGuildMemberThe 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}`);
});
ParameterTypeDescription
channelGuildChannelThe 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`);
});
ParameterTypeDescription
guildGuildThe Guild whose birthday channel has been delete
1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.5

2 years ago

1.1.43

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago