1.3.3 • Published 2 years ago

discord-birthday-wisher v1.3.3

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

discord-birthday-wisher

  • discord-birthday-wisher is a powerful npm package that wishes everyone a happy birthday on their birthday, uses MongoDB.
  • If you need help feel free to join our discord server to talk and help you with your code.
  • If you encounter any of issues fell free to open an issue in our github repository.

Download & Update

You can download it from npm:

npm install discord-birthday-wisher

You can update to a newer version to receive updates using npm.

npm update discord-birthday-wisher

Changelog

  • 8 July 2022 (v1.3.3) - Fixed bug in changeBirthday() assigning wrong birthday month.
  • 7 July 2022 (v1.3.0) - Changed
<Birthday>.BirthdayDay;
<Birthday>.BirthdayMonth;
<Birthday>.BirthdayYear;
<Birthday>.BirthdayFull;

to

<Birthday>.Day;
<Birthday>.Month;
<Birthday>.Year;
<Birthday>.Full;
  • 6 July 2022 (v1.1.0) - Grand Launch.

Quick Example

/* setBirthday Example */
const Birthdays = require("discord-birthday-wisher");
// Sets the birthday for a user to 08/11/2005.
const myBirthday = Birthdays.setBirthday("611107142560382976", "753938142246994031", "753938142246994033", 8, 11, 2005);

console.log(myBirthday.Day); // Output: 8
console.log(myBirthday.Month); // Output: 11
console.log(myBirthday.Year); // Output: 2005
console.log(myBirthday.Full); // Output: 8/11/2005

Setting Up

First things first, we include the module into the project.

const Birthdays = require("discord-birthday-wisher");

After that, you need to provide a valid mongo database url, and set it. You can do so by:

See How to connect to MongoDB Atlas here

Birthdays.connectionURL("mongodb://..."); // You only need to do this ONCE per process.

Examples

Examples can be found in /test

Methods

setBirthday

Creates an entry in database for that birthday if it doesnt exist.

Birthdays.setBirthday(<UserID - String>, <GuildID - String>, <ChannelID - String>, <BirthdayDay - Number> , BirthdayMonth - Number>, <BirthdayYear - Number>);
  • Output:
Promise<Object>

deleteBirthday

If the birthday exists, deletes it.

Birthdays.deleteBirthday(<UserID - String>, <GuildID - String>);
  • Output:
Promise<Object>

changeBirthday

If the birthday exists, changes it to the new birthday date.

Birthdays.changeBirthday(<BirthdayDay - Number> , <BirthdayMonth - Number>, <BirthdayYear - Number>);
  • Output:
Promise<Object>

How it works

setBirthday

  1. First, it runs a check to validated the given parameters.
  2. Then, it creates a MongoDB document in your database that stores the information.
  3. After that, it uses node-schedule to schedule a job at the specified birthday date.
  4. Lastly, when we get to that date, it sends a message to the specified channel wishing the user a happy birthday.

deleteBirthday

  1. First, it runs a check to validated the given parameters.
  2. Then, it finds the MongoDB document that matches with the inforamtion and deletes this document.
  3. Lastly, it retrieves the node-schedule job and cancels it.

changeBirthday

  1. First, it runs a check to validated the given parameters.
  2. Then, it finds the MongoDB document that matches with the inforamtion and updates this document.
  3. Lastly, it retrieves the node-schedule job and updates it with the new date.

Have fun and happy birthdays! Made with ❤ by Abdelrahman.