3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00
zeppelin/backend/src/plugins/SelfGrantableRoles/commands/RoleHelpCmd.ts
2021-06-30 04:56:56 +02:00

52 lines
1.6 KiB
TypeScript

import { asSingleLine, trimLines } from "../../../utils";
import { selfGrantableRolesCmd } from "../types";
import { getApplyingEntries } from "../util/getApplyingEntries";
export const RoleHelpCmd = selfGrantableRolesCmd({
trigger: ["role help", "role"],
permission: null,
async run({ message: msg, pluginData }) {
const applyingEntries = await getApplyingEntries(pluginData, msg);
if (applyingEntries.length === 0) return;
const allPrimaryAliases: string[] = [];
for (const entry of applyingEntries) {
for (const aliases of Object.values(entry.roles)) {
if (aliases[0]) {
allPrimaryAliases.push(aliases[0]);
}
}
}
const prefix = pluginData.fullConfig.prefix;
const [firstRole, secondRole] = allPrimaryAliases;
const help1 = asSingleLine(`
To give yourself a role, type e.g. \`${prefix}role ${firstRole}\` where **${firstRole}** is the role you want.
${secondRole ? `You can also add multiple roles at once, e.g. \`${prefix}role ${firstRole} ${secondRole}\`` : ""}
`);
const help2 = asSingleLine(`
To remove a role, type \`${prefix}role remove ${firstRole}\`,
again replacing **${firstRole}** with the role you want to remove.
`);
const helpMessage = trimLines(`
${help1}
${help2}
**Roles available to you:**
${allPrimaryAliases.join(", ")}
`);
const helpEmbed = {
title: "How to get roles",
description: helpMessage,
color: parseInt("42bff4", 16),
};
msg.channel.send({ embeds: [helpEmbed] });
},
});