discord-coin
v1.0.0
Published
Framework to facilitate the economy system for bot discord.
Downloads
2
Readme
Discord Coin
Framework to facilitate the economy system for bot discord.
Installation
npm i discord-coin
Examples
Lunch of the module
const Discord = require("discord.js"),
client = new Discord.Client(),
settings = {
prefix: "c!",
token: "Your Discord Token"
};
const CoinManager = require("discord-coin")
const manager = new CoinManager(client, {
storage: "money.json"
})
client.coinManager = manager;
client.on("ready", () => {
console.log("I'm ready !");
});
client.login(settings.token);
Add Money
client.on("message", (message) => {
const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if(command === "add-money"){
client.coinManager.addMoney(message.author.id,{
guildID: message.guild.id,
money: 100
})
}
})
Remove Money
client.on("message", (message) => {
const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if(command === "remove-money"){
client.coinManager.removeMoney(message.author.id,{
guildID: message.guild.id,
money: 100
})
}
})
getUser
client.on("message", (message) => {
const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if(command === "get-user"){
client.coinManager.getUser(message.author.id,{
guildID: message.guild.id
})
}
})
Events
moneyCreated
When a user sends his first message.
client.coinManager.on('moneyCreated',(member, guild) => {
console.log(`Money created for ${member.user.username} in the guild ${guild.name}`)
})
moneyAdded
When a user gets money
client.coinManager.on('moneyAdded',(member, guild, data) => {
console.log(`The member ${member.user.tag} in the guild ${guild.name} get ${data.money}$`)
})
moneyRemoved
When a user lost money
client.coinManager.on('moneyRemoved',(member, guild, data) => {
console.log(`The member ${member.user.tag} in the guild ${guild.name} lost ${data.money}$`)
})