Socket
Socket
Sign inDemoInstall

@reconlx/discord.js

Package Overview
Dependencies
0
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @reconlx/discord.js

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. <a href="https://nodei.co/npm/


Version published
Weekly downloads
50
increased by150%
Maintainers
1
Install size
24.1 kB
Created
Weekly downloads
 

Readme

Source

❔ @reconlx/discord.js

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.

NPM info


📝 Table of contents


Installation

First install Node.js. Then:

$ npm install @reconlx/discord.js

🛠 Usages (Click on it for more info on how to use it)

  • reconDB - simple way to store data into mongodb
  • DaysAgo - check how many days ago was it using date format
  • EmbedPages - 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

✈ Importing

// Using Node.js `require()`
const recon = require('@reconlx/discord.js');

// Using ES6 imports
import recon from '@reconlx/discord.js';

🙋‍♂️ Support

Feel free to join the support discord server -> https://discord.gg/xCCpfth


🔧 Usages


DaysAgo

// Example on checking how long the member's account was created.
// Import the package
const recon = require('@reconlx/discord.js')
// 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.
})

EmbedPages

Example :
// Example on checking how long the member's account was created.
// Import the package
const recon = require('@reconlx/discord.js')
// Destructure the package
const EmbedPages = recon.EmbedPages
// 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
]
// 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 EmbedPages method, use the <message> parameter to initialize it.
EmbedPages(msg, pages, emojis, time);
//There you go, now you have embed pages.
Preview on a music list :

preview


confirmation

// destructure the package
const { confirmation } = require('@reconlx/discord.js')
// 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 = confirmation(msg, message.author, ['✅', '❌'], 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()
  }
})

fetchTranscript

// destructure the package
const { fetchTransript } = require('@reconlx/discord.js')

// here is how you use it

// template
// fetchTranscript(message: any, numberOfMessages: number, sendToAuthor: boolean)

//example
module.exports = {
  name : 'transcript',
  run : async(client, message) => {
    fetchTranscript(message, 5, true)
  }
}
// it will fetch 10 messages in {message} channel and the transcript will be sent to the author

Preview on a general chat

preview


timeout

// destructure the package
const { timeout } = require('@reconlx/discord.js')

// 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.

Preview

preview




reconDB

1. Importing the package

const { reconDB } = require('@reconlx/discord.js')
// or
import { reconDB } from '@reconlx/discord.js'

2. Establishing and exporting reconDB

const db = new reconDB({
  uri : "your mongodb connection string"
})

module.exports = db;

3. Example on using it

const db = require('./db.js') // replace db.js with your file path to the setup of reconDB

db.set('numbers', '123')

Methods

.set

// saves data to database
db.set('key', 'value')

.get

// gets value from key
db.get('key') // returns => value

.has

// returns boolean
db.has('key') // returns => true

.delete

// deletes data
db.delete('key')

// checking for data
db.has('key') // returns => false

FAQs

Last updated on 09 Nov 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc