Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #8

Merged
merged 5 commits into from
Sep 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Tsubaki.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Help = require('./commands/information/Help.js');
const Info = require('./commands/information/Info.js');
const Stats = require('./commands/information/Stats.js');
const SysInfo = require('./commands/information/SysInfo.js');
const Profile = require('./commands/information/Profile.js');
const Pinfo = require('./commands/information/Pinfo.js');
const Invite = require('./commands/information/Invite.js');
const Support = require('./commands/information/Support.js');
const ChangeLog = require('./commands/information/ChangeLog.js');
Expand Down Expand Up @@ -341,7 +341,7 @@ setPlaying();
new Info(),
new Stats(),
new SysInfo(),
new Profile(),
new Pinfo(),
new Invite(),
new Support(),
new ChangeLog(),
Expand Down
4 changes: 2 additions & 2 deletions commands/admin/Ban.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class Ban extends AdminCommand {
}

message.channel.sendType(Tsubaki.Style.success(
`${userToBan.tag} has been **banned** by **${message.author}**`
+ (reason.length > 0 ? ` for: **${reason}` : ' !')
`**${userToBan.tag}** has been **banned** by **${message.author}**`
+ (reason.length > 0 ? ` for: **${reason}**` : ' !')
) );
} else if (!isBannable || !(userID.bannable)) {
message.channel.sendType(Tsubaki.Style.error(
Expand Down
2 changes: 1 addition & 1 deletion commands/admin/Kick.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Kick extends AdminCommand {
}

message.channel.sendType(Tsubaki.Style.success(
`${userToKick.tag} has been **kicked** by **${message.author}**`
`**${userToKick.tag}** has been **kicked** by **${message.author}**`
+ (reason.length > 0 ? ` for: **${reason}**` : ' !')
)
);
Expand Down
2 changes: 1 addition & 1 deletion commands/admin/UnBan.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class UnBan extends AdminCommand {
message.guild.unban(userToUnBan);

message.channel.sendType(Tsubaki.Style.success(
`${userToUnban.tag} have been **unbanned** by **${message.author}**`
`**${userToUnban.tag}** have been **unbanned** by **${message.author}**`
+ (reason.length > 0 ? ` for: **${reason}**` : ' !')
) );
}
Expand Down
2 changes: 1 addition & 1 deletion commands/fun/Banana.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Banana extends Command {
message.channel.sendType(Tsubaki.Style.unknownUser() );
} else {
message.channel.sendType(Tsubaki.Style.success(
`**${message.author.tag}** has given ${memberMention} a banana! :banana:`
`**${message.author.tag}** has given ${memberMention} a banana!`
) );

Tsubaki.getPoints(memberMention.id).then((points) => {
Expand Down
2 changes: 1 addition & 1 deletion commands/information/ChangeLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ChangeLog extends Command {
*/
execute(message, args, bot, db) {
let embed = new Discord.RichEmbed()
.setDescription('not done ;)')
.setDescription('um something idk')
.setColor(Tsubaki.color.white);
message.channel.sendType({embed: embed} );
}
Expand Down
66 changes: 33 additions & 33 deletions commands/information/Profile.js → commands/information/Pinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ let fontBold = process.env['HOME'] + '/.fonts/EncodeSansSemiCondensed-Bold.ttf';
let pointsBar = '#BF42F400';
let devColor = '#2BBBEF00';

/** The profile command */
class Profile extends Command {
/** The pinfo command */
class pinfo extends Command {
/** Create the command */
constructor() {
super(
'profile', 'Will show your profile or the mentioned profile.'
'pinfo', 'Will show your pinfo or the mentioned pinfo.'
, ' [@mention]'
);
}
Expand All @@ -63,17 +63,17 @@ class Profile extends Command {
* @param {sqlite.Database} db The instance of the database
*/
executeNew(message, args, bot, db) {
let profileMention = message.mentions.users.first();
if (profileMention == '' || profileMention === undefined) {
let pinfoMention = message.mentions.users.first();
if (pinfoMention == '' || pinfoMention === undefined) {
if (args.length === 0) {
profileMention = message.author;
pinfoMention = message.author;
} else {
message.channel.sendType(Tsubaki.Style.unknownUser() );
return;
}
}

let name = profileMention.username;
let name = pinfoMention.username;

let dir = '';
let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
Expand All @@ -87,21 +87,21 @@ class Profile extends Command {

let fontInfo;

Profile.getP(profileMention.displayAvatarURL).then((response) => {
pinfo.getP(pinfoMention.displayAvatarURL).then((response) => {
// response.pipe(file);
return Profile.createAvatar(response, dir);
return pinfo.createAvatar(response, dir);
}).then(() => {
return Profile.getSize(name, textRegionWidth - 100, textRegionHeight, 20);
return pinfo.getSize(name, textRegionWidth - 100, textRegionHeight, 20);
}).then((info) => {
fontInfo = info;
return Tsubaki.getPoints(profileMention.id);
return Tsubaki.getPoints(pinfoMention.id);
}).then((points) => {
return Profile.drawProfile(profileMention, points, dir, fontInfo.size, fontInfo.width);
return pinfo.drawpinfo(pinfoMention, points, dir, fontInfo.size, fontInfo.width);
}).then((imgBuffer) => {
message.channel.sendType({
files: [{
attachment: imgBuffer,
name: profileMention.username + '.gif',
name: pinfoMention.username + '.gif',
}],
} );
}).catch((err) => {
Expand Down Expand Up @@ -199,7 +199,7 @@ class Profile extends Command {
if (err) reject(err);

if (size.width >= width || size.height >= height) {
Profile.getSize(text, width, height, fontSize - 5)
pinfo.getSize(text, width, height, fontSize - 5)
.then((fontInfo) => {
resolve(fontInfo);
}).catch((err) => {
Expand All @@ -216,16 +216,16 @@ class Profile extends Command {

/**
*
* @param {Discord.User} profile The user's profile
* @param {Discord.User} pinfo The user's pinfo
* @param {number} points The number of points the user has
* @param {string} dir The temporary directory for the files
* @param {number} fontSize The font size for the name
* @param {number} nameWidth The width of the name at that font size
* @return {Promise.<string, Error>} A buffer of the drawn image if resolved,
* an error if rejected
*/
static drawProfile(profile, points, dir, fontSize, nameWidth) {
let name = profile.username;
static drawpinfo(pinfo, points, dir, fontSize, nameWidth) {
let name = pinfo.username;

let level = Tsubaki.getLevelR(points);
let levelPoints = Tsubaki.getPointsFor(level);
Expand All @@ -239,14 +239,14 @@ class Profile extends Command {
let role = '';
let roleColor = '#FFFFFFFF';

if (profile.id === Tsubaki.ianId || profile.id === Tsubaki.davidId) {
if (pinfo.id === Tsubaki.ianId || pinfo.id === Tsubaki.davidId) {
role = 'Dev';
roleColor = devColor;
}

return new Promise((resolve, reject) => {
// replace avatar with background
Profile.getP(profile.displayAvatarURL).then((response) => {
pinfo.getP(pinfo.displayAvatarURL).then((response) => {
gm(response, 'image.png')
.autoOrient()
.resize(width, height)
Expand Down Expand Up @@ -353,7 +353,7 @@ class Profile extends Command {
.write(`${dir}/part-${i}.png`, (err) => {
if (err) reject(err);
if (++parts >= 20) {
Profile.toGif(dir).then((imgBuffer) => {
pinfo.toGif(dir).then((imgBuffer) => {
resolve(imgBuffer);
});
}
Expand Down Expand Up @@ -399,18 +399,18 @@ class Profile extends Command {
this.executeNew(message, args.slice(1), bot, db);
return;
}
let profileMention = message.mentions.users.first();
if (profileMention == '' || profileMention === undefined) {
let pinfoMention = message.mentions.users.first();
if (pinfoMention == '' || pinfoMention === undefined) {
if (args.length === 0) {
profileMention = message.author;
pinfoMention = message.author;
} else {
message.channel.sendType(Tsubaki.Style.unknownUser() );
return;
}
}

let color = Tsubaki.color.gray;
switch (profileMention.presence.status) {
switch (pinfoMention.presence.status) {
case 'online':
color = Tsubaki.color.green;
break;
Expand All @@ -425,22 +425,22 @@ class Profile extends Command {
let guildMember = message.member;
let roleList = guildMember.roles.array();

Tsubaki.getPoints(profileMention.id).then((points) => {
let profileEmbed = new Discord.RichEmbed()
Tsubaki.getPoints(pinfoMention.id).then((points) => {
let pinfoEmbed = new Discord.RichEmbed()
.setDescription(`**__${guildMember.displayName}__**`)
.addField('Full Username', profileMention.tag, true)
.addField('ID', profileMention.id, true)
.addField('Full Username', pinfoMention.tag, true)
.addField('ID', pinfoMention.id, true)
.addField(
'Banana'
, `Level ${Tsubaki.getLevelR(points)}, with ${points} Bananas`
, true
)
.addField('Roles', roleList.join(' '), true)
.setThumbnail(profileMention.displayAvatarURL)
.setFooter(`Member since ${Profile.formatDate(guildMember.joinedAt)}`
+ `, Discorder since ${Profile.formatDate(profileMention.createdAt)}`)
.setThumbnail(pinfoMention.displayAvatarURL)
.setFooter(`Member since ${pinfo.formatDate(guildMember.joinedAt)}`
+ `, Discorder since ${pinfo.formatDate(pinfoMention.createdAt)}`)
.setColor(color);
message.channel.sendType({embed: profileEmbed} );
message.channel.sendType({embed: pinfoEmbed} );
});
}

Expand All @@ -460,4 +460,4 @@ class Profile extends Command {
}
}

module.exports = Profile;
module.exports = pinfo;