moderation.tidy: fix breaking in DMs, allow help to always be shown

This commit is contained in:
Cynthia Foxwell 2023-12-12 11:36:12 -07:00
parent 84529b86af
commit a3e092c78d
1 changed files with 13 additions and 2 deletions

View File

@ -10,10 +10,20 @@ tidy.category = CATEGORY;
tidy.helpText = "Clean up messages";
tidy.usage = "[subcommand] <count> <extra>";
tidy.callback = async function (msg, line, [subcommand, count, extra]) {
if (!msg.channel.permissionsOf(msg.author.id).has("manageMessages")) {
const showHelp = !subcommand || subcommand === "" || subcommand === "help";
if (!showHelp && !msg.guildID) {
return "Can only be used in guilds.";
}
if (
!showHelp &&
!msg.channel.permissionsOf(msg.author.id).has("manageMessages")
) {
return "You do not have `Manage Messages` permission.";
}
if (!msg.channel.permissionsOf(hf.bot.user.id).has("manageMessages")) {
if (
!showHelp &&
!msg.channel.permissionsOf(hf.bot.user.id).has("manageMessages")
) {
return "I do not have `Manage Messages` permission.";
}
@ -88,6 +98,7 @@ tidy.callback = async function (msg, line, [subcommand, count, extra]) {
return `Deleted ${messages.length} message(s).`;
}
case "help":
default:
return `__Usage__
\`all <count = 10>\` - Last \`count\` messages.