mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-21 08:45:03 +00:00
the commmand now sends the nickname of the member when a nickname isnt provided
This commit is contained in:
parent
37024ff1e4
commit
b54df47d82
3 changed files with 53 additions and 20 deletions
|
@ -1,6 +1,7 @@
|
|||
import { Util } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { canActOn, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { errorMessage } from "../../../utils";
|
||||
import { canActOn, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { utilityCmd } from "../types";
|
||||
|
||||
export const NicknameCmd = utilityCmd({
|
||||
|
@ -15,24 +16,26 @@ export const NicknameCmd = utilityCmd({
|
|||
},
|
||||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
if (!args.nickname) {
|
||||
if (!args.member.nickname) {
|
||||
msg.channel.send(`<@!${args.member.id}> does not have a nickname`);
|
||||
} else {
|
||||
msg.channel.send(`The nickname of <@!${args.member.id}> is **${Util.escapeBold(args.nickname)}**`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.member.id !== args.member.id && !canActOn(pluginData, msg.member, args.member)) {
|
||||
msg.channel.send(errorMessage("Cannot change nickname: insufficient permissions"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.nickname && !args.member.nickname) {
|
||||
msg.channel.send(errorMessage("User does not have a nickname"));
|
||||
const nicknameLength = [...args.nickname].length;
|
||||
if (nicknameLength < 2 || nicknameLength > 32) {
|
||||
msg.channel.send(errorMessage("Nickname must be between 2 and 32 characters long"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.nickname) {
|
||||
const nicknameLength = [...args.nickname].length;
|
||||
if (nicknameLength < 2 || nicknameLength > 32) {
|
||||
msg.channel.send(errorMessage("Nickname must be between 2 and 32 characters long"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const oldNickname = args.member.nickname || "<none>";
|
||||
|
||||
try {
|
||||
|
@ -42,14 +45,10 @@ export const NicknameCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
if (args.nickname) {
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`Changed nickname of <@!${args.member.id}> from **${oldNickname}** to **${args.nickname}**`,
|
||||
);
|
||||
} else {
|
||||
sendSuccessMessage(pluginData, msg.channel, `The nickname of <@!${args.member.id}> has been reset`);
|
||||
}
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`Changed nickname of <@!${args.member.id}> from **${oldNickname}** to **${args.nickname}**`,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -19,8 +19,13 @@ export const NicknameResetCmd = utilityCmd({
|
|||
return;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (!args.member.nickname) {
|
||||
msg.channel.send(errorMessage("User does not have a nickname"));
|
||||
=======
|
||||
if (!args.member.nick) {
|
||||
msg.channel.createMessage(errorMessage(`<@!${args.member.id}> does not have a nickname`));
|
||||
>>>>>>> 67f0227a (the commmand now sends the nickname of the member when a nickname isnt provided)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -786,6 +786,35 @@ export function deactivateMentions(content: string): string {
|
|||
return content.replace(/@/g, "@\u200b");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
/**
|
||||
* Disable inline code in the given string by replacing backticks/grave accents with acute accents
|
||||
* FIXME: Find a better way that keeps the grave accents? Can't use the code block approach here since it's just 1 character.
|
||||
*/
|
||||
export function disableInlineCode(content: string): string {
|
||||
return content.replace(/`/g, "\u00b4");
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable code blocks in the given string by adding invisible unicode characters between backticks
|
||||
*/
|
||||
export function disableCodeBlocks(content: string): string {
|
||||
return content.replace(/`/g, "`\u200b");
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable bold in the given string by escaping the asterisks
|
||||
*/
|
||||
export function disableBold(content: string): string {
|
||||
let i = 0;
|
||||
return content.replace(/\*\*(\*)?/g, (_, match) => {
|
||||
if (match) return ++i % 2 ? `${match}\\*\\*` : `\\*\\*${match}`;
|
||||
return "\\*\\*";
|
||||
});
|
||||
}
|
||||
|
||||
>>>>>>> 67f0227a (the commmand now sends the nickname of the member when a nickname isnt provided)
|
||||
export function useMediaUrls(content: string): string {
|
||||
return content.replace(/cdn\.discord(app)?\.com/g, "media.discordapp.net");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue