-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from muricans/mbot-testing
7.5.4
- Loading branch information
Showing
12 changed files
with
192 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const Discord = require('discord.js'); | ||
const sqlite = require('sqlite3').verbose(); | ||
|
||
const db = new sqlite.Database('./mbot.db', (err) => { | ||
if (err) console.log(err.message); | ||
}); | ||
|
||
module.exports = { | ||
name: 'leaderboard', | ||
description: 'Get up to 20 users with the most points', | ||
async execute(message, args, client) { | ||
leaderboard(message, client).then(leaders => message.channel.send(leaders)); | ||
}, | ||
}; | ||
|
||
function leaderboard(message, client) { | ||
return new Promise((resolve) => { | ||
db.all('SELECT points points, id id FROM users ORDER BY points DESC', (err, rows) => { | ||
if (err) return console.log(err); | ||
const embed = new Discord.RichEmbed().setTitle('Points Leaderboard'); | ||
if (!rows.length) return message.channel.send('No users found!'); | ||
rows.forEach(async (val, i, arr) => { | ||
if (i < 20) { | ||
const user = await client.fetchUser(arr[i].id); | ||
embed.addField(`${i + 1}. ${user.username}`, arr[i].points, true); | ||
} | ||
}); | ||
resolve(embed); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,23 @@ | ||
const sqlite = require('sqlite3').verbose(); | ||
const tls = require('../../tools'); | ||
const tools = new tls.Tools(); | ||
|
||
const db = new sqlite.Database('./mbot.db', (err) => { | ||
if (err) { | ||
console.error(err.message); | ||
} | ||
}); | ||
|
||
module.exports.cooldown = 0; | ||
|
||
module.exports = { | ||
name: 'points', | ||
usage: '[user]', | ||
description: `Returns the designated user's points`, | ||
execute(message, args) { | ||
db.serialize(() => { | ||
if (args.length === 0) { | ||
db.get('SELECT points points FROM users WHERE id = ' + message.author.id.toString(), (err, row) => { | ||
if (err) { | ||
return console.log(err); | ||
} | ||
return message.reply('You have ' + row.points.toString() + ' points!'); | ||
}); | ||
} | ||
if (args.length > 0) { | ||
tools.addCooldown(module.exports.name, 3, message); | ||
db.get('SELECT points points FROM users WHERE id = ' + message.mentions.users.first().id.toString(), (err, row) => { | ||
if (err) { | ||
return message.reply('No such user exists!'); | ||
} | ||
return message.reply(message.mentions.users.first().username + ' has ' + row.points.toString() + ' points!'); | ||
}); | ||
} | ||
}); | ||
async execute(message, args) { | ||
let current; | ||
let msg; | ||
const mention = message.mentions.users.first(); | ||
if (!args.length) { | ||
current = await tools.getPoints(message.author.id); | ||
msg = `You have ${current} points!`; | ||
} else { | ||
if (!mention) return message.channel.send('Could not find that user!'); | ||
current = await tools.getPoints(mention.id); | ||
msg = `${mention.username} has ${current} points!`; | ||
tools.addCooldown(this.name, 3, message); | ||
} | ||
return message.channel.send(msg); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,22 @@ | ||
const sqlite = require('sqlite3').verbose(); | ||
const tls = require('../../tools'); | ||
const tools = new tls.Tools(); | ||
|
||
const db = new sqlite.Database('./mbot.db', (err) => { | ||
if (err) { | ||
console.error(err.message); | ||
} | ||
}); | ||
|
||
module.exports = { | ||
name: 'set', | ||
usage: '<user> <amount>', | ||
description: 'Sets the users points [dev only]', | ||
args: true, | ||
minArgs: 2, | ||
owner: true, | ||
execute(message, args, client) { | ||
const weirdChamp = client.emojis.get("572690273247821824"); | ||
if (message.author.id != "399121700429627393") { | ||
return message.channel.send(`${message.author} You don't have permission to use this command! ${weirdChamp}`); | ||
} | ||
execute(message, args) { | ||
if (!message.mentions.users.first()) { | ||
return message.reply('That user does not exist!'); | ||
} | ||
db.serialize(() => { | ||
db.get("SELECT points points FROM users WHERE id = " + message.mentions.users.first().id.toString(), () => { | ||
const amnt = parseInt(args[1]); | ||
if (isNaN(amnt)) { | ||
return message.reply('Please use numbers!'); | ||
} | ||
//db.run('UPDATE users SET points = ? WHERE id = ?', amnt, message.mentions.users.first().id.toString()); | ||
tools.setPoints(amnt, message.mentions.users.first().id.toString()); | ||
message.reply('You set ' + message.mentions.users.first() + ' points to ' + amnt + '!'); | ||
}); | ||
}); | ||
const amnt = parseInt(args[1]); | ||
if (isNaN(amnt)) { | ||
return message.channel.send('Please use numbers!'); | ||
} | ||
tools.setPoints(amnt, message.mentions.users.first().id); | ||
return message.channel.send(`${message.author} You set ${message.mentions.users.first()}'s points to ${amnt}!`); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.