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

Commit

Permalink
Add cooldowns and optional Sharding
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Ray committed Sep 16, 2018
1 parent 48c3e54 commit ed9621c
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 24 deletions.
24 changes: 18 additions & 6 deletions commands/invite.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
const Discord = require("discord.js");
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)
.addField("Invite Link", "https://discordapp.com/api/oauth2/authorize?client_id=460639060851949569&permissions=8&scope=bot", true)
.setFooter("client.user.username | Beta - Master");
message.channel.send(embed);
};
.setFooter(`${client.user.username} | Beta - Master`);
message.member.user.createDM().then(channel => channel.send(embed))

const em1 = new Discord.RichEmbed()
.setAuthor(`${client.user.username}`, `${client.user.avatarURL}`)
.setColor(message.member.displayColor)
.setDescription("Invite link sent, check your DMs.")
.setFooter(`${client.user.username} | Beta - Master`);
message.channel.send(em1)
};





exports.conf = {
enabled: true,
guildOnly: true,
guildOnly: false,
aliases: ["get", "join"],
permLevel: "Systems Alpha/Dev Tester"
};

exports.help = {
name: "invite",
category: "Bot Information",
description: "Provides the invite link.",
description: "Provides the bot's invite link.",
usage: "invite"
};
15 changes: 2 additions & 13 deletions commands/math.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
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 (message, args) => {
if (talkedRecently.has(message.author.id) && !message.member.roles.has("490364533550874644")) {

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

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
6 changes: 3 additions & 3 deletions commands/ping.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const Discord = require("discord.js");
const talkedRecently = new Set();
exports.run = async (client, message, args, level) => {
exports.run = async (client, message) => {
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}`)
.setAuthor(`${client.user.username}`, `${client.user.avatarURL}`)
.setColor(message.member.displayColor)
.addField("• Ping Latency", `${msg.createdTimestamp - message.createdTimestamp}ms`, true)
.addField("• API Latency", `${Math.round(client.ping)}ms`, true)
Expand All @@ -31,6 +31,6 @@ exports.conf = {
exports.help = {
name: "ping",
category: "Misc",
description: "Pings the bot, responses with API and regular latencies.",
description: "Pings the bot, responds with API and regular latencies.",
usage: "ping"
};
58 changes: 58 additions & 0 deletions commands/serverinfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const Discord = require("discord.js");
const talkedRecently = new Set();
exports.run = async (client, message) => {
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("Loading... *If you are seeing this message longer than 5 seconds, an error may have occurred.*");
function checkBots(guild) {
let botCount = 0;
guild.members.forEach(member => {
if(member.user.bot) botCount++;
});
return botCount;
}
function checkMembers(guild) {
let memberCount = 0;
guild.members.forEach(member => {
if(!member.user.bot) memberCount++;
});
return memberCount;
}
const embed = new Discord.RichEmbed()
.setAuthor(`${client.user.username}`, `${client.user.avatarURL}`)
.setTitle("Server Information")
.setThumbnail(message.guild.iconURL)
.setColor(message.member.displayColor)
.addField('Server Owner', message.guild.owner, true)
.addField('Server Region', message.guild.region, true)
.addField('Channels', message.guild.channels.size, false)
.addField("Created", `${message.guild.createdAt}`, false)
.addField('Members', message.guild.memberCount, true)
.addField('Humans', checkMembers(message.guild), true)
.addField('Bots', checkBots(message.guild), true)
.addField('Verification Level', message.guild.verificationLevel, 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,
guildOnly: true,
aliases: [],
permLevel: "Standard User"
};

exports.help = {
name: "serverinfo",
category: "Misc",
description: "Provides information about the current guild.",
usage: "serverinfo"
};
1 change: 1 addition & 0 deletions commands/whois.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ exports.run = async (client, message, args, level) => {

const embed = new Discord.RichEmbed()
.setAuthor(botuser.displayName, botuser.user.avatarURL)
.setThumbnail(message.author.avatarURL)
.setColor(botuser.displayColor)
.addField("Joined Server At", `${botuser.joinedAt}`, true)
.addField("Created Account At", `${botuser.user.createdAt}`, true)
Expand Down
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
if (Number(process.version.slice(1).split(".")[0]) < 8) throw new Error("Node 8.0.0 or higher is required. Update Node on your system.");

const Discord = require("discord.js");
const Discord = require("discord.js")
const { promisify } = require("util");
const readdir = promisify(require("fs").readdir);
const Enmap = require("enmap");
const EnmapLevel = require("enmap-sqlite");

const client = new Discord.Client();
const client = new Discord.Client({
fetchAllMembers: true})


client.config = require("./config.js");
// client.config.token contains the bot's token
Expand Down
3 changes: 3 additions & 0 deletions shard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const Discord = require('discord.js');
const Manager = new Discord.ShardingManager('./index.js');
Manager.spawn(2); // This example will spawn 2 shards (5,000 guilds);

0 comments on commit ed9621c

Please sign in to comment.