A simple api to configure and enhance the ways on coding your discord bot. Compatible with discord.js v12 but it should also work on older versions. Variety of different usages for this api.
First install Node.js. Then:
$ npm install reconlx
- oldReconDB - the old way of storing data in mongodb
- reconDB - the newest way of storing data in mongodb with cache
- DaysAgo - check how many days ago was it using date format
- ReactionPages - simple pagination to make your "MessageEmbed" interactable.
- Confirmation - A reaction collector which returns the first emoji collected, can be used as a confirmation prompt.
- fetchTranscript - Specify an amount of messages and it will return a discord chat template with messages, acts like a transcript.
- timeout - Makes it easier to delete messages according to your needs
- chatBot - Replies to your messages in discord.
- hangman - Hangman game now playable in discord.
- tictactoe - TicTacToe game now playable in discord.
- GiveawayClient - Giveaway Client, easy way to manage your giveaways
- SnakeCord - Snakecord with some minor error fixes as the mantainer isn't reading prs.
// Using Node.js `require()`
const recon = require("reconlx");
// Using ES6 imports
import recon from "reconlx";
Feel free to join the support discord server -> https://discord.gg/xCCpfth
// Example on checking how long the member's account was created.
// Import the package
const recon = require("reconlx");
// Destructure the package
const daysAgo = recon.DaysAgo;
const discord = require("discord.js");
client.on("guildMemberAdd", async (member) => {
console.log(daysAgo(member.user.createdAt)); // return days.
});
// Example on checking how long the member's account was created.
// Import the package
const recon = require("reconlx");
// Destructure the package
const ReactionPages = recon.ReactionPages;
// Use either MessageEmbed or RichEmbed to make pages
// Keep in mind that Embeds should't have their footers set since the pagination method sets page info there
const { MessageEmbed } = require("discord.js");
const embed1 = new MessageEmbed().setTitle("1");
const embed2 = new MessageEmbed().setTitle("2");
// Create an array of embeds.
const pages = [embed1, embed2];
// Change pages when sending numbers.
const textPageChange = true;
// Create an emojilist, first emoji being page back and second emoji being page front. Defaults are set to ['⏪', '⏩'].
const emojis = ["⏪", "⏩"];
// Define a time in ms, defaults are set to 60000ms which is 60 seconds. Time on how long you want the embed to be interactable
const time = 30000;
// Call the ReactionPages method, use the <message> parameter to initialize it.
ReactionPages(msg, pages, textPageChange, emojis, time);
//There you go, now you have embed pages.
// destructure the package
const { confirmation } = require("reconlx");
// Here is an example on using it in banning members.
message.channel.send("Confirmation for banning members").then(async (msg) => {
// parameters used(which msg to react on, who can acess it, reactions, time(optional))
const emoji = await confirmation(msg, ["✅", "❌"], 30000);
if (emoji === "✅") {
//if author reacts on check
//delete the confirmation message
msg.delete();
//ban the member
guildMember.ban();
}
if (emoji === "❌") {
// if author reacts on cross
// delete the confirmation message
msg.delete();
}
});
// destructure the package
const { fetchTransript } = require("reconlx");
// here is how you use it
// template
// fetchTranscript(message: any, numberOfMessages: number, sendToAuthor: boolean)
// returns buffer
//example
module.exports = {
name: "transcript",
run: async (client, message) => {
fetchTranscript(message, 5).then((data) => {
const file = new MessageAttachment(data, "index.html");
message.channel.send(file);
});
},
};
// it will fetch 5 messages in the current channel.
// destructure the package
const { timeout } = require("reconlx");
// example
const messageToDelete = await message.channel.send("Hello There 👋");
// using the method
// template => timeout(message: who can acess, msgToDelete: which message to delete,time: time before the emoji gets deleted)
timeout(message, messageToDelete, 5000); // only message.author can areact, messageToDelete is going to deleted if collected reactions, if no reactions after 5 seconds the reaction will be removed.
const { chatBot } = require("reconlx");
/** @parameters
* message, message.channel
* input, input to give
*/
// example
chatBot(message, args.join(" "));
//importing
const { hangman } = require("reconlx");
// parameters
/**
* @name hangman
* @param {Object} options options
* @param {String} [options.channelID] channel to send to (channel.id)
* @param {any} [options.message] parameter used for message event
* @param {String} [options.permission] required permission to use this command (optional); default set to everyone.
* @param {String} [options.word] word that needed to be guessed
* @param {any} [options.client] client used to defined Discord.Client
*/
// making hangman
const hang = new hangman({
message: message,
word: args.slice(1).join(" "),
client: client,
channelID: message.mentions.channels.first(),
});
// starting the game
hang.start();
//importing
const { tictactoe } = require("reconlx");
// parameters
/**
* @name tictactoe
* @param {Object} options options
* @param {any} [options.message] parameter used for message event
* @param {any} [options.player_two] second player in the game.
*/
// start the game
var game = new tictactoe({
message: message,
player_two: message.mentions.members.first(),
});
const { oldReconDB } = require("reconlx");
// or
import { oldReconDB } from "reconlx";
const db = new oldReconDB({
uri: "your mongodb connection string",
});
module.exports = db;
const db = require("./db.js"); // replace db.js with the file path to oldReconDB
db.set("numbers", "123");
// saves data to database
db.set("key", "value");
// gets value from key
db.get("key"); // returns => value
// returns boolean
db.has("key"); // returns => true
// deletes data
db.delete("key");
// checking for data
db.has("key"); // returns => false
const { reconDB } = require("reconlx");
// or
import { reconDB } from "reconlx";
const db = new reconDB(client, {
uri: "your mongodb connection string",
});
module.exports = db;
const db = require("./db.js"); // replace db.js with the file path to reconDB
db.set("numbers", "123");
// saves data to database
db.set("key", "value");
// gets value from key
db.get("key"); // returns => value
// returns boolean
db.has("key"); // returns => true
// deletes data
db.delete("key");
// checking for data
db.has("key"); // returns => false
//returns the cached data
console.log(reconDB.collection())
const Discord = require('discord.js')
const client = new Discord.Client();
const { GiveawayClient } = require('reconlx');
/**
* @name GiveawayClient
* @kind constructor
* @param {Client} client
* @param {Object} options Options
* @param {String} [options.mongoURI] mongodb connection string
* @param {String} [options.emoji] emoji for reaction (must be a unicode)
* @param {String} [options.defaultColor] default colors for giveaway embeds
* @description Initiating the giveaway client
*/
const giveaway = new GiveawayClient(client, {
mongoURI?
emoji?
defaultColor?
});
module.exports = giveaway;
/**
* @method
* @param {Object} options options
* @param {TextChannel} [options.channel] Channel for the giveaway to be in
* @param {Number} [options.time] Duration of this giveaway
* @param {User} [options.hostedBy] Person that hosted the giveaway
* @param {String} [options.description] Description of the giveaway
* @param {Number} [options.winners] Amount of winners for the giveaway
* @param {String} [options.prize] Prize for the giveaway
*/
/**
* @method
* @param {String} MessageID Message ID for the giveaway
* @param {Boolean} getWinner Choose a winner?
* @description End a giveaway, choose a winner (optional)
*/
/**
* @method
* @param {String} channel channel of the giveaway
* @param {String} id message id
* @param {Number} winners amount of winners
* @description Change the winners for a giveaway!
*/
/**
* @method
* @param {Boolean} activatedOnly display activated giveaways only?
* @param {Boolean} all display giveaways of all guilds?
* @param {Message} message message if (all = false)
* @description Get data on current giveaways hosted by the bot
*/
/**
* @method
* @param {Boolean} all Get data from all guilds?
* @param {String} guildID guild id if all=false
* @description Removes (activated = false) giveaways
*/