mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-21 16:55: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 { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import { canActOn, sendSuccessMessage } from "../../../pluginUtils";
|
|
||||||
import { errorMessage } from "../../../utils";
|
import { errorMessage } from "../../../utils";
|
||||||
|
import { canActOn, sendSuccessMessage } from "../../../pluginUtils";
|
||||||
import { utilityCmd } from "../types";
|
import { utilityCmd } from "../types";
|
||||||
|
|
||||||
export const NicknameCmd = utilityCmd({
|
export const NicknameCmd = utilityCmd({
|
||||||
|
@ -15,24 +16,26 @@ export const NicknameCmd = utilityCmd({
|
||||||
},
|
},
|
||||||
|
|
||||||
async run({ message: msg, args, pluginData }) {
|
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)) {
|
if (msg.member.id !== args.member.id && !canActOn(pluginData, msg.member, args.member)) {
|
||||||
msg.channel.send(errorMessage("Cannot change nickname: insufficient permissions"));
|
msg.channel.send(errorMessage("Cannot change nickname: insufficient permissions"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.nickname && !args.member.nickname) {
|
const nicknameLength = [...args.nickname].length;
|
||||||
msg.channel.send(errorMessage("User does not have a nickname"));
|
if (nicknameLength < 2 || nicknameLength > 32) {
|
||||||
|
msg.channel.send(errorMessage("Nickname must be between 2 and 32 characters long"));
|
||||||
return;
|
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>";
|
const oldNickname = args.member.nickname || "<none>";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -42,14 +45,10 @@ export const NicknameCmd = utilityCmd({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.nickname) {
|
sendSuccessMessage(
|
||||||
sendSuccessMessage(
|
pluginData,
|
||||||
pluginData,
|
msg.channel,
|
||||||
msg.channel,
|
`Changed nickname of <@!${args.member.id}> from **${oldNickname}** to **${args.nickname}**`,
|
||||||
`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`);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,8 +19,13 @@ export const NicknameResetCmd = utilityCmd({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
if (!args.member.nickname) {
|
if (!args.member.nickname) {
|
||||||
msg.channel.send(errorMessage("User does not have a 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -786,6 +786,35 @@ export function deactivateMentions(content: string): string {
|
||||||
return content.replace(/@/g, "@\u200b");
|
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 {
|
export function useMediaUrls(content: string): string {
|
||||||
return content.replace(/cdn\.discord(app)?\.com/g, "media.discordapp.net");
|
return content.replace(/cdn\.discord(app)?\.com/g, "media.discordapp.net");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue