mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-22 17:25:01 +00:00
Combine Knub's type helpers with Zeppelin's, continue Utility plugin port
This commit is contained in:
parent
383601e9f4
commit
16ab3c36c4
13 changed files with 533 additions and 13 deletions
33
backend/src/plugins/Utility/commands/NicknameResetCmd.ts
Normal file
33
backend/src/plugins/Utility/commands/NicknameResetCmd.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { utilityCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { errorMessage } from "../../../utils";
|
||||
import { canActOn, sendSuccessMessage } from "../../../pluginUtils";
|
||||
|
||||
export const NicknameResetCmd = utilityCmd({
|
||||
trigger: "nickname reset",
|
||||
description: "Reset a member's nickname to their username",
|
||||
usage: "!nickname reset 106391128718245888",
|
||||
permission: "can_nickname",
|
||||
|
||||
signature: {
|
||||
member: ct.resolvedMember(),
|
||||
},
|
||||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
if (msg.member.id !== args.member.id && canActOn(pluginData, msg.member, args.member)) {
|
||||
msg.channel.createMessage(errorMessage("Cannot reset nickname: insufficient permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await args.member.edit({
|
||||
nick: "",
|
||||
});
|
||||
} catch (e) {
|
||||
msg.channel.createMessage(errorMessage("Failed to reset nickname"));
|
||||
return;
|
||||
}
|
||||
|
||||
sendSuccessMessage(pluginData, msg.channel, `The nickname of <@!${args.member.id}> has been reset`);
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue