mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 05:49:49 +02:00
Friendship Command
This commit is contained in:
@@ -132,7 +132,7 @@ in the appropriate channel's topic to use it.
|
|||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
Total: 384
|
Total: 385
|
||||||
|
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
@@ -230,6 +230,7 @@ Total: 384
|
|||||||
* **butt:** Determines a user's butt quality.
|
* **butt:** Determines a user's butt quality.
|
||||||
* **coolness:** Determines a user's coolness.
|
* **coolness:** Determines a user's coolness.
|
||||||
* **dick:** Determines your dick size. (NSFW)
|
* **dick:** Determines your dick size. (NSFW)
|
||||||
|
* **friendship:** Determines how good friends two users are.
|
||||||
* **guess-looks:** Guesses what a user looks like.
|
* **guess-looks:** Guesses what a user looks like.
|
||||||
* **iq:** Determines a user's IQ.
|
* **iq:** Determines a user's IQ.
|
||||||
* **psycho-pass:** Determines your Crime Coefficient.
|
* **psycho-pass:** Determines your Crime Coefficient.
|
||||||
@@ -638,6 +639,7 @@ here.
|
|||||||
- [astrology.TV](https://astrology.tv/)
|
- [astrology.TV](https://astrology.tv/)
|
||||||
* horoscope ([Horoscope Data](https://astrology.tv/horoscope/daily/))
|
* horoscope ([Horoscope Data](https://astrology.tv/horoscope/daily/))
|
||||||
- [Attype Studio](https://www.dafont.com/fadli-ramadhan-iskandar.d7339)
|
- [Attype Studio](https://www.dafont.com/fadli-ramadhan-iskandar.d7339)
|
||||||
|
* friendship ([Pinky Cupid Font](https://www.dafont.com/pinky-cupid.font))
|
||||||
* ship ([Pinky Cupid Font](https://www.dafont.com/pinky-cupid.font))
|
* ship ([Pinky Cupid Font](https://www.dafont.com/pinky-cupid.font))
|
||||||
- [Axis Order Bot](https://www.reddit.com/r/axisorderbot/wiki/index)
|
- [Axis Order Bot](https://www.reddit.com/r/axisorderbot/wiki/index)
|
||||||
* axis-cult (Prayer Data)
|
* axis-cult (Prayer Data)
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,109 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const { MersenneTwister19937, integer } = require('random-js');
|
||||||
|
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||||
|
const request = require('node-superfetch');
|
||||||
|
const path = require('path');
|
||||||
|
const { percentColor } = require('../../util/Util');
|
||||||
|
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Pinky Cupid.otf'), { family: 'Pinky Cupid' });
|
||||||
|
const percentColors = [
|
||||||
|
{ pct: 0.0, color: { r: 0, g: 0, b: 255 } },
|
||||||
|
{ pct: 0.5, color: { r: 0, g: 255 / 2, b: 255 / 2 } },
|
||||||
|
{ pct: 1.0, color: { r: 0, g: 255, b: 0 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
module.exports = class FriendshipCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'friendship',
|
||||||
|
aliases: ['friendship-meter', 'friends', 'friendship-tester', 'friendship-test', 'friend-test'],
|
||||||
|
group: 'random-seed',
|
||||||
|
memberName: 'friendship',
|
||||||
|
description: 'Determines how good friends two users are.',
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 10
|
||||||
|
},
|
||||||
|
clientPermissions: ['ATTACH_FILES'],
|
||||||
|
credit: [
|
||||||
|
{
|
||||||
|
name: 'Attype Studio',
|
||||||
|
url: 'https://www.dafont.com/fadli-ramadhan-iskandar.d7339',
|
||||||
|
reason: 'Pinky Cupid Font',
|
||||||
|
reasonURL: 'https://www.dafont.com/pinky-cupid.font'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'first',
|
||||||
|
label: 'first user',
|
||||||
|
prompt: 'Who is the first friend?',
|
||||||
|
type: 'user'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'second',
|
||||||
|
label: 'second user',
|
||||||
|
prompt: 'Who is the second friend?',
|
||||||
|
type: 'user',
|
||||||
|
default: msg => msg.author
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { first, second }) {
|
||||||
|
if (first.id === second.id) return msg.reply('You should be good friends with yourself.');
|
||||||
|
const calculated = -Math.abs(Number.parseInt(BigInt(first.id) - BigInt(second.id), 10));
|
||||||
|
const random = MersenneTwister19937.seed(calculated);
|
||||||
|
const level = integer(0, 100)(random);
|
||||||
|
const firstAvatarURL = first.displayAvatarURL({ format: 'png', size: 512 });
|
||||||
|
const secondAvatarURL = second.displayAvatarURL({ format: 'png', size: 512 });
|
||||||
|
try {
|
||||||
|
const firstAvatarData = await request.get(firstAvatarURL);
|
||||||
|
const firstAvatar = await loadImage(firstAvatarData.body);
|
||||||
|
const secondAvatarData = await request.get(secondAvatarURL);
|
||||||
|
const secondAvatar = await loadImage(secondAvatarData.body);
|
||||||
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'friendship.png'));
|
||||||
|
const canvas = createCanvas(base.width, base.height);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
ctx.drawImage(firstAvatar, 70, 56, 400, 400);
|
||||||
|
ctx.drawImage(secondAvatar, 730, 56, 400, 400);
|
||||||
|
ctx.drawImage(base, 0, 0);
|
||||||
|
ctx.textAlign = 'center';
|
||||||
|
ctx.textBaseline = 'top';
|
||||||
|
ctx.fillStyle = 'green';
|
||||||
|
ctx.font = '40px Pinky Cupid';
|
||||||
|
ctx.fillText('~Xiao\'s Friendship Meter~', 600, 15);
|
||||||
|
ctx.fillStyle = 'white';
|
||||||
|
ctx.fillText(first.username, 270, 448);
|
||||||
|
ctx.fillText(second.username, 930, 448);
|
||||||
|
ctx.font = '60px Pinky Cupid';
|
||||||
|
ctx.fillStyle = percentColor(level / 100, percentColors);
|
||||||
|
ctx.fillText(`~${level}%~`, 600, 230);
|
||||||
|
ctx.fillText(this.calculateLevelText(level), 600, 296);
|
||||||
|
ctx.font = '90px Pinky Cupid';
|
||||||
|
ctx.fillText(level > 49 ? '👍' : '👎', 600, 100);
|
||||||
|
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'friendship.png' }] });
|
||||||
|
} catch (err) {
|
||||||
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateLevelText(level) {
|
||||||
|
if (level === 0) return 'Abysmal';
|
||||||
|
if (level > 0 && level < 10) return 'Horrid';
|
||||||
|
if (level > 9 && level < 20) return 'Awful';
|
||||||
|
if (level > 19 && level < 30) return 'Very Bad';
|
||||||
|
if (level > 29 && level < 40) return 'Bad';
|
||||||
|
if (level > 39 && level < 50) return 'Poor';
|
||||||
|
if (level > 49 && level < 60) return 'Average';
|
||||||
|
if (level > 59 && level < 70) {
|
||||||
|
if (level === 69) return 'Nice';
|
||||||
|
return 'Fine';
|
||||||
|
}
|
||||||
|
if (level > 69 && level < 80) return 'Good';
|
||||||
|
if (level > 79 && level < 90) return 'Great';
|
||||||
|
if (level > 89 && level < 100) return 'Amazing';
|
||||||
|
if (level === 100) return 'Best Friends';
|
||||||
|
return '???';
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -3,6 +3,7 @@ const { MersenneTwister19937, integer } = require('random-js');
|
|||||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const { percentColor } = require('../../util/Util');
|
||||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Pinky Cupid.otf'), { family: 'Pinky Cupid' });
|
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Pinky Cupid.otf'), { family: 'Pinky Cupid' });
|
||||||
const percentColors = [
|
const percentColors = [
|
||||||
{ pct: 0.0, color: { r: 0, g: 0, b: 255 } },
|
{ pct: 0.0, color: { r: 0, g: 0, b: 255 } },
|
||||||
@@ -14,6 +15,7 @@ module.exports = class ShipCommand extends Command {
|
|||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, {
|
super(client, {
|
||||||
name: 'ship',
|
name: 'ship',
|
||||||
|
aliases: ['compatability-meter', 'compatability', 'love-tester', 'love-test'],
|
||||||
group: 'random-seed',
|
group: 'random-seed',
|
||||||
memberName: 'ship',
|
memberName: 'ship',
|
||||||
description: 'Ships two users together.',
|
description: 'Ships two users together.',
|
||||||
@@ -75,7 +77,7 @@ module.exports = class ShipCommand extends Command {
|
|||||||
ctx.fillText(first.username, 270, 448);
|
ctx.fillText(first.username, 270, 448);
|
||||||
ctx.fillText(second.username, 930, 448);
|
ctx.fillText(second.username, 930, 448);
|
||||||
ctx.font = '60px Pinky Cupid';
|
ctx.font = '60px Pinky Cupid';
|
||||||
ctx.fillStyle = this.percentColor(level / 100);
|
ctx.fillStyle = percentColor(level / 100, percentColors);
|
||||||
ctx.fillText(`~${level}%~`, 600, 230);
|
ctx.fillText(`~${level}%~`, 600, 230);
|
||||||
ctx.fillText(this.calculateLevelText(level), 600, 296);
|
ctx.fillText(this.calculateLevelText(level), 600, 296);
|
||||||
ctx.font = '90px Pinky Cupid';
|
ctx.font = '90px Pinky Cupid';
|
||||||
@@ -104,25 +106,4 @@ module.exports = class ShipCommand extends Command {
|
|||||||
if (level === 100) return 'Soulmates';
|
if (level === 100) return 'Soulmates';
|
||||||
return '???';
|
return '???';
|
||||||
}
|
}
|
||||||
|
|
||||||
percentColor(pct) {
|
|
||||||
let i = 1;
|
|
||||||
for (i; i < percentColors.length - 1; i++) {
|
|
||||||
if (pct < percentColors[i].pct) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const lower = percentColors[i - 1];
|
|
||||||
const upper = percentColors[i];
|
|
||||||
const range = upper.pct - lower.pct;
|
|
||||||
const rangePct = (pct - lower.pct) / range;
|
|
||||||
const pctLower = 1 - rangePct;
|
|
||||||
const pctUpper = rangePct;
|
|
||||||
const color = {
|
|
||||||
r: Math.floor((lower.color.r * pctLower) + (upper.color.r * pctUpper)).toString(16).padStart(2, '0'),
|
|
||||||
g: Math.floor((lower.color.g * pctLower) + (upper.color.g * pctUpper)).toString(16).padStart(2, '0'),
|
|
||||||
b: Math.floor((lower.color.b * pctLower) + (upper.color.b * pctUpper)).toString(16).padStart(2, '0')
|
|
||||||
};
|
|
||||||
return `#${color.r}${color.g}${color.b}`;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "113.0.7",
|
"version": "113.1.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -106,6 +106,27 @@ module.exports = class Util {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static percentColor(pct, percentColors) {
|
||||||
|
let i = 1;
|
||||||
|
for (i; i < percentColors.length - 1; i++) {
|
||||||
|
if (pct < percentColors[i].pct) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const lower = percentColors[i - 1];
|
||||||
|
const upper = percentColors[i];
|
||||||
|
const range = upper.pct - lower.pct;
|
||||||
|
const rangePct = (pct - lower.pct) / range;
|
||||||
|
const pctLower = 1 - rangePct;
|
||||||
|
const pctUpper = rangePct;
|
||||||
|
const color = {
|
||||||
|
r: Math.floor((lower.color.r * pctLower) + (upper.color.r * pctUpper)).toString(16).padStart(2, '0'),
|
||||||
|
g: Math.floor((lower.color.g * pctLower) + (upper.color.g * pctUpper)).toString(16).padStart(2, '0'),
|
||||||
|
b: Math.floor((lower.color.b * pctLower) + (upper.color.b * pctUpper)).toString(16).padStart(2, '0')
|
||||||
|
};
|
||||||
|
return `#${color.r}${color.g}${color.b}`;
|
||||||
|
}
|
||||||
|
|
||||||
static today(timeZone) {
|
static today(timeZone) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
if (timeZone) now.setUTCHours(timeZone);
|
if (timeZone) now.setUTCHours(timeZone);
|
||||||
|
|||||||
Reference in New Issue
Block a user