mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 14:18:36 +02:00
Add argument invalidtext
This commit is contained in:
@@ -1,272 +0,0 @@
|
|||||||
{
|
|
||||||
"fun": {
|
|
||||||
"LogoID": "3847909731",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Color1_color": "#F2D324",
|
|
||||||
"Color2_color": "#F02B2B",
|
|
||||||
"Color3_color": "#000000",
|
|
||||||
"Integer1": "3",
|
|
||||||
"Integer5": "2",
|
|
||||||
"Integer7": "8",
|
|
||||||
"Integer8": "8",
|
|
||||||
"Integer14_color": "#000000",
|
|
||||||
"Integer6": "75",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"burning": {
|
|
||||||
"LogoID": "4",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Color1_color": "#FF0000",
|
|
||||||
"Integer1": "15",
|
|
||||||
"Boolean1": "on",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"white": {
|
|
||||||
"LogoID": "732438332",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Color1_color": "#000000",
|
|
||||||
"Color2_color": "#FFFFFF",
|
|
||||||
"Color3_color": "#FFFFFF",
|
|
||||||
"Integer5": "0",
|
|
||||||
"Integer7": "0",
|
|
||||||
"Integer8": "0",
|
|
||||||
"Integer14_color": "#000000",
|
|
||||||
"Integer6": "75",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"fantasy": {
|
|
||||||
"LogoID": "45",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Color1_color": "#D5CE5F",
|
|
||||||
"Color2_color": "#D5CE5F",
|
|
||||||
"Integer1": "135",
|
|
||||||
"Integer2": "45",
|
|
||||||
"Integer3": "3",
|
|
||||||
"Integer5": "2",
|
|
||||||
"Integer7": "3",
|
|
||||||
"Integer8": "3",
|
|
||||||
"Integer14_color": "#000000",
|
|
||||||
"Integer6": "50",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"dragon": {
|
|
||||||
"LogoID": "1408867449",
|
|
||||||
"FontSize": "120",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"ice": {
|
|
||||||
"LogoID": "1779834160",
|
|
||||||
"FontSize": "120",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"gunmetal": {
|
|
||||||
"LogoID": "852819205",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Color1_color": "#FAFAFA",
|
|
||||||
"Boolean2": "on",
|
|
||||||
"Integer5": "4",
|
|
||||||
"Integer7": "0",
|
|
||||||
"Integer8": "0",
|
|
||||||
"Integer14_color": "#000000",
|
|
||||||
"Integer6": "70",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"wizards": {
|
|
||||||
"LogoID": "38",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Boolean2": "on",
|
|
||||||
"Integer5": "0",
|
|
||||||
"Integer7": "0",
|
|
||||||
"Integer8": "0",
|
|
||||||
"Integer14_color": "#000000",
|
|
||||||
"Integer6": "75",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"FileFormat": "5",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"sword": {
|
|
||||||
"LogoID": "2172004512",
|
|
||||||
"FontSize": "120",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"vampire": {
|
|
||||||
"LogoID": "732414977",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Boolean1": "on",
|
|
||||||
"Color1_color": "#FC14F4",
|
|
||||||
"Color2_color": "#60D4CE",
|
|
||||||
"Integer1": "135",
|
|
||||||
"Integer2": "45",
|
|
||||||
"Integer3": "3",
|
|
||||||
"Integer5": "2",
|
|
||||||
"Integer7": "3",
|
|
||||||
"Integer8": "3",
|
|
||||||
"Integer14_color": "#000000",
|
|
||||||
"Integer6": "50",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"dark": {
|
|
||||||
"LogoID": "830474754",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Boolean1": "on",
|
|
||||||
"Boolean2": "on",
|
|
||||||
"Integer1": "5",
|
|
||||||
"Boolean3": "on",
|
|
||||||
"Integer5": "4",
|
|
||||||
"Integer7": "2",
|
|
||||||
"Integer8": "2",
|
|
||||||
"Integer14_color": "#FFF2FF",
|
|
||||||
"Integer6": "30",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"comic": {
|
|
||||||
"LogoID": "9",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Integer1": "5",
|
|
||||||
"Integer5": "2",
|
|
||||||
"Integer7": "0",
|
|
||||||
"Integer8": "0",
|
|
||||||
"Integer14_color": "#000000",
|
|
||||||
"Integer6": "75",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#000000"
|
|
||||||
},
|
|
||||||
"spring": {
|
|
||||||
"LogoID": "759902224",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Color1_color": "#66FFCC",
|
|
||||||
"Color2_color": "#B94FFF",
|
|
||||||
"Integer1": "6",
|
|
||||||
"Integer2": "1",
|
|
||||||
"Integer5": "0",
|
|
||||||
"Integer7": "3",
|
|
||||||
"Integer8": "3",
|
|
||||||
"Integer14_color": "#000000",
|
|
||||||
"Integer6": "75",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"slab": {
|
|
||||||
"LogoID": "17",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Color1_color": "#EFE66E",
|
|
||||||
"Integer1": "100",
|
|
||||||
"Boolean1": "on",
|
|
||||||
"Integer5": "2",
|
|
||||||
"Integer7": "0",
|
|
||||||
"Integer8": "0",
|
|
||||||
"Integer14_color": "#000000",
|
|
||||||
"Integer6": "75",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"flaming": {
|
|
||||||
"LogoID": "1169711118",
|
|
||||||
"FontSize": "90",
|
|
||||||
"Color1_color": "#4D0000",
|
|
||||||
"Integer1": "90",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"lava": {
|
|
||||||
"LogoID": "852774362",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Boolean1": "on",
|
|
||||||
"Integer1": "3",
|
|
||||||
"Boolean3": "on",
|
|
||||||
"Integer5": "2",
|
|
||||||
"Integer7": "2",
|
|
||||||
"Integer8": "2",
|
|
||||||
"Integer14_color": "#000000",
|
|
||||||
"Integer6": "60",
|
|
||||||
"Integer9": "6",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#000000"
|
|
||||||
},
|
|
||||||
"tough": {
|
|
||||||
"LogoID": "758282876",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Color1_color": "#0A213D",
|
|
||||||
"Integer1": "5",
|
|
||||||
"Integer5": "0",
|
|
||||||
"Integer7": "0",
|
|
||||||
"Integer8": "0",
|
|
||||||
"Integer14_color": "#000000",
|
|
||||||
"Integer6": "75",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"gold": {
|
|
||||||
"LogoID": "46",
|
|
||||||
"FontSize": "70",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
},
|
|
||||||
"sushi": {
|
|
||||||
"LogoID": "830446526",
|
|
||||||
"FontSize": "70",
|
|
||||||
"Color1_color": "#CC0808",
|
|
||||||
"Color2_color": "#E3D110",
|
|
||||||
"Integer1": "135",
|
|
||||||
"Integer2": "45",
|
|
||||||
"Integer3": "2",
|
|
||||||
"Integer5": "2",
|
|
||||||
"Integer7": "2",
|
|
||||||
"Integer8": "2",
|
|
||||||
"Integer14_color": "#000000",
|
|
||||||
"Integer6": "40",
|
|
||||||
"Integer9": "0",
|
|
||||||
"Integer13": "on",
|
|
||||||
"Integer12": "on",
|
|
||||||
"FileFormat": "6",
|
|
||||||
"BackgroundColor_color": "#FFFFFF"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
{
|
|
||||||
"ADMINISTRATOR": "Administrator",
|
|
||||||
"CREATE_INSTANT_INVITE": "Create Invite",
|
|
||||||
"KICK_MEMBERS": "Kick Members",
|
|
||||||
"BAN_MEMBERS": "Ban Members",
|
|
||||||
"MANAGE_CHANNELS": "Manage Channels",
|
|
||||||
"MANAGE_GUILD": "Manage Server",
|
|
||||||
"ADD_REACTIONS": "Add Reactions",
|
|
||||||
"VIEW_AUDIT_LOG": "View Audit Log",
|
|
||||||
"PRIORITY_SPEAKER": "Priority Speaker",
|
|
||||||
"STREAM": "Video",
|
|
||||||
"VIEW_CHANNEL": "View Channels",
|
|
||||||
"SEND_MESSAGES": "Send Messages",
|
|
||||||
"SEND_TTS_MESSAGES": "Send Text-to-Speech Messages",
|
|
||||||
"MANAGE_MESSAGES": "Manage Messages",
|
|
||||||
"EMBED_LINKS": "Embed Links",
|
|
||||||
"ATTACH_FILES": "Attach Files",
|
|
||||||
"READ_MESSAGE_HISTORY": "Read Message History",
|
|
||||||
"MENTION_EVERYONE": "Mention everyone, here, and All Roles",
|
|
||||||
"USE_EXTERNAL_EMOJIS": "Use External Emoji",
|
|
||||||
"VIEW_GUILD_INSIGHTS": "View Server Insights",
|
|
||||||
"CONNECT": "Connect",
|
|
||||||
"SPEAK": "Speak",
|
|
||||||
"MUTE_MEMBERS": "Mute Members",
|
|
||||||
"DEAFEN_MEMBERS": "Deafen Members",
|
|
||||||
"MOVE_MEMBERS": "Move Members",
|
|
||||||
"USE_VAD": "Use Voice Activity",
|
|
||||||
"CHANGE_NICKNAME": "Change Nickname",
|
|
||||||
"MANAGE_NICKNAMES": "Manage Nicknames",
|
|
||||||
"MANAGE_ROLES": "Manage Roles",
|
|
||||||
"MANAGE_WEBHOOKS": "Manage Webhooks",
|
|
||||||
"MANAGE_EMOJIS": "Manage Emojis",
|
|
||||||
"USE_APPLICATION_COMMANDS": "Use Slash Commands",
|
|
||||||
"REQUEST_TO_SPEAK": "Request to Speak"
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
[
|
|
||||||
"CREATE_INSTANT_INVITE",
|
|
||||||
"ADD_REACTIONS",
|
|
||||||
"VIEW_AUDIT_LOG",
|
|
||||||
"VIEW_CHANNEL",
|
|
||||||
"SEND_MESSAGES",
|
|
||||||
"MANAGE_EMOJIS",
|
|
||||||
"MANAGE_MESSAGES",
|
|
||||||
"EMBED_LINKS",
|
|
||||||
"ATTACH_FILES",
|
|
||||||
"READ_MESSAGE_HISTORY",
|
|
||||||
"USE_EXTERNAL_EMOJIS",
|
|
||||||
"CONNECT",
|
|
||||||
"SPEAK",
|
|
||||||
"USE_VAD",
|
|
||||||
"CHANGE_NICKNAME",
|
|
||||||
"MENTION_EVERYONE"
|
|
||||||
]
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
const Command = require('../../framework/Command');
|
|
||||||
|
|
||||||
module.exports = class LMGTFYCommand extends Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: 'lmgtfy',
|
|
||||||
aliases: ['let-me-google-that-for-you'],
|
|
||||||
group: 'edit-text',
|
|
||||||
memberName: 'lmgtfy',
|
|
||||||
description: 'Creates a LMGTFY link with the query you provide.',
|
|
||||||
credit: [
|
|
||||||
{
|
|
||||||
name: 'LMGTFY',
|
|
||||||
url: 'https://lmgtfy.com/',
|
|
||||||
reason: 'API'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
key: 'query',
|
|
||||||
prompt: 'What would you like the link to search for?',
|
|
||||||
type: 'string',
|
|
||||||
validate: query => {
|
|
||||||
if (encodeURIComponent(query).length < 1950) return true;
|
|
||||||
return 'Invalid query, your query is too long.';
|
|
||||||
},
|
|
||||||
parse: query => encodeURIComponent(query)
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
run(msg, { query }) {
|
|
||||||
return msg.say(`http://lmgtfy.com/?iie=1&q=${query}`);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
const UnionType = require('./UnionType');
|
const UnionType = require('./UnionType');
|
||||||
|
const { list } = require('../util/Util');
|
||||||
|
|
||||||
module.exports = class Argument {
|
module.exports = class Argument {
|
||||||
constructor(client, options) {
|
constructor(client, options) {
|
||||||
@@ -37,4 +38,23 @@ module.exports = class Argument {
|
|||||||
if (this.emptyChecker) return this.emptyChecker(val, msg, arg);
|
if (this.emptyChecker) return this.emptyChecker(val, msg, arg);
|
||||||
return this.type.isEmpty(val, msg, arg);
|
return this.type.isEmpty(val, msg, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get invalidText() {
|
||||||
|
if (this.oneOf) {
|
||||||
|
return `It must be one of the following: ${list(arg.oneOf, 'or')}`;
|
||||||
|
} else if (this.max !== null && this.min !== null && (this.typeID === 'integer' || this.typeID === 'float')) {
|
||||||
|
return `It must be a number from ${this.min} to ${this.max}.`;
|
||||||
|
} else if (this.max !== null && this.min === null && (this.typeID === 'integer' || this.typeID === 'float')) {
|
||||||
|
return `It must be a number less than or equal to ${this.max}.`;
|
||||||
|
} else if (this.min !== null && this.max === null && (this.typeID === 'integer' || this.typeID === 'float')) {
|
||||||
|
return `It must be a number greater than or equal to ${this.min}.`
|
||||||
|
} else if (this.min !== null && this.max !== null && this.typeID === 'string') {
|
||||||
|
return `It must be at least ${this.min} characters long and at most ${this.max} characters long.`;
|
||||||
|
} else if (this.min !== null && this.max === null && this.typeID === 'string') {
|
||||||
|
return `It must be at least ${this.min} characters long.`;
|
||||||
|
} else if (this.max !== null && this.min === null && this.typeID === 'string') {
|
||||||
|
return `It must be at most ${this.max} characters long.`;
|
||||||
|
}
|
||||||
|
return `It must be a ${this.typeID}.`;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
const minimist = require('minimist');
|
const minimist = require('minimist');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { list } = require('../util/Util');
|
|
||||||
const argRegex = /"([^"]*)"|(\S+)/g;
|
const argRegex = /"([^"]*)"|(\S+)/g;
|
||||||
|
|
||||||
module.exports = class CommandDispatcher {
|
module.exports = class CommandDispatcher {
|
||||||
@@ -50,7 +49,7 @@ module.exports = class CommandDispatcher {
|
|||||||
} else {
|
} else {
|
||||||
return stripIndents`
|
return stripIndents`
|
||||||
The "${arg.label || arg.key}" argument is required.
|
The "${arg.label || arg.key}" argument is required.
|
||||||
${arg.oneOf ? `It must be one of the following: ${list(arg.oneOf, 'or')}` : ''}
|
${arg.invalidText}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,7 +60,7 @@ module.exports = class CommandDispatcher {
|
|||||||
if (!valid || typeof valid === 'string') {
|
if (!valid || typeof valid === 'string') {
|
||||||
return stripIndents`
|
return stripIndents`
|
||||||
An invalid value was provided for one of the "${arg.label || arg.key}" arguments.
|
An invalid value was provided for one of the "${arg.label || arg.key}" arguments.
|
||||||
${arg.oneOf ? `It must be one of the following: ${list(arg.oneOf, 'or')}` : ''}
|
${arg.invalidText}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
parsedArgs.push(await arg.parse(parsedArg, msg, arg));
|
parsedArgs.push(await arg.parse(parsedArg, msg, arg));
|
||||||
@@ -74,7 +73,7 @@ module.exports = class CommandDispatcher {
|
|||||||
if (arg.default === null) {
|
if (arg.default === null) {
|
||||||
return stripIndents`
|
return stripIndents`
|
||||||
The "${arg.label || arg.key}" argument is required.
|
The "${arg.label || arg.key}" argument is required.
|
||||||
${arg.oneOf ? `It must be one of the following: ${list(arg.oneOf, 'or')}` : ''}
|
${arg.invalidText}
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
finalResult[arg.key] = typeof arg.default === 'function' ? arg.default(msg) : arg.default;
|
finalResult[arg.key] = typeof arg.default === 'function' ? arg.default(msg) : arg.default;
|
||||||
@@ -85,7 +84,7 @@ module.exports = class CommandDispatcher {
|
|||||||
if (!valid || typeof valid === 'string') {
|
if (!valid || typeof valid === 'string') {
|
||||||
return stripIndents`
|
return stripIndents`
|
||||||
An invalid value was provided for the "${arg.label || arg.key}" argument.
|
An invalid value was provided for the "${arg.label || arg.key}" argument.
|
||||||
${arg.oneOf ? `It must be one of the following: ${list(arg.oneOf, 'or')}` : ''}
|
${arg.invalidText}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
finalResult[arg.key] = await arg.parse(parsedArg, msg, arg);
|
finalResult[arg.key] = await arg.parse(parsedArg, msg, arg);
|
||||||
|
|||||||
Reference in New Issue
Block a user