Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

discord-msg

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-msg

Hi 👋 Discord-Measage Discord-Message - A lightweight and easy to use, framework for discord bots, uses MongoDB.

  • 1.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Hi 👋

Discord-Message System Using MongoDB


Discord.js support

VersionSupport
v12
v13
Discord-Message

- A lightweight and easy to use,

framework for discord bots, uses MongoDB.

How To Install It In Your Project:?



Changelog

  • 7 May 2022 (v1.0.9) - Adding SubtractAllMessage() method.
npm i discord-msg


Setting Up

First things first, we include the module into the project.

const Message = require("discord-msg");

Then you need to provide a valid MongoDB database url and client
Message.Setup(client, 'DataBase Url')


Methods


onMessage({
message,
guildID: <Message>.guild.id,
userID: <Message>.author.id
})

AddMessage({
guildID: <Message>.guild.id,
userID: <Message>.author.id,
Value: Num
})

SubtractMessage({
guildID: <Message>.guild.id,
userID: <Message>.author.id,
Value: Num
})

Fetch({
guildID: <Message>.guild.id,
userID: <Message>.author.id,

}).then(count => <Measage>.channel.send(count))

Leaderboard({
guildID: <Message>.guild.id,
UsersFetch: num,
}).then(Leader => <Measage>.channel.send(Leader))

.SubtractAllMessage({
guildID: <Message>.guild.id,
})

Source Code:


For Discord Js V12

const Discord = require('discord.js')
const client = new Discord.Client()
const Message = require('discord-msg')
const prefix = "+"
Message.Setup(client, 'MongoDB DataBase Url')
client.on('message', async message => {
if(message.content.startsWith(prefix + "top")){
if(message.author.bot || !message.guild) return 
await Message.Leaderboard({
guildID: message.guild.id,
UsersFetch: 2
}).then(Leader => {

message.channel.send(new Discord.MessageEmbed().setAuthor(message.author.tag, message.author.avatarURL({dynamic: true})).setDescription(Leader).setTimestamp().setFooter(`Leaderboard For: ${message.guild.name}`).setColor('BLUE'))
})
}
})

client.on('message', async message => {
if(message.author.bot || !message.guild) return 
await Message.onMessage({
message,
userID: message.author.id,
guildID: message.guild.id,
})
})

client.on('message', async message => {
if(message.content.startsWith(prefix + "fetch")){
if(message.author.bot || !message.guild) return 
let u = message.mentions.users.first()
if(!u) return
await Message.Fetch({
userID: u.id,
guildID: message.guild.id
}).then(count => {
message.channel.send(`<@${u.id}> Have ${count} Message`)
}).catch(err => console.log(err))

}
})
client.on('message', async message => {
if(message.content.startsWith(prefix + "add")){
if(message.author.bot || !message.guild) return 
if(message.author.id == 'Your ID'){

let u = message.mentions.users.first()
if(!u) return
let args = message.content.split(' ').slice(2).join(' ')
if(!args) return 
if(args.includes('-')) return message.channel.send('Nice Try Bro')
await Message.AddMessage({
userID: u.id,
guildID: message.guild.id,
value: parseInt(args)
})
message.channel.send('done')
}
}
})

client.on('message', async message => {
if(message.content.startsWith(prefix + "subtract")){
if(message.author.bot || !message.guild) return 
if(message.author.id == 'Your ID'){
let u = message.mentions.users.first()
    
let args = message.content.split(' ').slice(2).join(' ')
if(!args) return 
await Message.SubtractMessage({
userID: u.id,
guildID: message.guild.id,
count: args
})
message.channel.send('done')
}
}
})
client.on('message', async message => {
if(message.content.startsWith(prefix + "subtractall")){
if(message.author.bot || !message.guild) return 
if(message.author.id == 'Your ID'){

await Message.SubtractAllMessage({
guildID: message.guild.id,
})
message.channel.send('done')
}
}
})

For Discord Js V13


const { Client, Intents } = require("discord.js")

const client = new Client({ intents: 32767 })

const Message = require('discord-msg')
const prefix = "+"
Message.Setup(client, 'DataBase Url')
client.on('messageCreate', async message => {
if(message.content.startsWith(prefix + "top")){
if(message.author.bot || !message.guild) return 
await Message.Leaderboard({
guildID: message.guild.id,
UsersFetch: 2
}).then(Leader => {

message.channel.send({embeds: [new MessageEmbed().setAuthor(message.author.tag, message.author.avatarURL({dynamic: true})).setDescription(Leader).setTimestamp().setFooter(`Leaderboard For: ${message.guild.name}`).setColor('BLUE')]})
})
}
})

client.on('messageCreate', async message => {
if(message.author.bot || !message.guild) return 
await Message.onMessage({
message,
userID: message.author.id,
guildID: message.guild.id,
})
})

client.on('messageCreate', async message => {
if(message.content.startsWith(prefix + "fetch")){
if(message.author.bot || !message.guild) return 
let u = message.mentions.users.first()
if(!u) return
await Message.Fetch({
userID: u.id,
guildID: message.guild.id
}).then(count => {
message.channel.send(`<@${u.id}> Have ${count} Message`)
}).catch(err => console.log(err))

}
})
client.on('messageCreate', async message => {
if(message.content.startsWith(prefix + "add")){
if(message.author.bot || !message.guild) return 
if(message.author.id == 'Your ID'){

let u = message.mentions.users.first()
if(!u) return
let args = message.content.split(' ').slice(2).join(' ')
if(!args) return 
if(args.includes('-')) return message.channel.send('Nice Try Bro')
await Message.AddMessage({
userID: u.id,
guildID: message.guild.id,
value: parseInt(args)
})
message.channel.send('done')
}
}
})

client.on('messageCreate', async message => {
if(message.content.startsWith(prefix + "subtract")){
if(message.author.bot || !message.guild) return 
if(message.author.id == 'Your ID'){
let u = message.mentions.users.first()
    
let args = message.content.split(' ').slice(2).join(' ')
if(!args) return 
await Message.SubtractMessage({
userID: u.id,
guildID: message.guild.id,
count: args
})
message.channel.send('done')
}
}
})
client.on('messageCreate', async message => {
if(message.content.startsWith(prefix + "subtractall")){
if(message.author.bot || !message.guild) return 
if(message.author.id == 'Your ID'){

await Message.SubtractAllMessage({
guildID: message.guild.id,
})
message.channel.send('done')
}
}
})

In The End ✌️

Any Bug Or Suggestion:

Discord: #B A D B O Y #1502

feel free with discord message ❤️✌️

Keywords

FAQs

Package last updated on 07 Jan 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc