Fix Stuff

This commit is contained in:
Daniel Odendahl Jr
2017-06-09 00:32:03 +00:00
parent c26f048911
commit 212ed27e3b
49 changed files with 385 additions and 396 deletions
+5 -10
View File
@@ -1,11 +1,6 @@
# Logs
logs
# Packages
node_modules/
# Log Files
logs/
*.log
npm-debug.log*
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
node_modules
+15 -17
View File
@@ -56,18 +56,19 @@ client.dispatcher.addInhibitor((msg) => {
if (msg.channel.type === 'dm') return false;
const role = msg.guild.settings.get('singleRole');
if (!msg.guild.roles.has(role) || msg.member.hasPermission('ADMINISTRATOR')) return false;
if (!msg.member.roles.has(role)) {
return ['singleRole', msg.reply(`Only the ${msg.guild.roles.get(role).name} role may use commands.`)];
} else {
return false;
}
if (!msg.member.roles.has(role)) return 'single role';
else return false;
});
client.on('message', (msg) => {
if (!msg.guild || !msg.guild.settings.get('inviteGuard')) return;
if (!msg.channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
if (/(discord(\.gg\/|app\.com\/invite\/|\.me\/))/gi.test(msg.content)) {
if (!msg.guild || !msg.guild.settings.get('inviteGuard')) return;
if (msg.author.bot || msg.member.hasPermission('ADMINISTRATOR')) return;
if (!msg.channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'MANAGE_MESSAGES'])) return;
if (!msg.channel.permissionsFor(client.user).has('MANAGE_MESSAGES')) {
msg.say('Could not delete invite, missing permissions.');
return;
}
msg.delete();
msg.reply('Invites are prohibited from being posted here.');
}
@@ -75,23 +76,20 @@ client.on('message', (msg) => {
client.on('messageReactionAdd', (reaction, user) => {
if (reaction.emoji.name !== '⭐') return;
const { message } = reaction;
const channel = message.guild.channels.get(message.guild.settings.get('starboard'));
if (!channel) return;
if (!message.channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'MANAGE_MESSAGES'])) return;
if (user.id === message.author.id) {
const msg = reaction.message;
const channel = msg.guild.channels.get(msg.guild.settings.get('starboard'));
if (!channel || !msg.channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'MANAGE_MESSAGES'])) return;
if (user.id === msg.author.id) {
reaction.remove(user);
message.reply('You cannot star your own messages, baka.');
msg.reply('You cannot star your own messages, baka.');
return;
}
client.registry.resolveCommand('random:star').run(message, { id: message.id }, true);
client.registry.resolveCommand('random:star').run(msg, { id: msg.id }, true);
});
client.on('guildMemberAdd', (member) => {
const role = member.guild.roles.get(member.guild.settings.get('joinRole'));
if (role && member.guild.me.hasPermission('MANAGE_ROLES')) {
member.addRole(role).catch(() => null);
}
if (role && member.guild.me.hasPermission('MANAGE_ROLES')) member.addRole(role).catch(() => null);
const channel = member.guild.channels.get(member.guild.settings.get('memberLog'));
if (!channel || !channel.permissionsFor(client.user).has('SEND_MESSAGES')) return;
const msg = member.guild.settings.get('joinMsg', 'Welcome <user>!')
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 KiB

+18
View File
@@ -0,0 +1,18 @@
{
"online": {
"text": "<:online:313956277808005120> Online",
"color": "#00AE86"
},
"idle": {
"text": "<:away:313956277220802560> Idle",
"color": "#FFFF00"
},
"dnd": {
"text": "<:dnd:313956276893646850> Do Not Disturb",
"color": "#FF0000"
},
"offline": {
"text": "<:offline:313956277237710868> Offline",
"color": "#808080"
}
};
+4 -2
View File
@@ -31,8 +31,10 @@ module.exports = class YearsCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 256
});
const Image = Canvas.Image;
const canvas = new Canvas(856, 569);
const ctx = canvas.getContext('2d');
+4 -2
View File
@@ -31,8 +31,10 @@ module.exports = class BeautifulCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 256
});
const Image = Canvas.Image;
const canvas = new Canvas(500, 532);
const ctx = canvas.getContext('2d');
+4 -2
View File
@@ -31,8 +31,10 @@ module.exports = class BobRossCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 256
});
const Image = Canvas.Image;
const canvas = new Canvas(600, 775);
const ctx = canvas.getContext('2d');
+7 -4
View File
@@ -34,15 +34,18 @@ module.exports = class CardCommand extends Command {
async run(msg, args) {
const member = args.member || msg.member;
const avatarURL = member.user.avatarURL('png', 256);
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const avatarURL = member.displayAvatarURL({
format: 'png',
size: 256
});
const cardID = Math.floor(Math.random() * (9999 - 1000 + 1)) + 1000;
let rarity;
if (cardID < 5000) rarity = 'C';
else if (cardID < 8000) rarity = 'U';
else rarity = 'R';
const Image = Canvas.Image;
Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OpenSans.ttf'), { family: 'Open Sans' }); // eslint-disable-line max-len
Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Roboto.ttf'), { family: 'Roboto' }); // eslint-disable-line max-len
Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'NotoEmoji-Regular.ttf'), { family: 'Roboto' }); // eslint-disable-line max-len
const canvas = new Canvas(390, 544);
const ctx = canvas.getContext('2d');
const base = new Image();
@@ -52,7 +55,7 @@ module.exports = class CardCommand extends Command {
ctx.fillRect(0, 0, 390, 544);
ctx.drawImage(avatar, 11, 11, 370, 370);
ctx.drawImage(base, 0, 0);
ctx.font = '18px Open Sans';
ctx.font = '18px Roboto';
ctx.fillStyle = 'black';
ctx.fillText(member.displayName, 30, 62);
ctx.fillText('Discord Join Date:', 148, 400);
+4 -2
View File
@@ -30,8 +30,10 @@ module.exports = class ChallengerCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 256
});
const Image = Canvas.Image;
const canvas = new Canvas(500, 500);
const ctx = canvas.getContext('2d');
+4 -2
View File
@@ -30,8 +30,10 @@ module.exports = class DexterCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 256
});
const Image = Canvas.Image;
const canvas = new Canvas(744, 554);
const ctx = canvas.getContext('2d');
+4 -2
View File
@@ -28,8 +28,10 @@ module.exports = class GreyscaleCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 256
});
const Image = Canvas.Image;
const canvas = new Canvas(256, 256);
const ctx = canvas.getContext('2d');
+4 -2
View File
@@ -27,8 +27,10 @@ module.exports = class InvertCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 256
});
const Image = Canvas.Image;
const canvas = new Canvas(256, 256);
const ctx = canvas.getContext('2d');
+4 -2
View File
@@ -31,8 +31,10 @@ module.exports = class RIPCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 256
});
const Image = Canvas.Image;
const canvas = new Canvas(507, 338);
const ctx = canvas.getContext('2d');
+4 -2
View File
@@ -30,8 +30,10 @@ module.exports = class SimbaCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 256);
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 256
});
const Image = Canvas.Image;
const canvas = new Canvas(500, 281);
const ctx = canvas.getContext('2d');
+7 -4
View File
@@ -30,10 +30,13 @@ module.exports = class SteamCardCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 512);
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 256
});
const Image = Canvas.Image;
Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'OpenSans.ttf'), { family: 'Open Sans' }); // eslint-disable-line max-len
Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Roboto.ttf'), { family: 'Roboto' }); // eslint-disable-line max-len
Canvas.registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'NotoEmoji-Regular.ttf'), { family: 'Roboto' }); // eslint-disable-line max-len
const canvas = new Canvas(494, 568);
const ctx = canvas.getContext('2d');
const base = new Image();
@@ -43,7 +46,7 @@ module.exports = class SteamCardCommand extends Command {
ctx.fillRect(0, 0, 494, 568);
ctx.drawImage(avatar, 25, 25, 450, 450);
ctx.drawImage(base, 0, 0);
ctx.font = '30px Open Sans';
ctx.font = '30px Roboto';
ctx.fillText(user.username, 35, 48);
};
base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'steam-card.png'));
+4 -2
View File
@@ -30,8 +30,10 @@ module.exports = class TriggeredCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 512);
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 256
});
const Image = Canvas.Image;
const canvas = new Canvas(320, 371);
const ctx = canvas.getContext('2d');
+4 -2
View File
@@ -30,8 +30,10 @@ module.exports = class WantedCommand extends Command {
async run(msg, args) {
const user = args.user || msg.author;
const avatarURL = user.avatarURL('png', 512);
if (!avatarURL) return msg.say('The User Provided has No Avatar.');
const avatarURL = user.displayAvatarURL({
format: 'png',
size: 256
});
const Image = Canvas.Image;
const canvas = new Canvas(741, 1000);
const ctx = canvas.getContext('2d');
+73 -77
View File
@@ -22,91 +22,87 @@ module.exports = class BattleCommand extends Command {
this.fighting = new Set();
}
async run(msg, args) { // eslint-disable-line complexity
async run(msg, args) {
const { opponent } = args;
if (opponent.bot) return msg.say('Bots cannot be fought.');
if (opponent.id === msg.author.id) return msg.say('You may not fight yourself.');
if (this.fighting.has(msg.guild.id)) return msg.say('Only one fight may be occurring per server.');
this.fighting.add(msg.guild.id);
await msg.say(`**${opponent.username}**, do you accept this challenge? **__Y__es** or **No**?`);
try {
const verify = await msg.channel.awaitMessages((res) => res.author.id === opponent.id, {
max: 1,
time: 15000,
errors: ['time']
});
if (!['yes', 'y'].includes(verify.first().content.toLowerCase())) {
this.fighting.delete(msg.guild.id);
return msg.say('Guess that was a no then...');
}
let userHP = 500;
let oppoHP = 500;
let userTurn = false;
let guard = false;
const reset = () => {
if (userTurn) userTurn = false;
else userTurn = true;
if (guard) guard = false;
};
const dealDamage = (damage) => {
if (userTurn) oppoHP -= damage;
else userHP -= damage;
};
while (userHP > 0 && oppoHP > 0) { // eslint-disable-line no-unmodified-loop-condition
const username = userTurn ? msg.author.username : opponent.username;
const id = userTurn ? msg.author.id : opponent.id;
await msg.say(stripIndents`
**${username}**, do you **fight**, **guard**, **special**, or **run**?
**${msg.author.username}**: ${userHP}HP
**${opponent.username}**: ${oppoHP}HP
`);
try {
const turn = await msg.channel.awaitMessages((res) => res.author.id === id, {
max: 1,
time: 15000,
errors: ['time']
});
const choice = turn.first().content.toLowerCase();
if (choice === 'fight') {
const damage = Math.floor(Math.random() * (guard ? 10 : 100)) + 1;
await msg.say(`**${username}** deals **${damage}** damage!`);
dealDamage(damage);
reset();
} else if (choice === 'guard') {
await msg.say(`**${username}** guards!`);
reset();
guard = true;
} else if (choice === 'special') {
const hit = Math.floor(Math.random() * 4) + 1;
if (hit === 1) {
const damage = Math.floor(Math.random() * ((guard ? 300 : 150) - 100 + 1) + 100);
await msg.say(`**${username}** deals **${damage}** damage!`);
dealDamage(damage);
reset();
} else {
await msg.say(`**${username}**'s attack missed!`);
reset();
}
} else if (choice === 'run') {
await msg.say(`**${username}** flees!`);
break;
} else {
await msg.say('I do not understand what you want to do.');
}
} catch (err) {
await msg.say('Time!');
break;
}
}
this.fighting.delete(msg.guild.id);
return msg.say(stripIndents`
The match is over!
**Winner:** ${userHP > oppoHP ? msg.author.username : opponent.username}
**Loser:** ${userHP > oppoHP ? opponent.username : msg.author.username}
`);
} catch (err) {
const verify = await msg.channel.awaitMessages((res) => res.author.id === opponent.id, {
max: 1,
time: 30000
});
if (!verify.size || !['yes', 'y'].includes(verify.first().content.toLowerCase())) {
this.fighting.delete(msg.guild.id);
return msg.say('Looks like they declined...');
}
let userHP = 500;
let oppoHP = 500;
let userTurn = false;
let guard = false;
const reset = (changeGuard = true) => {
if (userTurn) userTurn = false;
else userTurn = true;
if (changeGuard && guard) guard = false;
};
const dealDamage = (damage) => {
if (userTurn) oppoHP -= damage;
else userHP -= damage;
};
const forfeit = () => {
if (userTurn) userHP -= 500 - userHP;
else oppoHP -= 500 - oppoHP;
};
while (userHP > 0 && oppoHP > 0) { // eslint-disable-line no-unmodified-loop-condition
const username = userTurn ? msg.author.username : opponent.username;
const id = userTurn ? msg.author.id : opponent.id;
await msg.say(stripIndents`
**${username}**, do you **fight**, **guard**, **special**, or **run**?
**${msg.author.username}**: ${userHP}HP
**${opponent.username}**: ${oppoHP}HP
`);
const turn = await msg.channel.awaitMessages((res) => res.author.id === id, {
max: 1,
time: 30000
});
if (!turn.size) {
await msg.say('Time!');
forfeit();
}
const choice = turn.first().content.toLowerCase();
if (choice === 'fight') {
const damage = Math.floor(Math.random() * (guard ? 10 : 100)) + 1;
await msg.say(`**${username}** deals **${damage}** damage!`);
dealDamage(damage);
reset();
} else if (choice === 'guard') {
await msg.say(`**${username}** guards!`);
guard = true;
reset(false);
} else if (choice === 'special') {
const hit = Math.floor(Math.random() * 4) + 1;
if (hit === 1) {
const damage = Math.floor(Math.random() * ((guard ? 300 : 150) - 100 + 1) + 100);
await msg.say(`**${username}** deals **${damage}** damage!`);
dealDamage(damage);
reset();
} else {
await msg.say(`**${username}**'s attack missed!`);
reset();
}
} else if (choice === 'run') {
await msg.say(`**${username}** flees!`);
forfeit();
} else {
await msg.say('I do not understand what you want to do.');
}
}
this.fighting.delete(msg.guild.id);
return msg.say(stripIndents`
The match is over!
**Winner:** ${userHP > oppoHP ? `${msg.author.username} (${userHP}HP)` : `${opponent.username} (${oppoHP}HP)`}
**Loser:** ${userHP > oppoHP ? `${opponent.username} (${oppoHP}HP)` : `${msg.author.username} (${userHP}HP)`}
`);
}
};
+8 -11
View File
@@ -38,16 +38,13 @@ module.exports = class MathGameCommand extends Command {
.setTitle('You have 10 seconds to answer:')
.setDescription(expression);
await msg.embed(embed);
try {
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 10000,
errors: ['time']
});
if (collected.first().content !== answer) return msg.say(`Nope, sorry, it's ${answer}.`);
else return msg.say('Nice job! 10/10! You deserve some cake!');
} catch (err) {
return msg.say(`Time! It was ${answer}, sorry!`);
}
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 10000
});
if (!collected.size) return msg.say(`Time! It was ${answer}, sorry!`);
if (collected.first().content !== answer) return msg.say(`Nope, sorry, it's ${answer}.`);
else return msg.say('Nice job! 10/10! You deserve some cake!');
}
};
+7 -11
View File
@@ -31,16 +31,12 @@ module.exports = class QuizCommand extends Command {
True or False: ${decodeURIComponent(body.results[0].question)}
`);
await msg.embed(embed);
try {
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000,
errors: ['time']
});
if (collected.first().content.toLowerCase() !== answer) return msg.say(`Nope, sorry, it's ${answer}.`);
else return msg.say('Nice job! 10/10! You deserve some cake!');
} catch (err) {
return msg.say(`Time! It was ${answer}, sorry!`);
}
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000
});
if (!collected.size) return msg.say(`Time! It was ${answer}, sorry!`);
if (collected.first().content.toLowerCase() !== answer) return msg.say(`Nope, sorry, it's ${answer}.`);
else return msg.say('Nice job! 10/10! You deserve some cake!');
}
};
+7 -11
View File
@@ -33,16 +33,12 @@ module.exports = class TypingGameCommand extends Command {
.setTitle(`You have ${time / 1000} seconds to type:`)
.setDescription(sentence);
await msg.embed(embed);
try {
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: time,
errors: ['time']
});
if (collected.first().content !== sentence) return msg.say('Nope, sorry!');
else return msg.say('Nice job! 10/10! You deserve some cake!');
} catch (err) {
return msg.say('Time! Sorry!');
}
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time
});
if (!collected.size) return msg.say('Time! Sorry!');
if (collected.first().content !== sentence) return msg.say('Nope, sorry!');
else return msg.say('Nice job! 10/10! You deserve some cake!');
}
};
+34 -39
View File
@@ -36,50 +36,45 @@ module.exports = class BanCommand extends Command {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
const { member, reason } = args;
if (!member.bannable) return msg.say('This member is not bannable. Perhaps they have a higher role than me?');
await msg.say(`Are you sure you want to ban ${member.user.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000
});
if (!collected.size || !['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting.');
try {
await msg.say(`Are you sure you want to ban ${member.user.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000,
errors: ['time']
});
if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Ban.');
try {
await member.user.send(stripIndents`
You were banned from ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await member.ban({
days: 7,
reason: `${msg.author.tag}: ${reason}`
});
await msg.say(`Successfully banned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
return msg.say('Could not log the ban to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
await member.send(stripIndents`
You were banned from ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await member.ban({
days: 7,
reason: `${msg.author.tag}: ${reason}`
});
await msg.say(`Successfully banned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
return msg.say('Could not log the ban to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Ban
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL())
.setColor(0xFF0000)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Ban
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFF0000)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Ban
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} catch (err) {
return msg.say('Aborting Ban.');
return modlogs.send({ embed });
}
}
};
+31 -36
View File
@@ -36,47 +36,42 @@ module.exports = class KickCommand extends Command {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
const { member, reason } = args;
if (!member.kickable) return msg.say('This member is not kickable. Perhaps they have a higher role than me?');
await msg.say(`Are you sure you want to kick ${member.user.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000
});
if (!collected.size || !['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting.');
try {
await msg.say(`Are you sure you want to kick ${member.user.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000,
errors: ['time']
});
if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Kick.');
try {
await member.user.send(stripIndents`
You were kicked from ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await member.kick({ reason: `${msg.author.tag}: ${reason}` });
await msg.say(`Successfully kicked ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
return msg.say('Could not log the kick to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
await member.send(stripIndents`
You were kicked from ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await member.kick({ reason: `${msg.author.tag}: ${reason}` });
await msg.say(`Successfully kicked ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
return msg.say('Could not log the kick to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Kick
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL())
.setColor(0xFFA500)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Kick
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFA500)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Kick
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} catch (err) {
return msg.say('Aborting Kick.');
return modlogs.send({ embed });
}
}
};
+35 -40
View File
@@ -36,51 +36,46 @@ module.exports = class SoftbanCommand extends Command {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
const { member, reason } = args;
if (!member.bannable) return msg.say('This member is not bannable. Perhaps they have a higher role than me?');
await msg.say(`Are you sure you want to softban ${member.user.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000
});
if (!collected.size || !['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting.');
try {
await msg.say(`Are you sure you want to softban ${member.user.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000,
errors: ['time']
});
if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Softban.');
try {
await member.user.send(stripIndents`
You were softbanned from ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await member.ban({
days: 7,
reason: `${msg.author.tag}: ${reason} (Softban)`
});
await msg.guild.unban(member.user, 'Softban');
await msg.say(`Successfully softbanned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
return msg.say('Could not log the softban to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
await member.send(stripIndents`
You were softbanned from ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await member.ban({
days: 7,
reason: `${msg.author.tag}: ${reason} (Softban)`
});
await msg.guild.unban(member.user, 'Softban');
await msg.say(`Successfully softbanned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
return msg.say('Could not log the softban to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Softban
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL())
.setColor(0xFF4500)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Softban
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFF4500)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Softban
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} catch (err) {
return msg.say('Aborting Softban.');
return modlogs.send({ embed });
}
}
};
+24 -29
View File
@@ -38,39 +38,34 @@ module.exports = class UnbanCommand extends Command {
const bans = await msg.guild.fetchBans();
if (!bans.has(id)) return msg.say('This ID is not in the Guild Banlist.');
const member = bans.get(id).user;
try {
await msg.say(`Are you sure you want to unban ${member.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000,
errors: ['time']
});
if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Unban.');
await msg.guild.unban(member, `${msg.author.tag}: ${reason}`);
await msg.say(`Successfully unbanned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
return msg.say('Could not log the unban to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
await msg.say(`Are you sure you want to unban ${member.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000
});
if (!collected.size || !['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting.');
await msg.guild.unban(member, `${msg.author.tag}: ${reason}`);
await msg.say(`Successfully unbanned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
return msg.say('Could not log the unban to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
**Member:** ${member.tag} (${member.id})
**Action:** Unban
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL())
.setColor(0x00AE86)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.tag} (${member.id})
**Action:** Unban
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0x00AE86)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.tag} (${member.id})
**Action:** Unban
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} catch (err) {
return msg.say('Aborting Unban.');
return modlogs.send({ embed });
}
}
};
+30 -35
View File
@@ -34,46 +34,41 @@ module.exports = class WarnCommand extends Command {
async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
const { member, reason } = args;
await msg.say(`Are you sure you want to warn ${member.user.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000
});
if (!collected.size || !['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting.');
try {
await msg.say(`Are you sure you want to warn ${member.user.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000,
errors: ['time']
});
if (!['y', 'yes'].includes(collected.first().content.toLowerCase())) return msg.say('Aborting Warn.');
try {
await member.user.send(stripIndents`
You were warned in ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await msg.say(`Successfully warned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
return msg.say('Could not log the warn to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
await member.user.send(stripIndents`
You were warned in ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await msg.say(`Successfully warned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
return msg.say('Could not log the warn to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Warn
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL())
.setColor(0xFFFF00)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Warn
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFFF00)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Warn
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} catch (err) {
return msg.say('Aborting Warn.');
return modlogs.send({ embed });
}
}
};
+1 -1
View File
@@ -19,7 +19,7 @@ module.exports = class CleverbotCommand extends Command {
]
});
this.clevs = new Cleverbot.Client({
this.clevs = new Cleverbot({
key: CLEVS_KEY,
user: CLEVS_USER,
nick: CLEVS_NICK
+1 -1
View File
@@ -39,6 +39,6 @@ module.exports = class MemeCommand extends Command {
run(msg, args) {
const { type, top, bottom } = args;
return msg.say({ files: [`https://memegen.link/${type}/${top}/${bottom}.jpg`] });
return msg.say(`https://memegen.link/${type}/${top}/${bottom}.jpg`);
}
};
+1 -2
View File
@@ -1,5 +1,4 @@
const Command = require('../../structures/Command');
const path = require('path');
module.exports = class SpamCommand extends Command {
constructor(client) {
@@ -13,6 +12,6 @@ module.exports = class SpamCommand extends Command {
}
run(msg) {
return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', 'spam.png')] });
return msg.say('https://i.imgur.com/arx7GJV.jpg');
}
};
+2 -5
View File
@@ -25,12 +25,9 @@ module.exports = class StarCommand extends Command {
async run(msg, args, reaction) {
const { id } = args;
const channel = msg.guild.channels.get(msg.guild.settings.get('starboard'));
if (!channel || this.starred.includes(id)) return null;
if (!channel.permissionsFor(this.client.user).has('SEND_MESSAGES')) return null;
if (!channel || !channel.permissionsFor(this.client.user).has('SEND_MESSAGES') || this.starred.includes(id)) return null;
const message = await msg.channel.fetchMessage(id);
if (!reaction && msg.author.id === message.author.id) {
return msg.reply('You cannot star your own messages, baka.');
}
if (!reaction && msg.author.id === message.author.id) return msg.reply('You cannot star your own messages, baka.');
this.starred.push(id);
if (!channel.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return msg.say(stripIndents`
+1 -1
View File
@@ -1,5 +1,5 @@
const Command = require('../../structures/Command');
const fishes = [':fish:', ':tropical_fish:', ':blowfish:'];
const fishes = [':fish:', ':tropical_fish:', ':blowfish:', ':wrench:'];
module.exports = class FishyCommand extends Command {
constructor(client) {
+3 -2
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command');
const { RichEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { cleanXML } = require('../../util/Util');
const { cleanXML } = require('../../structures/Util');
const { promisifyAll } = require('tsubaki');
const xml = promisifyAll(require('xml2js'));
const { ANIMELIST_LOGIN } = process.env;
@@ -49,7 +49,8 @@ module.exports = class AnimeCommand extends Command {
anime.entry[0].end_date[0], true);
return msg.embed(embed);
} catch (err) {
return msg.say('No Results.');
if (err.message === 'Parse Error') return msg.say('No Results.');
else throw err;
}
}
};
+2 -1
View File
@@ -41,7 +41,8 @@ module.exports = class BotSearchCommand extends Command {
body.prefix, true);
return msg.embed(embed);
} catch (err) {
return msg.say(err.message);
if (err.message === '404 Not Found') return msg.say('Bot Not Found.');
else throw err;
}
}
};
+2 -1
View File
@@ -48,7 +48,8 @@ module.exports = class GithubCommand extends Command {
body.language, true);
return msg.embed(embed);
} catch (err) {
return msg.say(err.message);
if (err.message === '404 Not Found') return msg.say('Repo Not Found.');
else throw err;
}
}
};
+1 -1
View File
@@ -28,7 +28,7 @@ module.exports = class GoogleCommand extends Command {
.query({ q: query });
const $ = cheerio.load(text);
let href = $('.r').first().find('a').first().attr('href');
if (!href) return msg.say('No Results.');
if (!href) return message.edit('No Results.');
href = querystring.parse(href.replace('/url?', ''));
return message.edit(href.q);
}
+3 -2
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command');
const { RichEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { cleanXML } = require('../../util/Util');
const { cleanXML } = require('../../structures/Util');
const { promisifyAll } = require('tsubaki');
const xml = promisifyAll(require('xml2js'));
const { ANIMELIST_LOGIN } = process.env;
@@ -49,7 +49,8 @@ module.exports = class MangaCommand extends Command {
manga.entry[0].end_date[0], true);
return msg.embed(embed);
} catch (err) {
return msg.say('No Results.');
if (err.message === 'Parse Error') return msg.say('No Results.');
else throw err;
}
}
};
+1 -1
View File
@@ -15,7 +15,7 @@ module.exports = class CowsayCommand extends Command {
type: 'string',
validate: (text) => {
if (text.length < 1500) return true;
else return 'Invalid Text. Text must be under 1500 characters.';
else return 'Text must be under 1500 characters.';
}
}
]
+2 -2
View File
@@ -16,9 +16,9 @@ module.exports = class MockingCommand extends Command {
type: 'string',
validate: (text) => {
if (text.length < 1950) return true;
else return 'Invalid Text. Text must be under 1950 characters.';
else return 'Text must be under 1950 characters.';
},
parse: (text) => text.split('')
parse: (text) => text.toLowerCase().split('')
}
]
});
+1 -1
View File
@@ -15,7 +15,7 @@ module.exports = class ZalgoCommand extends Command {
type: 'string',
validate: (text) => {
if (text.length < 500) return true;
else return 'Invalid Text. Text must be under 500 characters.';
else return 'Text must be under 500 characters.';
}
}
]
+1 -1
View File
@@ -20,6 +20,6 @@ module.exports = class AvatarCommand extends Command {
run(msg, args) {
const user = args.user || msg.author;
return msg.say(user.avatarURL('webp', 2048) || user.displayAvatarURL);
return msg.say(user.displayAvatarURL({ size: 2048 }));
}
};
+4 -15
View File
@@ -1,18 +1,7 @@
const Command = require('../../structures/Command');
const { RichEmbed } = require('discord.js');
const moment = require('moment');
const statuses = {
online: '<:online:313956277808005120> Online',
idle: '<:away:313956277220802560> Idle',
dnd: '<:dnd:313956276893646850> Do Not Disturb',
offline: '<:offline:313956277237710868> Offline'
};
const colors = {
online: 0x00AE86,
idle: 0xFFFF00,
dnd: 0xFF0000,
offline: 0x808080
};
const statuses = require('../../assets/json/user-info');
module.exports = class UserInfoCommand extends Command {
constructor(client) {
@@ -39,8 +28,8 @@ module.exports = class UserInfoCommand extends Command {
const member = args.member || msg.member;
const status = member.user.presence.status;
const embed = new RichEmbed()
.setColor(colors[status])
.setThumbnail(member.user.displayAvatarURL)
.setColor(statuses[status].color)
.setThumbnail(member.user.displayAvatarURL())
.addField(' Name',
member.user.tag, true)
.addField(' ID',
@@ -50,7 +39,7 @@ module.exports = class UserInfoCommand extends Command {
.addField(' Server Join Date',
moment(member.joinedTimestamp).format('MMMM Do YYYY h:mm:ss A'))
.addField(' Status',
statuses[status], true)
statuses[status].text, true)
.addField(' Playing',
member.user.presence.game ? member.user.presence.game.name : 'None', true);
return msg.embed(embed);
+13 -10
View File
@@ -1,6 +1,5 @@
const Command = require('../../structures/Command');
const { RichEmbed } = require('discord.js');
const { stripIndents } = require('common-tags');
module.exports = class HelpCommand extends Command {
constructor(client) {
@@ -29,14 +28,18 @@ module.exports = class HelpCommand extends Command {
const showAll = command && command.toLowerCase() === 'all';
if (command && !showAll) {
if (commands.length === 1) {
return msg.say(stripIndents`
__Command **${commands[0].name}**:__ *${commands[0].description}*
${commands[0].guildOnly ? 'Usable Only in Servers' : 'Usable in Servers and DM'}
**Format:** ${msg.anyUsage(`${commands[0].name} ${commands[0].format ? commands[0].format : ''}`)}
**Aliases:** ${commands[0].aliases.join(', ') || 'None'}
**Group:** ${commands[0].group.name}
${commands[0].details || ''}
`);
const embed = new RichEmbed()
.setTitle(`Command ${commands[0].name}`)
.setDescription(commands[0].description)
.addField(' Format',
msg.anyUsage(`${commands[0].name} ${commands[0].format ? commands[0].format : ''}`))
.addField(' Aliases',
commands[0].aliases.join(', ') || 'None')
.addField(' Group',
commands[0].group.name);
return msg.embed(embed);
} else if (commands.length > 1) {
return msg.say(`Multiple commands found, please be more specific: ${commands.map((c) => c.name).join(', ')}`);
} else {
return msg.say(`Could not identify command. Use \`${msg.usage(null)}\` to view a list of commands.`);
}
@@ -48,7 +51,7 @@ module.exports = class HelpCommand extends Command {
for (const group of this.client.registry.groups.values()) {
embed.addField(` ${group.name}`,
showAll ?
group.commands.map((c) => c.name).join(', ') :
group.commands.map((c) => c.name).join(', ') || 'None' :
group.commands.filter((c) => c.isUsable(msg)).map((c) => c.name).join(', ') || 'None');
}
try {
-1
View File
@@ -14,7 +14,6 @@
<ol>
<li>Moderation Commands Require a Channel set with x;modchannel to send Ban/Softban/Kick/Unban/Warn Logs</li>
<li>To use Member Join/Leave Logging, set a channel with x;memberchannel, a custom message can be set with x;membermsg</li>
<li>You can set a special role that is able to use Moderation commands (excluding lockdown) with x;staffrole</li>
<li>Use x;help to View a Command List</li>
<li>Visit my <a href="https://discord.gg/fqQF8mc">Home Server</a> for more support, or for updates, or if you just want to hang out.</li>
</ol>
-1
View File
@@ -72,7 +72,6 @@
<ol>
<li>Moderation Commands Require a Channel set with x;modchannel to send Ban/Softban/Kick/Unban/Warn Logs</li>
<li>To use Member Join/Leave Logging, set a channel with x;memberchannel, a custom message can be set with x;membermsg</li>
<li>You can set a special role that is able to use Moderation commands (excluding lockdown) with x;staffrole</li>
<li>Use x;help to View a Command List</li>
<li>Visit my <a href="https://discord.gg/fqQF8mc">Home Server</a> for more support, or for updates, or if you just want to hang out.</li>
</ol>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "22.1.4",
"version": "22.1.5",
"description": "A Discord Bot",
"main": "Shard.js",
"scripts": {
View File