Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
QoL Improvements
Browse files Browse the repository at this point in the history
-Prohibit some commands from being used in DMs w/ the bot
-Added a rate limiting system to commands that may be abused
-Only allow the invite command to be used in Development channels
  • Loading branch information
Matthew Ray committed Sep 15, 2018
1 parent d84b6e1 commit 48c3e54
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 5 deletions.
2 changes: 1 addition & 1 deletion commands/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports.run = async (client, message, args, level) => {

exports.conf = {
enabled: true,
guildOnly: true,
guildOnly: false,
aliases: ["about"],
permLevel: "Standard User"
};
Expand Down
3 changes: 2 additions & 1 deletion commands/invite.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Discord = require("discord.js");
exports.run = async (client, message, args, level) => {
exports.run = async (client, message) => {
if(message.channel.id != "488762614156099585" || "489234703229124608") return;
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username}`, `${client.user.avatarURL}`)
.setColor(message.member.displayColor)
Expand Down
14 changes: 13 additions & 1 deletion commands/math.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
const superagent = require('superagent');
const math = require('mathjs');
const talkedRecently = new Set();

async function request(i) {
return await superagent.get(`http://numbersapi.com/${i}?json`);
}
exports.run = async (client, message, args, level) => {
exports.run = async (message, args) => {
if (talkedRecently.has(message.author.id) && !message.member.roles.has("490364533550874644")) {

message.channel.send("You are being rate limited!" + message.author);
} else {
const input = args.join(' ');
const errmsg = {
exp: 'Couldn\'t evaluate the given expression, please try again later.',
Expand Down Expand Up @@ -70,7 +75,14 @@ exports.run = async (client, message, args, level) => {
}

return message.channel.send(result);

}
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after a minute
talkedRecently.delete(message.author.id);
}, 2000);
}

exports.conf = {
enabled: true,
Expand Down
13 changes: 12 additions & 1 deletion commands/ping.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const Discord = require("discord.js");
exports.run = async (client, message, args, level) => { // eslint-disable-line no-unused-vars
const talkedRecently = new Set();
exports.run = async (client, message, args, level) => {
if (talkedRecently.has(message.author.id) && !message.member.roles.has("490364533550874644")) {

message.channel.send("You are being rate limited!" + message.author);
} else { // eslint-disable-line no-unused-vars
const msg = await message.channel.send("Ping?");
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username}`, `${client.user.avatarURL}`)
Expand All @@ -8,7 +13,13 @@ exports.run = async (client, message, args, level) => { // eslint-disable-line n
.addField("• API Latency", `${Math.round(client.ping)}ms`, true)
.setFooter(`${client.user.username} | Beta - Master`);
msg.edit(embed);
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after a minute
talkedRecently.delete(message.author.id);
}, 2000);
};
}

exports.conf = {
enabled: true,
Expand Down
13 changes: 12 additions & 1 deletion commands/shiba.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
const Discord = require("discord.js");
const superagent = require ("superagent");
const talkedRecently = new Set();

exports.run = async (client, message, args) => {
if (talkedRecently.has(message.author.id) && !message.member.roles.has("490364533550874644")) {

message.channel.send("You are being rate limited!" + message.author);
} else {
const {body} = await superagent
.get ('http://shibe.online/api/shibes?count=1&urls=true&httpsUrls=true');

Expand All @@ -10,7 +15,13 @@ exports.run = async (client, message, args) => {
.setTitle(":dog: Woof!")
.setImage(body[0]);
message.channel.send(shibaembed);
};
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after a minute
talkedRecently.delete(message.author.id);
}, 7500);
};
}
exports.conf = {
enabled: true,
guildOnly: false,
Expand Down
11 changes: 11 additions & 0 deletions commands/stats.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
const { version } = require("discord.js");
const Discord = require("discord.js");
const talkedRecently = new Set();
const moment = require("moment");
require("moment-duration-format");

exports.run = (client, message, args, level) => { // eslint-disable-line no-unused-vars
if (talkedRecently.has(message.author.id) && !message.member.roles.has("490364533550874644")) {

message.channel.send("You are being rate limited!" + message.author);
} else {
const duration = moment.duration(client.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username}`, `${client.user.avatarURL}`)
Expand All @@ -20,6 +25,12 @@ exports.run = (client, message, args, level) => { // eslint-disable-line no-unus
.setFooter(`${client.user.username} | Beta - Master`);
message.channel.send(embed);
};
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after a minute
talkedRecently.delete(message.author.id);
}, 2000);
}

exports.conf = {
enabled: true,
Expand Down
12 changes: 12 additions & 0 deletions commands/uptime.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
const Discord = require("discord.js");
const talkedRecently = new Set();
const moment = require("moment");
require("moment-duration-format");


exports.run = (client, message, args, level) => { // eslint-disable-line no-unused-vars
if (talkedRecently.has(message.author.id) && !message.member.roles.has("490364533550874644")) {

message.channel.send("You are being rate limited!" + message.author);
} else {
const duration = moment.duration(client.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username}`, `${client.user.avatarURL}`)
Expand All @@ -14,6 +20,12 @@ exports.run = (client, message, args, level) => { // eslint-disable-line no-unus


message.channel.send(embed);
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after a minute
talkedRecently.delete(message.author.id);
}, 2000);
}
};

exports.conf = {
Expand Down
11 changes: 11 additions & 0 deletions commands/whois.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
const Discord = require("discord.js");
const talkedRecently = new Set();
const status = {
online: "Online",
idle: "Idle",
dnd: "Do Not Disturb",
offline: "Offline/Invisible"
};
exports.run = async (client, message, args, level) => {
if (talkedRecently.has(message.author.id) && !message.member.roles.has("490364533550874644")) {

message.channel.send("You are being rate limited!" + message.author);
} else {
if (message.mentions.users.first())
try {
level = client.permlevel(message.mentions.users.first().lastMessage);
Expand Down Expand Up @@ -48,7 +53,13 @@ exports.run = async (client, message, args, level) => {
msg.edit("EXCPT*- " +
err);
}
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after a minute
talkedRecently.delete(message.author.id);
}, 2000);
};
}
exports.conf = {
enabled: true,
guildOnly: true,
Expand Down

0 comments on commit 48c3e54

Please sign in to comment.