mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Two Buttons Command
This commit is contained in:
@@ -224,7 +224,7 @@ in the appropriate channel's topic to use it.
|
||||
|
||||
## Commands
|
||||
|
||||
Total: 437
|
||||
Total: 438
|
||||
|
||||
### Utility:
|
||||
|
||||
@@ -614,6 +614,7 @@ Total: 437
|
||||
* **spongebob-burn:** Sends a "Spongebob Throwing Something into a Fire" meme with words of your choice.
|
||||
* **thug-life:** Draws "Thug Life" over an image or a user's avatar.
|
||||
* **to-be-continued:** Draws an image with the "To Be Continued..." arrow.
|
||||
* **two-buttons:** Sends a "Two Buttons" meme with the buttons of your choice.
|
||||
* **ultimate-tattoo:** Draws an image or a user's avatar as "The Ultimate Tattoo".
|
||||
* **vietnam-flashbacks:** Edits Vietnam flashbacks behind an image or a user's avatar.
|
||||
* **worthless:** Draws an image or a user's avatar over Gravity Falls' "This is worthless." meme.
|
||||
@@ -955,6 +956,7 @@ here.
|
||||
* steam-now-playing ([Noto Font](https://www.google.com/get/noto/))
|
||||
* steam-now-playing-classic ([Noto Font](https://www.google.com/get/noto/))
|
||||
* translate ([Google Translate](https://translate.google.com/))
|
||||
* two-buttons ([Noto Font](https://www.google.com/get/noto/))
|
||||
* youtube ([YouTube Data API](https://developers.google.com/youtube/v3/))
|
||||
- [Google Feud](http://www.googlefeud.com/)
|
||||
* google-feud (Original Game)
|
||||
@@ -1032,6 +1034,8 @@ here.
|
||||
* guesspionage ([Original "Guesspionage" Game](https://www.jackboxgames.com/guesspionage/))
|
||||
* lie-swatter ([Original "Lie Swatter" Game](https://www.jackboxgames.com/lie-swatter/))
|
||||
* word-spud ([Original "Word Spud" Game](https://www.jackboxgames.com/word-spud/))
|
||||
- [Jake Clark](https://jake-clark.tumblr.com/)
|
||||
* two-buttons ([Image](https://twitter.com/jakeclarkdude/status/689141113584619524))
|
||||
- [jasmaa](https://github.com/jasmaa/)
|
||||
* neko-atsume-password ([API URL](https://github.com/jasmaa/nekoatsume-password-learner/blob/master/neko_pswd.py#L4))
|
||||
- [JellyNeo Item Database](https://items.jellyneo.net/)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 435 KiB |
@@ -0,0 +1,76 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||
const path = require('path');
|
||||
const { wrapText } = require('../../util/Canvas');
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' });
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' });
|
||||
|
||||
module.exports = class TwoButtonsCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'two-buttons',
|
||||
aliases: ['buttons', 'button'],
|
||||
group: 'edit-meme',
|
||||
memberName: 'two-buttons',
|
||||
description: 'Sends a "Two Buttons" meme with the buttons of your choice.',
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
credit: [
|
||||
{
|
||||
name: 'Google',
|
||||
url: 'https://www.google.com/',
|
||||
reason: 'Noto Font',
|
||||
reasonURL: 'https://www.google.com/get/noto/'
|
||||
},
|
||||
{
|
||||
name: 'Jake Clark',
|
||||
url: 'https://jake-clark.tumblr.com/',
|
||||
reason: 'Image',
|
||||
reasonURL: 'https://twitter.com/jakeclarkdude/status/689141113584619524'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'first',
|
||||
prompt: 'What should the text of the first button be?',
|
||||
type: 'string',
|
||||
max: 50
|
||||
},
|
||||
{
|
||||
key: 'second',
|
||||
prompt: 'What should the text of the second button be?',
|
||||
type: 'string',
|
||||
max: 50
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { first, second }) {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'two-buttons.png'));
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.rotate(12 * (Math.PI / 180));
|
||||
ctx.font = '50px Noto';
|
||||
while (ctx.measureText(first).width > 183) {
|
||||
fontSize -= 1;
|
||||
ctx.font = `${fontSize}px Noto`;
|
||||
}
|
||||
const firstLines = await wrapText(ctx, first, 183);
|
||||
ctx.fillText(firstLines.join('\n'), 126, 70);
|
||||
ctx.font = '50px Noto';
|
||||
while (ctx.measureText(second).width > 122) {
|
||||
fontSize -= 1;
|
||||
ctx.font = `${fontSize}px Noto`;
|
||||
}
|
||||
const secondLines = await wrapText(ctx, second, 122);
|
||||
ctx.fillText(secondLines.join('\n'), 355, 79);
|
||||
ctx.rotate(-12 * (Math.PI / 180));
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'two-buttons.png' }] });
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "114.24.0",
|
||||
"version": "114.25.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user