mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Migrate SelfGrantableRoles to new Plugin structure
This commit is contained in:
parent
140ba84544
commit
763bdd0b19
10 changed files with 418 additions and 0 deletions
|
@ -0,0 +1,52 @@
|
|||
import { selfGrantableRolesCmd } from "../types";
|
||||
import { asSingleLine, trimLines } from "src/utils";
|
||||
import { getApplyingEntries } from "../util/getApplyingEntries";
|
||||
|
||||
export const RoleHelpCmd = selfGrantableRolesCmd({
|
||||
trigger: ["role help", "role"],
|
||||
permission: null,
|
||||
|
||||
async run({ message: msg, pluginData }) {
|
||||
const applyingEntries = getApplyingEntries(pluginData, msg);
|
||||
if (applyingEntries.length === 0) return;
|
||||
|
||||
const allPrimaryAliases = [];
|
||||
for (const entry of applyingEntries) {
|
||||
for (const aliases of Object.values(entry.roles)) {
|
||||
if (aliases[0]) {
|
||||
allPrimaryAliases.push(aliases[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const prefix = pluginData.guildConfig.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.createMessage({ embed: helpEmbed });
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue