discord-msg
v1.0.9
Published
<h1>Hi 👋</h1> <h1>Discord-Measage</h1> <hr> </hr> Discord-Message - A lightweight and easy to use, framework for discord bots, uses MongoDB.
Downloads
24
Maintainers
Readme
Discord.js support
|Version| Support| |-------|--------| |v12 | ✔ | |v13 | ✔ |
- 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");
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