mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 23:05:04 +02:00
Clean ups
This commit is contained in:
@@ -15,7 +15,7 @@ module.exports = class WhatAnimeCommand extends Command {
|
||||
{
|
||||
key: 'screenshot',
|
||||
prompt: 'What screenshot do you want to scan?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -19,7 +19,7 @@ module.exports = class ContrastCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -35,7 +35,7 @@ module.exports = class DemotivationalPosterCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 1024 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -25,7 +25,7 @@ module.exports = class DistortCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -20,7 +20,7 @@ module.exports = class FrameCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -19,7 +19,7 @@ module.exports = class GlitchCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -20,7 +20,7 @@ module.exports = class GreyscaleCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -19,7 +19,7 @@ module.exports = class IfunnyCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -19,7 +19,7 @@ module.exports = class InvertCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -19,7 +19,7 @@ module.exports = class NeedsMoreJpegCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
},
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ module.exports = class PixelizeCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -20,7 +20,7 @@ module.exports = class RainbowCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -19,7 +19,7 @@ module.exports = class SepiaCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -19,7 +19,7 @@ module.exports = class SilhouetteCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -25,7 +25,7 @@ module.exports = class TintCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
@@ -20,7 +20,7 @@ module.exports = class ToBeContinuedCommand extends Command {
|
||||
{
|
||||
key: 'image',
|
||||
prompt: 'What image would you like to edit?',
|
||||
type: 'image|avatar',
|
||||
type: 'image',
|
||||
default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 })
|
||||
}
|
||||
]
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "90.1.0",
|
||||
"version": "90.1.1",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
const { ArgumentType } = require('discord.js-commando');
|
||||
|
||||
module.exports = class AvatarArgumentType extends ArgumentType {
|
||||
constructor(client) {
|
||||
super(client, 'avatar');
|
||||
}
|
||||
|
||||
validate(value, msg, arg) {
|
||||
return this.client.registry.types.get('user').validate(value, msg, arg);
|
||||
}
|
||||
|
||||
async parse(value, msg, arg) {
|
||||
const user = await this.client.registry.types.get('user').parse(value, msg, arg);
|
||||
return user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
}
|
||||
};
|
||||
+15
-8
@@ -5,18 +5,25 @@ module.exports = class ImageArgumentType extends ArgumentType {
|
||||
super(client, 'image');
|
||||
}
|
||||
|
||||
validate(value, msg) {
|
||||
validate(value, msg, arg) {
|
||||
const attachment = msg.attachments.first();
|
||||
if (!attachment || !attachment.height || !attachment.width) return false;
|
||||
if (attachment.size > 8e+6) return 'Please provide an image under 8 MB.';
|
||||
return true;
|
||||
if (attachment) {
|
||||
if (!attachment.height || !attachment.width) return false;
|
||||
if (attachment.size > 8e+6) return 'Please provide an image under 8 MB.';
|
||||
return true;
|
||||
}
|
||||
return this.client.registry.types.get('user').validate(value, msg, arg);
|
||||
}
|
||||
|
||||
parse(value, msg) {
|
||||
return msg.attachments.first().url;
|
||||
async parse(value, msg, arg) {
|
||||
const attachment = msg.attachments.first();
|
||||
if (attachment) return attachment.url;
|
||||
const user = await this.client.registry.types.get('user').parse(value, msg, arg);
|
||||
return user.displayAvatarURL({ format: 'png', size: 512 });
|
||||
}
|
||||
|
||||
isEmpty(value, msg) {
|
||||
return msg.attachments.size === 0;
|
||||
isEmpty(value, msg, arg) {
|
||||
if (msg.attachments.size) return false;
|
||||
return this.client.registry.types.get('user').isEmpty(value, msg, arg);
|
||||
}
|
||||
};
|
||||
|
||||
+5
-3
@@ -88,9 +88,11 @@ module.exports = class CanvasUtil {
|
||||
}
|
||||
|
||||
static shortenText(ctx, text, maxWidth) {
|
||||
let shorten;
|
||||
if (ctx.measureText(text).width > maxWidth) shorten = true;
|
||||
while (ctx.measureText(text).width > maxWidth) text = text.substr(0, text.length - 1);
|
||||
let shorten = false;
|
||||
while (ctx.measureText(text).width > maxWidth) {
|
||||
if (!shorten) shorten = true;
|
||||
text = text.substr(0, text.length - 1);
|
||||
}
|
||||
return shorten ? `${text}...` : text;
|
||||
}
|
||||
};
|
||||
|
||||
+3
-3
@@ -60,7 +60,7 @@ module.exports = class Util {
|
||||
|
||||
static today(timeZone) {
|
||||
const now = new Date();
|
||||
if (timeZone) now.setUTCHours(now.getUTCHours() + timeZone);
|
||||
if (timeZone) now.setUTCHours(timeZone);
|
||||
now.setHours(0);
|
||||
now.setMinutes(0);
|
||||
now.setSeconds(0);
|
||||
@@ -74,13 +74,13 @@ module.exports = class Util {
|
||||
return today;
|
||||
}
|
||||
|
||||
static async awaitPlayers(msg, max, min, { text = 'join game', time = 30000, dmCheck = false } = {}) {
|
||||
static async awaitPlayers(msg, max, min, { time = 30000, dmCheck = false } = {}) {
|
||||
const joined = [];
|
||||
joined.push(msg.author.id);
|
||||
const filter = res => {
|
||||
if (res.author.bot) return false;
|
||||
if (joined.includes(res.author.id)) return false;
|
||||
if (res.content.toLowerCase() !== text.toLowerCase()) return false;
|
||||
if (res.content.toLowerCase() !== 'join game') return false;
|
||||
joined.push(res.author.id);
|
||||
res.react(SUCCESS_EMOJI_ID || '✅').catch(() => null);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user