mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
DiceBear Command, Fix Adorable
This commit is contained in:
@@ -257,7 +257,7 @@ in the appropriate channel's topic to use it.
|
||||
|
||||
## Commands
|
||||
|
||||
Total: 550
|
||||
Total: 551
|
||||
|
||||
### Utility:
|
||||
|
||||
@@ -619,6 +619,7 @@ Total: 550
|
||||
* **danger:** Creates a danger sign with the text of your choice.
|
||||
* **desaturate:** Draws an image or a user's avatar but desaturated.
|
||||
* **dexter:** Draws an image or a user's avatar over the screen of Dexter from Pokémon.
|
||||
* **dicebear:** Creates a DiceBear avatar based on the text you provide.
|
||||
* **distort:** Draws an image or a user's avatar but distorted.
|
||||
* **emboss:** Draws an image or a user's avatar but embossed.
|
||||
* **fire-frame:** Draws a fiery border over an image or a user's avatar.
|
||||
@@ -916,7 +917,7 @@ here.
|
||||
- [@liltusk](https://twitter.com/liltusk)
|
||||
* food-broke ([Image](https://twitter.com/liltusk/status/835719948597137408))
|
||||
- [Adorable Avatars](http://avatars.adorable.io/)
|
||||
* adorable (API)
|
||||
* adorable (Original API)
|
||||
- [Advice Slip](https://adviceslip.com/)
|
||||
* advice ([API](https://api.adviceslip.com/))
|
||||
- [Akinator](https://en.akinator.com/)
|
||||
@@ -1035,6 +1036,8 @@ here.
|
||||
* deviantart ([API](https://www.deviantart.com/developers/))
|
||||
- [devsnek](https://github.com/devsnek)
|
||||
* owo (Code)
|
||||
- [DiceBear](https://avatars.dicebear.com/)
|
||||
* dicebear (API)
|
||||
- [Digital Equipment Corporation](http://gordonbell.azurewebsites.net/digital/timeline/tmlnhome.htm)
|
||||
* dec-talk (Original DECTalk Software)
|
||||
- [Discord](https://discord.com/)
|
||||
@@ -1107,6 +1110,8 @@ here.
|
||||
* gender (API)
|
||||
- [Gerhard Jordan](http://www.gerhardjordan.com/)
|
||||
* never-have-i-ever ([Statement Data](http://www.neverhaveiever.org/))
|
||||
- [gfauchart](https://github.com/gfauchart)
|
||||
* adorable ([API](https://github.com/adorableio/avatars-api-middleware/issues/108))
|
||||
- [GIPHY](https://giphy.com/)
|
||||
* giphy ([API](https://developers.giphy.com/))
|
||||
- [GitHub](https://github.com/)
|
||||
|
||||
@@ -14,7 +14,13 @@ module.exports = class AdorableCommand extends Command {
|
||||
{
|
||||
name: 'Adorable Avatars',
|
||||
url: 'http://avatars.adorable.io/',
|
||||
reason: 'API'
|
||||
reason: 'Original API'
|
||||
},
|
||||
{
|
||||
name: 'gfauchart',
|
||||
url: 'https://github.com/gfauchart',
|
||||
reason: 'API',
|
||||
reasonURL: 'https://github.com/adorableio/avatars-api-middleware/issues/108'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
@@ -30,7 +36,7 @@ module.exports = class AdorableCommand extends Command {
|
||||
|
||||
async run(msg, { text }) {
|
||||
try {
|
||||
const { body } = await request.get(`https://api.adorable.io/avatars/285/${text}.png`);
|
||||
const { body } = await request.get(`https://api.hello-avatar.com/adorables/285/${text}.png`);
|
||||
return msg.say({ files: [{ attachment: body, name: 'adorable.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const { list } = require('../../util/Util');
|
||||
const emotions = ['happy', 'sad', 'surprised'];
|
||||
|
||||
module.exports = class DicebearCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'dicebear',
|
||||
aliases: ['dicebear-avatar'],
|
||||
group: 'edit-image',
|
||||
memberName: 'dicebear',
|
||||
description: 'Creates a DiceBear avatar based on the text you provide.',
|
||||
clientPermissions: ['ATTACH_FILES'],
|
||||
throttling: {
|
||||
usages: 1,
|
||||
duration: 10
|
||||
},
|
||||
credit: [
|
||||
{
|
||||
name: 'DiceBear Avatars',
|
||||
url: 'https://avatars.dicebear.com/',
|
||||
reason: 'API'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'gender',
|
||||
prompt: 'What gender do you want to use? Either male or female.',
|
||||
type: 'string',
|
||||
oneOf: ['male', 'female'],
|
||||
parse: gender => gender.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'emotion',
|
||||
prompt: `What emotion should the avatar display? Either ${list(emotions, 'or')}.`,
|
||||
type: 'string',
|
||||
oneOf: emotions,
|
||||
parse: emotion => emotion.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'text',
|
||||
prompt: 'What text should be used for generation?',
|
||||
type: 'string',
|
||||
parse: text => encodeURIComponent(text)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { gender, emotion, text }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`https://avatars.dicebear.com/api/${gender}/${text}.svg`)
|
||||
.query({
|
||||
width: 285,
|
||||
height: 285,
|
||||
'mood[]': emotion
|
||||
});
|
||||
const canvas = createCanvas(285, 285);
|
||||
const ctx = canvas.getContext('2d');
|
||||
const img = await loadImage(body);
|
||||
ctx.drawImage(img, 0, 0, 285, 285);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'dicebear.png' }] });
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "119.32.0",
|
||||
"version": "119.33.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user