"help" command

This commit is contained in:
Isaac
2021-05-17 21:16:58 +01:00
parent 98c986e715
commit 37adac1dd0
14 changed files with 122 additions and 26 deletions

View File

@@ -1,5 +1,6 @@
const Command = require('../modules/commands/command');
const { MessageEmbed } = require('discord.js');
// eslint-disable-next-line no-unused-vars
const { MessageEmbed, Message } = require('discord.js');
module.exports = class AddCommand extends Command {
constructor(client) {
@@ -27,6 +28,11 @@ module.exports = class AddCommand extends Command {
});
}
/**
* @param {Message} message
* @param {string} args
* @returns {Promise<void|any>}
*/
async execute(message, args) {
let settings = await message.guild.settings;
const i18n = this.client.i18n.getLocale(settings.locale);

View File

@@ -1,5 +1,6 @@
const Command = require('../modules/commands/command');
const { MessageEmbed } = require('discord.js');
// eslint-disable-next-line no-unused-vars
const { MessageEmbed, Message } = require('discord.js');
module.exports = class BlacklistCommand extends Command {
constructor(client) {
@@ -24,6 +25,11 @@ module.exports = class BlacklistCommand extends Command {
});
}
/**
* @param {Message} message
* @param {string} args
* @returns {Promise<void|any>}
*/
async execute(message, args) {
let settings = await message.guild.settings;
const i18n = this.client.i18n.getLocale(settings.locale);

View File

@@ -1,5 +1,6 @@
const Command = require('../modules/commands/command');
const { MessageEmbed, MessageMentions } = require('discord.js');
// eslint-disable-next-line no-unused-vars
const { MessageEmbed, MessageMentions, Message } = require('discord.js');
const { Op } = require('sequelize');
const toTime = require('to-time-monthsfork');
const { footer } = require('../utils/discord');
@@ -48,6 +49,11 @@ module.exports = class CloseCommand extends Command {
});
}
/**
* @param {Message} message
* @param {*} args
* @returns {Promise<void|any>}
*/
async execute(message, args) {
const arg_ticket = this.args[0].name;
const arg_reason = this.args[1].name;

View File

@@ -1,5 +1,6 @@
const Command = require('../modules/commands/command');
const { MessageEmbed } = require('discord.js');
// eslint-disable-next-line no-unused-vars
const { MessageEmbed, Message } = require('discord.js');
module.exports = class HelpCommand extends Command {
constructor(client) {
@@ -24,8 +25,41 @@ module.exports = class HelpCommand extends Command {
});
}
/**
* @param {Message} message
* @param {string} args
* @returns {Promise<void|any>}
*/
async execute(message, args) {
let settings = await message.guild.settings;
const i18n = this.client.i18n.getLocale(settings.locale);
const cmd = this.manager.commands.find(command => command.aliases.includes(args.toLowerCase()));
if (cmd) {
return await cmd.sendUsage(message.channel, args);
} else {
let commands = this.manager.commands.filter(async command => {
if (command.permissions.length >= 1) return !message.member.hasPermission(command.permissions);
else if (command.staff_only) return await message.member.isStaff();
});
let list = commands.map(command => {
// let description = command.description;
let description = command.description.length > 50
? command.description.substring(0, 50) + '...'
: command.description;
return `**\`${settings.command_prefix}${command.name}\` ·** ${description}`;
});
return await message.channel.send(
new MessageEmbed()
.setColor(settings.colour)
.setTitle(i18n('commands.help.response.list.title'))
.setDescription(i18n('commands.help.response.list.description', {
prefix: settings.command_prefix,
}))
.addField(i18n('commands.help.response.list.fields.commands'), list.join('\n'))
.setFooter(settings.footer, message.guild.iconURL())
);
}
}
};

View File

@@ -1,5 +1,6 @@
const Command = require('../modules/commands/command');
const { MessageEmbed } = require('discord.js');
// eslint-disable-next-line no-unused-vars
const { MessageEmbed, Message } = require('discord.js');
const { footer } = require('../utils/discord');
const { letters } = require('../utils/emoji');
const { wait } = require('../utils');
@@ -28,6 +29,11 @@ module.exports = class NewCommand extends Command {
});
}
/**
* @param {Message} message
* @param {string} args
* @returns {Promise<void|any>}
*/
async execute(message, args) {
let settings = await message.guild.settings;
const i18n = this.client.i18n.getLocale(settings.locale);

View File

@@ -1,5 +1,6 @@
const Command = require('../modules/commands/command');
const { MessageEmbed } = require('discord.js');
// eslint-disable-next-line no-unused-vars
const { MessageEmbed, Message } = require('discord.js');
const { some, wait } = require('../utils');
const { emojify } = require('node-emoji');
@@ -56,6 +57,11 @@ module.exports = class PanelCommand extends Command {
});
}
/**
* @param {Message} message
* @param {*} args
* @returns {Promise<void|any>}
*/
async execute(message, args) {
// localised command and arg names are a pain
const arg_title = this.args[0].name;

View File

@@ -1,5 +1,6 @@
const Command = require('../modules/commands/command');
const { MessageEmbed } = require('discord.js');
// eslint-disable-next-line no-unused-vars
const { MessageEmbed, Message } = require('discord.js');
module.exports = class RemoveCommand extends Command {
constructor(client) {
@@ -27,6 +28,11 @@ module.exports = class RemoveCommand extends Command {
});
}
/**
* @param {Message} message
* @param {string} args
* @returns {Promise<void|any>}
*/
async execute(message, args) {
let settings = await message.guild.settings;
const i18n = this.client.i18n.getLocale(settings.locale);

View File

@@ -26,7 +26,7 @@ module.exports = class SettingsCommand extends Command {
/**
* @param {Message} message
* @param {*} args
* @param {string} args
* @returns {Promise<void|any>}
*/
async execute(message) {

View File

@@ -1,6 +1,7 @@
const Command = require('../modules/commands/command');
const Keyv = require('keyv');
const { MessageEmbed } = require('discord.js');
// eslint-disable-next-line no-unused-vars
const { MessageEmbed, Message } = require('discord.js');
module.exports = class StatsCommand extends Command {
constructor(client) {
@@ -20,6 +21,11 @@ module.exports = class StatsCommand extends Command {
});
}
/**
* @param {Message} message
* @param {string} args
* @returns {Promise<void|any>}
*/
async execute(message) {
let settings = await message.guild.settings;
const i18n = this.client.i18n.getLocale(settings.locale);
@@ -34,7 +40,6 @@ module.exports = class StatsCommand extends Command {
guild: message.guild.id
}
});
stats = { // maths
tickets: tickets.count,
messages: settings.log_messages

View File

@@ -1,5 +1,6 @@
const Command = require('../modules/commands/command');
const { MessageEmbed } = require('discord.js');
// eslint-disable-next-line no-unused-vars
const { MessageEmbed, Message } = require('discord.js');
module.exports = class TopicCommand extends Command {
constructor(client) {
@@ -21,6 +22,11 @@ module.exports = class TopicCommand extends Command {
});
}
/**
* @param {Message} message
* @param {string} args
* @returns {Promise<void|any>}
*/
async execute(message, args) {
let settings = await message.guild.settings;
const i18n = this.client.i18n.getLocale(settings.locale);