UNPKG

sectom

Version:

Sectom is a useful npm package that has multiple easy to use functions.

457 lines (287 loc) 12.2 kB
<!-- -- This file is auto-generated from README_js.md. Changes should be made there. --> <div align="center"> <h1>Sectom</h1> </div> <div align="center"> <p>Sectom is a useful npm package that has multiple easy to use functions..</p> <p> <a href="https://www.npmjs.com/package/sectom"><img src="https://img.shields.io/npm/v/sectom?maxAge=3600" alt="NPM version" /></a> <a href="https://www.npmjs.com/package/sectom"><img src="https://img.shields.io/npm/dt/sectom?maxAge=3600" alt="NPM downloads" /></a> </p> <p> <a href="https://nodei.co/npm/sectom/"><img src="https://nodei.co/npm/sectom.png?downloads=true&stars=true" alt="NPM info" /></a> </p> </div> ## ┃Getting Started - You need to install [**Node.js V12 or Later**](https://nodejs.org/en/download/) - You might need to install [**Discord.js**](https://www.npmjs.com/package/discord.js?source=post_page) - [**Discord JS Docs**](https://discord.js.org/#/docs/main/master/general/welcome) - [**Discord JS Guide**](https://discordjs.guide/) ## Quickstart After you have downloaded node js or/and discord js you can start by entering this command in the terminal: ```shell $ npm install sectom ``` ## ℹ┃Information ### functions: - [`propercase()`](https://www.npmjs.com/package/sectom#propercase) - Functions that makes the start of each word in a string a capital letter. - [`capitalize()`](https://www.npmjs.com/package/sectom#capitalize) - Function that makes the start of a string a capital letter. - [`switch()` (quick DB)](https://www.npmjs.com/package/sectom#switchquickdb) - Functions that switches the value of two keys around for quick.DB. - [`switch()` (quickmongo)](https://www.npmjs.com/package/sectom#switchquickmongo) - Functions that switches the value of two keys around for quickmongo. - [`DateDiffer()`](https://npmjs.com/package/sectom#datediffer) - Function that tells you the difference between two dates. - [`stringToBoolean()`](https://www.npmjs.com/package/sectom#stringtoboolean) - Functions that converts a string to a boolean. - [`ordinal_suffix()`](https://www.npmjs.com/package/sectom#ordinal_suffix) - Function that returns a string with the correct suffix ending - [`randomNumber()`](https://npmjs.com/package/sectom#randomnumber) - Function that generates a random number between two numbers of your choice - [`onlyNumericalString()`](https://npmjs.com/package/sectom#onlynumericalstring) - Function that returns a string only including numerical values. - [`onlyAlphabeticalString()`](https://npmjs.com/package/sectom#onlyalphabeticalstring) - Function that returns a string only including alphabetical values. - [`removeEmojis()`](https://npmjs.com/package/sectom#removeemojis) - Function that removes any emojis from a string. - [`isBST()`](https://npmjs.com/package/sectom#isbst) - Function that returns a boolean value stating if it is currently British Summer Time - [`yomomma()`](https://npmjs.com/package/sectom#yomomma) - Function that generates a string with a "yomamma" joke - [`urban()`](https://npmjs.com/package/sectom#urban) - Function to generate an embed describing a word from the urban API - [`generateDiscordMemeEmbed()`](https://npmjs.com/package/sectom#generatediscordmemeembed) - Function that generates an embed with a meme. - [`isEmptyObject()`](https://npmjs.com/package/sectom#isemptyobject) - Function that returns a boolean value stating if an object is empty or not. ### Classes: - [`DB`](https://www.npmjs.com/package/sectom#db) - A class with helpful function for both **Quick.DB** and **Quick Mongo** <hr> <br> <br> # ┃Functions: ## propercase propercase is a quick and easy to use function that converts a string into a propercase form **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { propercase } = modules; console.log(propercase("the quick brown fox")); // The Quick Brown Fox ``` ## capitalize capitalize is a quick and easy to use function that converts the first character of a string into a capitalize form **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { capitalize } = modules; console.log(capitalize("the quick brown fox")); // The quick brown fox ``` ## switchQuickDB switch is a useful function for quick mongo users and quick db users, it switches the value of two different keys around with one another **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); const db = require("quick.db"); // Object destructuring const { modules } = sectom; const { quickDB } = modules.DB; const keyOne = "myServers"; const keyTwo = "myUsers"; quickDB.switch(db, keyOne, keyTwo); // returns true if there was a success ``` ## switchQuickMongo switch is a useful function for quick mongo users and quick db users, it switches the value of two different keys around with one another **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); const { Database } = require("quickmongo"); const db = new Database("url"); // Object destructuring const { modules } = sectom; const { quickMongo } = modules.DB; const keyOne = "myServers"; const keyTwo = "myUsers"; quickMongo.switch(db, keyOne, keyTwo); // returns true if there was a success ``` ## DateDiffer DateDiffer is a very helpful function which gives you a string showing the differences between two dates **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { DateDiffer } = modules; console.log(DateDiffer("2011-10-05T14:48:00.000Z")); // "9 years 9 months 8 days 2 hours and 56 minutes ago" console.log(DateDiffer("2011-10-05T14:48:00.000Z", false)); // "9 years 9 months 8 days and 2 hours ago" console.log(DateDiffer("2011-10-05T14:48:00.000Z"), true, true); // "**9** years **9** months **8** days **2** hours and **56** minutes ago" console.log(DateDiffer("2011-10-05T14:48:00.000Z", false, true)); // "**9** years **9** months **8** days and **2** hours ago" ``` ## formatter formatter is a massive module for discord message markdowns and formats and allows you to quickly bold, italic, underline, use codeblocks, and more! **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { formatter } = sectom; console.log(formatter.defaults.bold("")); ``` ## stringToBoolean stringToBoolean is a helpful function that converts a string into a boolean value **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { stringToBoolean } = modules; stringToBoolean("true"); // returns true stringToBoolean("yes"); // returns true console.log(stringToBoolean("no")); // false ``` ## ordinal_suffix ordinal_suffix is a function that returns a string with the ordinal suffix **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { ordinal_suffix } = modules; console.log(ordinal_suffix("1")); // 1st console.log(ordinal_suffix(2)); // 2nd console.log(ordinal_suffix("3")); // 3rd console.log(ordinal_suffix(4)); // 4th ``` ## randomNumber randomNumber is a helpful function that generates a random number between your choices **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { randomNumber } = modules; console.log(randomNumber(1, 10)); // any number between 1-10m, 1 being included and 10 not being included ``` ## onlyNumericalString onlyNumericalString is a regex function that removes anything in a string that is not numerical **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { onlyNumericalString } = modules; console.log(onlyNumericalString("123abc")); // 123 ``` ## onlyAlphabeticalString onlyAlphabeticalString is a regex function that removes anything in a string that is not alphabetical **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { onlyAlphabeticalString } = modules; console.log(onlyAlphabeticalString("123abc")); // abc ``` ## removeEmojis removeEmojis is a regex function that removes anything in a string that is an emoji **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { removeEmojis } = modules; console.log(removeEmojis("🧡🧡💔Hello")); // Hello ``` ## isBST isBST is a helpful function that checks if it is currently British Summer Time **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { isBST } = modules; console.log(isBST()); // true if it is and false if it is not BST ``` ## getLondonTime getLondonTime is a helpful function that checks the current time or a given time in London **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { getLondonTime } = modules; console.log(getLondonTime()); // returns the current date in London console.log(getLondonTime(/**a passed in date */)); // returns the current date in London ``` ## yomomma yomomma is a funny function that returns a "yomomma" joke **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { yomomma } = modules; console.log(yomomma()); // a possible outcome is: // "Yo mama is so fat that Weight Watchers said I give up" ``` ## urban urban is a funny function that makes a discord embed for a word in the urban API **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { urban } = modules; console.log(urban("wagwan")); // this will return an embed or a embed JSON (if the second paramater is set to false) // a possible outcome of a word is: // "[Wagwan] is a greeting that only [roadmen] of [lvl] 10 can use this greeting is an abbreviation of \"Whats going on?\"" ``` ## generateDiscordMemeEmbed generateDiscordMemeEmbed is a funny function that makes a discord embed for generated meme **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { generateDiscordMemeEmbed } = modules; const discord = require("discord.js"); const client = new discord.Client(); // Discord JS v13 client.on("messageCreate", async (message) => { if (message.content == "!meme") message.channel.send(generateDiscordMemeEmbed()); }); // Discord JS v12 client.on("message", async (message) => { if (message.content == "!meme") message.channel.send(generateDiscordMemeEmbed()); }); client.login("token"); // this will send an embed or a embed JSON (if the second paramater is set to false) ``` ## isEmptyObject isEmptyObject is a useful function that returns a boolean stating if an object is empty or not **Example:** ```javascript // Requiring Sectom const sectom = require("sectom"); // Object destructuring const { modules } = sectom; const { isEmptyObject } = modules; const obj = {}; console.log(isEmptyObject(obj)); // true const obj2 = { a: 2, }; console.log(isEmptyObject(obj2)); // false ```