1.0.1 • Published 5 years ago

discord.js-plugins v1.0.1

Weekly downloads
3
License
ISC
Repository
-
Last release
5 years ago

discord.js-plugins

discord.js-plugins is a 3rd party module for discord.js

SubjectDescription
TrialInformation about free trial
PurchasingHow to purchase a product key
InstallationHow to install the module
UsageHow to do a import the module
PluginsLearn how to use a specific plugin
ExamplesExamples of what you can make

Trial

If you want to try out discord.js-plugins you can use the product key called trial you only get the following plugins tho.. Prompt, Request, Database

Purchasing

To purchase a product key go to shoppy.gg. If there is any problems contact Niiko#0713 on Discord.

Installation

Use the package manager npm to install the module.

npm install discord.js --save
npm install discord.js-plugins --save

Usage

const Discord = require("discord.js");
const client = new Discord.Client();

require("discord.js-plugins")(Discord, client, "PRODUCT_KEY").then(() => {
    // Initialize discord.js bot code..
})

Plugins

SubjectDescription
CaptchaMake captcha verification
DatabaseEasily manage a database
RequestMake HTTP Web Requests
ReactMessageActions when reacted to message
PromptQuestion the target and get answer

Captcha

let captcha = new Discord.Captcha(
    message.author.id, // target id
    (msg) => { msg.channel.send("valid") }, // valid callback
    (msg) => { msg.channel.send("invalid") }, // invalid callback
);

captcha.send(message.channel); // channel where to send message

Database

let database = new Discord.Database("GLOBAL"); // GLOBAL = Synced with all server, guild id = guild

database.get("GROUP"); // gets group value
database.set("GROUP", "VALUE"); // sets group value
database.push("GROUP", "VALUE"); // pushes value (only works if value is an array)
database.remove("GROUP"); // removes a group
database.exist("GROUP"); // checks if a group exists

Request

new Discord.Request("URL", {
    method: "GET"
}).then(response => {
    console.log(response); // response = raw text
});

ReactMessage

let react = new Discord.ReactMessage(
    "Hello there react to this message", // message content, could be an embed
    ["👋", "👊"], // only sends callback if these emojis, null = all emojis
    (msg, reaction, user) => { msg.channel.send("caught you reacting.") } // react callback
);

react.send(message.channel); // channel where to send message

Prompt

let prompt = new Discord.Prompt(
    message.author.id, // target id
    "Is discord.js-plugins cool?" // message content, could be embed
);

prompt.send(message.channel); // channel where to send message

Examples

React to message for role

const Discord = require("discord.js");
const client = new Discord.Client();

require("discord.js-plugins")(Discord, client, "PRODUCT_KEY").then(() => {
    client.on("message", (message) => {
        if (message.content === "role") {
            var react = new Discord.ReactMessage("React to this for verified role", null, (msg, reaction, user) => {
                var role = null;
                var target = null;

                /* Find Role */ msg.guild.roles.cache.filter(r => { if (r.name === 'verified') role = r; });
                /* Find Member */ msg.guild.members.cache.filter(r => { if (r.id === user.id) target = r; });
            
                /* Add role to member */ target.roles.add(role);
            });

            react.send(message.channel); /* Send React message */
        }
    })
})