Allow ship/friendship with self

This commit is contained in:
Dragon Fire
2020-06-05 00:24:00 -04:00
parent 1caa7352eb
commit b99826340a
3 changed files with 13 additions and 7 deletions
+6 -3
View File
@@ -51,14 +51,16 @@ module.exports = class FriendshipCommand extends Command {
}
async run(msg, { first, second }) {
if (first.id === second.id) return msg.reply('You should be good friends with yourself.');
let level;
const self = first.id === second.id;
const owner = this.client.isOwner(first) || this.client.isOwner(second);
const authorUser = first.id === msg.author.id || second.id === msg.author.id;
const botUser = first.id === this.client.user.id || second.id === this.client.user.id;
if (owner && botUser) {
if (authorUser) level = 100;
else level = 0;
} else if (self) {
level = 100;
} else {
const calculated = -Math.abs(Number.parseInt(BigInt(first.id) - BigInt(second.id), 10));
const random = MersenneTwister19937.seed(calculated);
@@ -88,7 +90,7 @@ module.exports = class FriendshipCommand extends Command {
ctx.font = '60px Pinky Cupid';
ctx.fillStyle = percentColor(level / 100, percentColors);
ctx.fillText(`~${level}%~`, 600, 230);
ctx.fillText(this.calculateLevelText(level, owner, authorUser, botUser), 600, 296);
ctx.fillText(this.calculateLevelText(level, self, owner, authorUser, botUser), 600, 296);
ctx.font = '90px Pinky Cupid';
ctx.fillText(level > 49 ? '👍' : '👎', 600, 100);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'friendship.png' }] });
@@ -97,11 +99,12 @@ module.exports = class FriendshipCommand extends Command {
}
}
calculateLevelText(level, owner, authorUser, botUser) {
calculateLevelText(level, self, owner, authorUser, botUser) {
if (owner && botUser) {
if (authorUser) return 'Perfect';
else return 'Yuck';
}
if (self) return 'Narcissist';
if (level === 0) return 'Abysmal';
if (level > 0 && level < 10) return 'Horrid';
if (level > 9 && level < 20) return 'Awful';
+6 -3
View File
@@ -51,13 +51,15 @@ module.exports = class ShipCommand extends Command {
}
async run(msg, { first, second }) {
if (first.id === second.id) return msg.reply('Shipping someone with themselves would be pretty weird.');
let level;
const self = first.id === second.id;
const owner = this.client.isOwner(first) || this.client.isOwner(second);
const authorUser = first.id === msg.author.id || second.id === msg.author.id;
const botUser = first.id === this.client.user.id || second.id === this.client.user.id;
if (owner && botUser) {
level = 0;
} else if (self) {
level = 100;
} else {
const calculated = Math.abs(Number.parseInt(BigInt(first.id) - BigInt(second.id), 10));
const random = MersenneTwister19937.seed(calculated);
@@ -87,7 +89,7 @@ module.exports = class ShipCommand extends Command {
ctx.font = '60px Pinky Cupid';
ctx.fillStyle = percentColor(level / 100, percentColors);
ctx.fillText(`~${level}%~`, 600, 230);
ctx.fillText(this.calculateLevelText(level, owner, authorUser, botUser), 600, 296);
ctx.fillText(this.calculateLevelText(level, self, owner, authorUser, botUser), 600, 296);
ctx.font = '90px Pinky Cupid';
ctx.fillText(level > 49 ? '❤️' : '💔', 600, 100);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'ship.png' }] });
@@ -96,11 +98,12 @@ module.exports = class ShipCommand extends Command {
}
}
calculateLevelText(level, owner, authorUser, botUser) {
calculateLevelText(level, self, owner, authorUser, botUser) {
if (owner && botUser) {
if (authorUser) return 'Pervert';
else return 'Yuck';
}
if (self) return 'Narcissist';
if (level === 0) return 'Abysmal';
if (level > 0 && level < 10) return 'Horrid';
if (level > 9 && level < 20) return 'Awful';
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "116.1.3",
"version": "116.1.4",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {