3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Use blueprint directly for commands for clarity

This commit is contained in:
Dragory 2020-07-05 15:03:51 +03:00
parent 05693455ec
commit 9963a4d5a4
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
4 changed files with 34 additions and 40 deletions

View file

@ -4,20 +4,18 @@ import { helpers } from "knub";
const { getMemberLevel } = helpers;
export const LevelCmd = utilityCmd(
"level",
{
export const LevelCmd = utilityCmd({
trigger: "level",
description: "Show the permission level of a user",
usage: "!level 106391128718245888",
signature: {
member: ct.resolvedMember({ required: false }),
},
{
description: "Show the permission level of a user",
usage: "!level 106391128718245888",
},
({ message, args, pluginData }) => {
run({ message, args, pluginData }) {
const member = args.member || message.member;
const level = getMemberLevel(pluginData, member);
message.channel.createMessage(`The permission level of ${member.username}#${member.discriminator} is **${level}**`);
}
);
});

View file

@ -5,22 +5,20 @@ import { chunkArray, sorter, trimLines } from "../../../utils";
import { refreshMembersIfNeeded } from "../refreshMembers";
import { sendErrorMessage } from "../../../pluginUtils";
export const RolesCmd = utilityCmd(
"roles",
{
export const RolesCmd = utilityCmd({
trigger: "roles",
description: "List all roles or roles matching a search",
usage: "!roles mod",
permission: "can_roles",
signature: {
search: t.string({ catchAll: true }),
counts: t.switchOption(),
sort: t.string({ option: true }),
},
{
description: "List all roles or roles matching a search",
usage: "!roles mod",
permission: "can_roles",
},
async ({ message: msg, args, pluginData }) => {
async run({ message: msg, args, pluginData }) {
const { guild } = pluginData;
let roles: Array<{ _memberCount?: number } & Role> = Array.from((msg.channel as TextChannel).guild.roles.values());
@ -109,5 +107,5 @@ export const RolesCmd = utilityCmd(
msg.channel.createMessage("```py\n" + roleLines.join("\n") + "```");
}
}
}
);
},
});

View file

@ -1,12 +1,14 @@
import { utilityCmd } from "../types";
import { baseTypeHelpers as t } from "knub";
export const SearchCmd = utilityCmd(
["search", "s"],
{
export const SearchCmd = utilityCmd({
trigger: ["search", "s"],
signature: {
query: t.string({ catchAll: true }),
},
run() {
},
{},
() => {}
);
});

View file

@ -4,17 +4,13 @@ import { embedPadding, formatNumber, memoize, MINUTES, trimLines } from "../../.
import { utilityCmd } from "../types";
import humanizeDuration from "humanize-duration";
export const ServerCmd = utilityCmd(
"server",
{},
export const ServerCmd = utilityCmd({
trigger: "server",
description: "Show information about the server",
usage: "!server",
permission: "can_server",
{
permission: "can_server",
description: "Show information about the server",
usage: "!server",
},
async ({ message }) => {
async run({ message }) {
const embed: EmbedOptions = {
fields: [],
color: parseInt("6b80cf", 16),
@ -122,5 +118,5 @@ export const ServerCmd = utilityCmd(
});
message.channel.createMessage({ embed });
}
);
},
});