mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 21:44:48 +02:00
Make help message more informative
This commit is contained in:
@@ -93,10 +93,14 @@ client.on('ready', async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up disabled commands
|
// Set up disabled commands
|
||||||
const disabled = await client.redis.hgetall('disabled');
|
try {
|
||||||
for (const command of Object.keys(disabled)) {
|
const disabled = await client.redis.hgetall('disabled');
|
||||||
client.registry.commands.get(command).disable();
|
for (const command of Object.keys(disabled)) {
|
||||||
client.logger.info(`[DISABLED] Disabled the ${command} command.`);
|
client.registry.commands.get(command).disable();
|
||||||
|
client.logger.info(`[DISABLED] Disabled the ${command} command.`);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
client.logger.error(`[DISABLED] Error while disabling commands:\n${err.stack}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import command-last-run.json
|
// Import command-last-run.json
|
||||||
@@ -163,7 +167,7 @@ client.on('ready', async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
client.logger.info(`[BLACKLIST] Left ${guildsLeft} guilds owned by blacklisted users.`);
|
if (guildsLeft > 0) client.logger.info(`[BLACKLIST] Left ${guildsLeft} guilds owned by blacklisted users.`);
|
||||||
|
|
||||||
// Set up existing timers
|
// Set up existing timers
|
||||||
try {
|
try {
|
||||||
@@ -190,8 +194,12 @@ client.on('ready', async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up parse-domain
|
// Set up parse-domain
|
||||||
await client.loadParseDomain();
|
try {
|
||||||
client.logger.info('[PARSE DOMAIN] parse-domain loaded.');
|
await client.loadParseDomain();
|
||||||
|
client.logger.info('[PARSE DOMAIN] parse-domain loaded.');
|
||||||
|
} catch (err) {
|
||||||
|
client.logger.error(`[PARSE DOMAIN] Failed to load parse-domain\n${err.stack}`);
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch adult site list
|
// Fetch adult site list
|
||||||
try {
|
try {
|
||||||
@@ -210,14 +218,22 @@ client.on('ready', async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up face detection
|
// Set up face detection
|
||||||
await client.loadFaceDetector();
|
try {
|
||||||
client.logger.info('[FACE DETECTOR] Loaded face detector.');
|
await client.loadFaceDetector();
|
||||||
|
client.logger.info('[FACE DETECTOR] Loaded face detector.');
|
||||||
|
} catch (err) {
|
||||||
|
client.logger.error(`[FACE DETECTOR] Failed to load face detector\n${err.stack}`);
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch all members
|
// Fetch all members
|
||||||
for (const [, guild] of client.guilds.cache) {
|
try {
|
||||||
await guild.members.fetch();
|
for (const guild of client.guilds.cache.values()) {
|
||||||
|
await guild.members.fetch();
|
||||||
|
}
|
||||||
|
client.logger.info('[MEMBERS] Fetched all guild members.');
|
||||||
|
} catch (err) {
|
||||||
|
client.logger.error(`[MEMBERS] Failed to fetch guild members\n${err.stack}`);
|
||||||
}
|
}
|
||||||
client.logger.info('[MEMBERS] Fetched all guild members.');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('messageCreate', async msg => {
|
client.on('messageCreate', async msg => {
|
||||||
|
|||||||
+3
-3
@@ -72,9 +72,9 @@ module.exports = class CommandClient extends Client {
|
|||||||
|
|
||||||
if (!this.dispatcher.isCommand(msg)) return;
|
if (!this.dispatcher.isCommand(msg)) return;
|
||||||
const parsed = await this.dispatcher.parseMessage(msg);
|
const parsed = await this.dispatcher.parseMessage(msg);
|
||||||
if (typeof parsed === 'string') {
|
if (parsed.error) {
|
||||||
const helpUsage = this.registry.commands.get('help').usage();
|
const helpUsage = this.registry.commands.get('help').usage(parsed.command.name);
|
||||||
await msg.reply(`${parsed}\n\nUse ${helpUsage} for more information.`);
|
await msg.reply(`${parsed.error}\n\nUse ${helpUsage} for more information.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { command, args } = parsed;
|
const { command, args } = parsed;
|
||||||
|
|||||||
+10
-10
@@ -54,10 +54,10 @@ module.exports = class CommandDispatcher {
|
|||||||
finalResult[arg.key] = typeof arg.default === 'function' ? arg.default(msg) : arg.default;
|
finalResult[arg.key] = typeof arg.default === 'function' ? arg.default(msg) : arg.default;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
return stripIndents`
|
return { command, error: stripIndents`
|
||||||
The "${arg.label || arg.key}" argument is required.
|
The "${arg.label || arg.key}" argument is required.
|
||||||
${arg.invalidText}
|
${arg.invalidText}
|
||||||
`;
|
` };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,12 +65,12 @@ module.exports = class CommandDispatcher {
|
|||||||
for (const parsedArg of infinite) {
|
for (const parsedArg of infinite) {
|
||||||
const valid = await arg.validate(parsedArg, msg, arg);
|
const valid = await arg.validate(parsedArg, msg, arg);
|
||||||
if (typeof valid === 'string') {
|
if (typeof valid === 'string') {
|
||||||
return valid;
|
return { command, error: valid };
|
||||||
} else if (!valid) {
|
} else if (!valid) {
|
||||||
return stripIndents`
|
return { command, error: 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.invalidText}
|
${arg.invalidText}
|
||||||
`;
|
` };
|
||||||
}
|
}
|
||||||
parsedArgs.push(await arg.parse(parsedArg, msg, arg));
|
parsedArgs.push(await arg.parse(parsedArg, msg, arg));
|
||||||
}
|
}
|
||||||
@@ -80,10 +80,10 @@ module.exports = class CommandDispatcher {
|
|||||||
const parsedArg = i + 1 === command.args.length ? parsed._.slice(i).join(' ') : parsed._[i]?.toString();
|
const parsedArg = i + 1 === command.args.length ? parsed._.slice(i).join(' ') : parsed._[i]?.toString();
|
||||||
if (arg.isEmpty(parsedArg, msg, arg)) {
|
if (arg.isEmpty(parsedArg, msg, arg)) {
|
||||||
if (arg.default === null) {
|
if (arg.default === null) {
|
||||||
return stripIndents`
|
return { command, error: stripIndents`
|
||||||
The "${arg.label || arg.key}" argument is required.
|
The "${arg.label || arg.key}" argument is required.
|
||||||
${arg.invalidText}
|
${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;
|
||||||
continue;
|
continue;
|
||||||
@@ -91,12 +91,12 @@ module.exports = class CommandDispatcher {
|
|||||||
}
|
}
|
||||||
const valid = await arg.validate(parsedArg, msg, arg);
|
const valid = await arg.validate(parsedArg, msg, arg);
|
||||||
if (typeof valid === 'string') {
|
if (typeof valid === 'string') {
|
||||||
return valid;
|
return { command, error: valid };
|
||||||
} else if (!valid) {
|
} else if (!valid) {
|
||||||
return stripIndents`
|
return { command, error: 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.invalidText}
|
${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