Skip to content

Commit

Permalink
Refactors
Browse files Browse the repository at this point in the history
* Somes methods don't have their first arg as optional anymore.
* authorisedUser -> authorizedUser & setAuthorisedUser -> setAuthorizedUser
  • Loading branch information
gazmull committed Mar 9, 2018
1 parent d14eec2 commit 8a6dd2f
Show file tree
Hide file tree
Showing 14 changed files with 262 additions and 707 deletions.
File renamed without changes.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# Discord.JS - Pagination Embed
A pagination utility for MessageEmbed in Discord.JS

`npm install gazmull/discord-paginationembed`
Installing the utility: `npm install gazmull/discord-paginationembed`

Requires Discord.JS: `npm install discordjs/discord.js`

# Compatibility
Currently supports Discord.JS v12.
Expand All @@ -14,19 +16,19 @@ Currently supports Discord.JS v12.
> ### Under `message` event
```js
const FieldsEmbedMode = require('discord-paginationembed').FieldsEmbed;
const { FieldsEmbed: FieldsEmbedMode } = require('discord-paginationembed');

new FieldsEmbedMode()
.setArray([ { name: "John Doe" }, { name: "Jane Doe" } ])
.setAuthorisedUser(message.author)
.setAuthorizedUser(message.author)
.setChannel(message.channel)
.setElementsPerPage(1)
.setPage(2)
.showPageIndicator(false)
.build();
```
```js
const EmbedsMode = require('discord-paginationembed').Embeds;
const { Embeds: EmbedsMode } = require('discord-paginationembed');
const { MessageEmbed } = require("discord.js");

const embeds = [];
Expand All @@ -38,7 +40,7 @@ const myImage = message.author.displayAvatarURL();

new EmbedsMode()
.setArray(embeds)
.setAuthorisedUser(message.author)
.setAuthorizedUser(message.author)
.setChannel(message.channel)
.showPageIndicator(true)
.setPage(3)
Expand All @@ -65,7 +67,7 @@ new EmbedsMode()
* Fork this repository.
* Execute `npm install`
* Code and code and code and code and... code!
* `npm test` to verify your additions/adjustments are following ESLint's rules and verify docs are valid.
* `npm test` to verify if your additions/adjustments are following ESLint's rules and to verify if the docs are valid.
* File a [Pull Request](https://github.com/gazmull/discord-paginationembed/compare)!

# License
Expand Down
320 changes: 80 additions & 240 deletions docs/Embeds.html

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions docs/Embeds.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<label for="nav-trigger" class="overlay"></label>

<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Embeds.html">Embeds</a><ul class='methods'><li data-type='method'><a href="Embeds.html#addBlankField">addBlankField</a></li><li data-type='method'><a href="Embeds.html#addField">addField</a></li><li data-type='method'><a href="Embeds.html#build">build</a></li><li data-type='method'><a href="Embeds.html#setArray">setArray</a></li><li data-type='method'><a href="Embeds.html#setAuthor">setAuthor</a></li><li data-type='method'><a href="Embeds.html#setAuthorisedUser">setAuthorisedUser</a></li><li data-type='method'><a href="Embeds.html#setChannel">setChannel</a></li><li data-type='method'><a href="Embeds.html#setClientMessage">setClientMessage</a></li><li data-type='method'><a href="Embeds.html#setColor">setColor</a></li><li data-type='method'><a href="Embeds.html#setDescription">setDescription</a></li><li data-type='method'><a href="Embeds.html#setEmojis">setEmojis</a></li><li data-type='method'><a href="Embeds.html#setFooter">setFooter</a></li><li data-type='method'><a href="Embeds.html#setImage">setImage</a></li><li data-type='method'><a href="Embeds.html#setPage">setPage</a></li><li data-type='method'><a href="Embeds.html#setThumbnail">setThumbnail</a></li><li data-type='method'><a href="Embeds.html#setTimeout">setTimeout</a></li><li data-type='method'><a href="Embeds.html#setTimestamp">setTimestamp</a></li><li data-type='method'><a href="Embeds.html#setTitle">setTitle</a></li><li data-type='method'><a href="Embeds.html#setURL">setURL</a></li><li data-type='method'><a href="Embeds.html#showPageIndicator">showPageIndicator</a></li></ul></li><li><a href="FieldsEmbed.html">FieldsEmbed</a><ul class='methods'><li data-type='method'><a href="FieldsEmbed.html#build">build</a></li><li data-type='method'><a href="FieldsEmbed.html#formatField">formatField</a></li><li data-type='method'><a href="FieldsEmbed.html#setArray">setArray</a></li><li data-type='method'><a href="FieldsEmbed.html#setAuthorisedUser">setAuthorisedUser</a></li><li data-type='method'><a href="FieldsEmbed.html#setChannel">setChannel</a></li><li data-type='method'><a href="FieldsEmbed.html#setClientMessage">setClientMessage</a></li><li data-type='method'><a href="FieldsEmbed.html#setElementsPerPage">setElementsPerPage</a></li><li data-type='method'><a href="FieldsEmbed.html#setEmojis">setEmojis</a></li><li data-type='method'><a href="FieldsEmbed.html#setPage">setPage</a></li><li data-type='method'><a href="FieldsEmbed.html#setTimeout">setTimeout</a></li><li data-type='method'><a href="FieldsEmbed.html#showPageIndicator">showPageIndicator</a></li></ul></li><li><a href="PaginationEmbed.html">PaginationEmbed</a><ul class='methods'><li data-type='method'><a href="PaginationEmbed.html#setArray">setArray</a></li><li data-type='method'><a href="PaginationEmbed.html#setAuthorisedUser">setAuthorisedUser</a></li><li data-type='method'><a href="PaginationEmbed.html#setChannel">setChannel</a></li><li data-type='method'><a href="PaginationEmbed.html#setClientMessage">setClientMessage</a></li><li data-type='method'><a href="PaginationEmbed.html#setEmojis">setEmojis</a></li><li data-type='method'><a href="PaginationEmbed.html#setPage">setPage</a></li><li data-type='method'><a href="PaginationEmbed.html#setTimeout">setTimeout</a></li><li data-type='method'><a href="PaginationEmbed.html#showPageIndicator">showPageIndicator</a></li></ul></li></ul><h3><a href="global.html">Global</a></h3>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Embeds.html">Embeds</a><ul class='methods'><li data-type='method'><a href="Embeds.html#addBlankField">addBlankField</a></li><li data-type='method'><a href="Embeds.html#addField">addField</a></li><li data-type='method'><a href="Embeds.html#build">build</a></li><li data-type='method'><a href="Embeds.html#setArray">setArray</a></li><li data-type='method'><a href="Embeds.html#setAuthor">setAuthor</a></li><li data-type='method'><a href="Embeds.html#setAuthorizedUser">setAuthorizedUser</a></li><li data-type='method'><a href="Embeds.html#setChannel">setChannel</a></li><li data-type='method'><a href="Embeds.html#setClientMessage">setClientMessage</a></li><li data-type='method'><a href="Embeds.html#setColor">setColor</a></li><li data-type='method'><a href="Embeds.html#setDescription">setDescription</a></li><li data-type='method'><a href="Embeds.html#setEmojis">setEmojis</a></li><li data-type='method'><a href="Embeds.html#setFooter">setFooter</a></li><li data-type='method'><a href="Embeds.html#setImage">setImage</a></li><li data-type='method'><a href="Embeds.html#setPage">setPage</a></li><li data-type='method'><a href="Embeds.html#setThumbnail">setThumbnail</a></li><li data-type='method'><a href="Embeds.html#setTimeout">setTimeout</a></li><li data-type='method'><a href="Embeds.html#setTimestamp">setTimestamp</a></li><li data-type='method'><a href="Embeds.html#setTitle">setTitle</a></li><li data-type='method'><a href="Embeds.html#setURL">setURL</a></li><li data-type='method'><a href="Embeds.html#showPageIndicator">showPageIndicator</a></li></ul></li><li><a href="FieldsEmbed.html">FieldsEmbed</a><ul class='methods'><li data-type='method'><a href="FieldsEmbed.html#build">build</a></li><li data-type='method'><a href="FieldsEmbed.html#formatField">formatField</a></li><li data-type='method'><a href="FieldsEmbed.html#setArray">setArray</a></li><li data-type='method'><a href="FieldsEmbed.html#setAuthorizedUser">setAuthorizedUser</a></li><li data-type='method'><a href="FieldsEmbed.html#setChannel">setChannel</a></li><li data-type='method'><a href="FieldsEmbed.html#setClientMessage">setClientMessage</a></li><li data-type='method'><a href="FieldsEmbed.html#setElementsPerPage">setElementsPerPage</a></li><li data-type='method'><a href="FieldsEmbed.html#setEmojis">setEmojis</a></li><li data-type='method'><a href="FieldsEmbed.html#setPage">setPage</a></li><li data-type='method'><a href="FieldsEmbed.html#setTimeout">setTimeout</a></li><li data-type='method'><a href="FieldsEmbed.html#showPageIndicator">showPageIndicator</a></li></ul></li><li><a href="PaginationEmbed.html">PaginationEmbed</a><ul class='methods'><li data-type='method'><a href="PaginationEmbed.html#setArray">setArray</a></li><li data-type='method'><a href="PaginationEmbed.html#setAuthorizedUser">setAuthorizedUser</a></li><li data-type='method'><a href="PaginationEmbed.html#setChannel">setChannel</a></li><li data-type='method'><a href="PaginationEmbed.html#setClientMessage">setClientMessage</a></li><li data-type='method'><a href="PaginationEmbed.html#setEmojis">setEmojis</a></li><li data-type='method'><a href="PaginationEmbed.html#setPage">setPage</a></li><li data-type='method'><a href="PaginationEmbed.html#setTimeout">setTimeout</a></li><li data-type='method'><a href="PaginationEmbed.html#showPageIndicator">showPageIndicator</a></li></ul></li></ul><h3><a href="global.html">Global</a></h3>
</nav>

<div id="main">
Expand Down Expand Up @@ -111,6 +111,7 @@ <h1 class="page-title">Embeds.js</h1>

/**
* The thumbnail of all embeds.
* @type {string}
*/
this.thumbnail = options.thumbnail || null;

Expand All @@ -135,7 +136,7 @@ <h1 class="page-title">Embeds.js</h1>

/**
* Embed in the current page.
* @returns {MessageEmbed} - An instance of MessageEmbed.
* @type {MessageEmbed}
*/
get currentEmbed() {
return this.array[this.page - 1];
Expand All @@ -144,7 +145,7 @@ <h1 class="page-title">Embeds.js</h1>
/**
* Adds a blank field to the fields of all embeds.
* @param {boolean} [inline=false] - Whether the field is inline or not to the other fields.
* @returns {Embeds} - Instance of Embeds
* @returns {PaginationEmbed}
*/
addBlankField(inline = false) {
const arr = this.array;
Expand All @@ -160,7 +161,7 @@ <h1 class="page-title">Embeds.js</h1>
* @param {string} name - The name of the field.
* @param {string} value - The value of the field.
* @param {boolean} [inline=false] - Whether the field is inline or not to the other fields.
* @returns {Embeds} - Instance of Embeds
* @returns {PaginationEmbed}
*/
addField(name, value, inline = false) {
if (!name &amp;&amp; !value) return this;
Expand All @@ -179,12 +180,12 @@ <h1 class="page-title">Embeds.js</h1>
* @example
*
* // Object as constructor.
* const Embeds = require('discord-paginationembed').Embeds;
* const { Embeds } = require('discord-paginationembed');
* const { MessageEmbed } = require('discord.js');
*
* // Under message event.
* new Embeds({
* authorisedUser: message.author,
* authorizedUser: message.author,
* channel: message.channel,
* clientMessage: { content: 'Preparing the embed...' },
* array: [
Expand All @@ -208,12 +209,12 @@ <h1 class="page-title">Embeds.js</h1>
* @example
*
* // Methods as constructor.
* const Embeds = require('discord-paginationembed').Embeds;
* const { Embeds } = require('discord-paginationembed');
* const { MessageEmbed } = require('discord.js');
*
* // Under message event.
* new Embeds()
* .setAuthorisedUser(message.author)
* .setAuthorizedUser(message.author)
* .setChannel(message.channel)
* .setClientMessage(null, 'Preparing the embed...')
* .setArray([
Expand Down Expand Up @@ -269,7 +270,7 @@ <h1 class="page-title">Embeds.js</h1>
/**
* Sets the array of embeds to paginate.
* @param {Array} array - An array of embeds to paginate.
* @returns {Embeds} - Instance of Embeds
* @returns {PaginationEmbed}
*/
setArray(array) {
const isValidArray = Array.isArray(array) &amp;&amp; Boolean(array.length);
Expand All @@ -290,7 +291,7 @@ <h1 class="page-title">Embeds.js</h1>
* @param {StringResolvable} name - The name of the author.
* @param {string} [iconURL=null] - The icon URL of the author.
* @param {string} [url=null] - The URL of the author.
* @returns {Embeds} - Instance of Embeds
* @returns {PaginationEmbed}
*/
setAuthor(name, iconURL = null, url = null) {
if (!name) return this;
Expand All @@ -306,7 +307,7 @@ <h1 class="page-title">Embeds.js</h1>
/**
* Sets the color of all embeds.
* @param {ColorResolvable} color - The color of all embeds.
* @returns {Embeds} - Instance of Embeds
* @returns {PaginationEmbed}
*/
setColor(color) {
if (!color) return this;
Expand All @@ -322,7 +323,7 @@ <h1 class="page-title">Embeds.js</h1>
/**
* Sets the description of all embeds.
* @param {string} description - The description of all embeds.
* @returns {Embeds} - Instance of Embeds
* @returns {PaginationEmbed}
*/
setDescription(description) {
if (!description) return this;
Expand All @@ -339,7 +340,7 @@ <h1 class="page-title">Embeds.js</h1>
* Sets the footer of all embeds.
* @param {string} text - The footer text.
* @param {string} [iconURL=null] - URL for the footer's icon.
* @returns {Embeds} - Instance of Embeds
* @returns {PaginationEmbed}
*/
setFooter(text, iconURL = null) {
if (!text) return this;
Expand All @@ -355,7 +356,7 @@ <h1 class="page-title">Embeds.js</h1>
/**
* Sets the image of all embeds.
* @param {string} image - The image of all embeds.
* @returns {Embeds} - Instance of Embeds
* @returns {PaginationEmbed}
*/
setImage(image) {
if (!image) return this;
Expand All @@ -371,7 +372,7 @@ <h1 class="page-title">Embeds.js</h1>
/**
* Sets the thumbnail of all embeds.
* @param {string} thumbnail - The thumbnail of all embeds.
* @returns {Embeds} - Instance of Embeds
* @returns {PaginationEmbed}
*/
setThumbnail(thumbnail) {
if (!thumbnail) return this;
Expand All @@ -386,7 +387,7 @@ <h1 class="page-title">Embeds.js</h1>

/**
* Sets the timestamp of all embeds.
* @returns {Embeds} - Instance of Embeds
* @returns {PaginationEmbed}
*/
setTimestamp() {
const arr = this.array;
Expand All @@ -400,7 +401,7 @@ <h1 class="page-title">Embeds.js</h1>
/**
* Sets the title of all embeds.
* @param {string} title - The title of all embeds.
* @returns {Embeds} - Instance of Embeds
* @returns {PaginationEmbed}
*/
setTitle(title) {
if (!title) return this;
Expand All @@ -416,7 +417,7 @@ <h1 class="page-title">Embeds.js</h1>
/**
* Sets the URL of all embeds.
* @param {string} url - The URL of all embeds.
* @returns {Embeds} - Instance of Embeds
* @returns {PaginationEmbed}
*/
setURL(url) {
if (!url) return this;
Expand Down Expand Up @@ -455,7 +456,7 @@ <h1 class="page-title">Embeds.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Mar 09 2018 09:04:35 GMT+0800 (Taipei Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Mar 09 2018 18:30:59 GMT+0800 (Taipei Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
Loading

0 comments on commit 8a6dd2f

Please sign in to comment.