Bug fixes and ~~performance~~ typing improvements
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index c3d6b33..cba14f4 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -9,22 +9,12 @@
builder
.setName("nick")
.setDescription("Changes a users nickname")
- .addUserOption((option) =>
- option
- .setName("user")
- .setDescription("The user to change")
- .setRequired(true)
- )
+ .addUserOption((option) => option.setName("user").setDescription("The user to change").setRequired(true))
.addStringOption((option) =>
- option
- .setName("name")
- .setDescription("The name to set | Leave blank to clear")
- .setRequired(false)
+ option.setName("name").setDescription("The name to set | Leave blank to clear").setRequired(false)
);
-const callback = async (
- interaction: CommandInteraction
-): Promise<void | unknown> => {
+const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
const { renderUser } = client.logger;
// TODO:[Modals] Replace this with a modal
let notify = true;
@@ -37,19 +27,12 @@
keyValueList({
user: renderUser(interaction.options.getUser("user")),
"new nickname": `${
- interaction.options.getString("name")
- ? interaction.options.getString("name")
- : "*No nickname*"
+ interaction.options.getString("name") ? interaction.options.getString("name") : "*No nickname*"
}`
}) +
`The user **will${notify ? "" : " not"}** be notified\n\n` +
- `Are you sure you want to ${
- interaction.options.getString("name")
- ? "change"
- : "clear"
- } <@!${
- (interaction.options.getMember("user") as GuildMember)
- .id
+ `Are you sure you want to ${interaction.options.getString("name") ? "change" : "clear"} <@!${
+ (interaction.options.getMember("user") as GuildMember).id
}>'s nickname?`
)
.setColor("Danger")
@@ -74,23 +57,17 @@
let dm;
try {
if (notify) {
- dm = await (
- interaction.options.getMember("user") as GuildMember
- ).send({
+ dm = await (interaction.options.getMember("user") as GuildMember).send({
embeds: [
new EmojiEmbed()
.setEmoji("PUNISH.NICKNAME.RED")
.setTitle("Nickname changed")
.setDescription(
`Your nickname was ${
- interaction.options.getString("name")
- ? "changed"
- : "cleared"
+ interaction.options.getString("name") ? "changed" : "cleared"
} in ${interaction.guild.name}.` +
(interaction.options.getString("name")
- ? ` it is now: ${interaction.options.getString(
- "name"
- )}`
+ ? ` it is now: ${interaction.options.getString("name")}`
: "") +
"\n\n" +
(confirmation.components.appeal.response
@@ -119,8 +96,7 @@
before,
nickname
);
- const { log, NucleusColors, entry, renderUser, renderDelta } =
- client.logger;
+ const { log, NucleusColors, entry, renderUser, renderDelta } = client.logger;
const data = {
meta: {
type: "memberUpdate",
@@ -134,14 +110,8 @@
memberId: entry(member.id, `\`${member.id}\``),
before: entry(before, before ? before : "*None*"),
after: entry(nickname, nickname ? nickname : "*None*"),
- updated: entry(
- new Date().getTime(),
- renderDelta(new Date().getTime())
- ),
- updatedBy: entry(
- interaction.user.id,
- renderUser(interaction.user)
- )
+ updated: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ updatedBy: entry(interaction.user.id, renderUser(interaction.user))
},
hidden: {
guild: interaction.guild.id
@@ -154,9 +124,7 @@
new EmojiEmbed()
.setEmoji("PUNISH.NICKNAME.RED")
.setTitle("Nickname")
- .setDescription(
- "Something went wrong and the users nickname could not be changed."
- )
+ .setDescription("Something went wrong and the users nickname could not be changed.")
.setStatus("Danger")
],
components: []
@@ -199,30 +167,24 @@
const member = interaction.member as GuildMember;
const me = interaction.guild.me!;
const apply = interaction.options.getMember("user") as GuildMember;
- if (member === null || me === null || apply === null)
- throw "That member is not in the server";
+ if (member === null || me === null || apply === null) throw "That member is not in the server";
const memberPos = member.roles ? member.roles.highest.position : 0;
const mePos = me.roles ? me.roles.highest.position : 0;
const applyPos = apply.roles ? apply.roles.highest.position : 0;
// Do not allow any changing of the owner
- if (member.id === interaction.guild.ownerId)
- throw "You cannot change the owner's nickname";
+ if (member.id === interaction.guild.ownerId) throw "You cannot change the owner's nickname";
// Check if Nucleus can change the nickname
- if (!(mePos > applyPos))
- throw "I do not have a role higher than that member";
+ if (!(mePos > applyPos)) throw "I do not have a role higher than that member";
// Check if Nucleus has permission to change the nickname
- if (!me.permissions.has("MANAGE_NICKNAMES"))
- throw "I do not have the *Manage Nicknames* permission";
+ if (!me.permissions.has("MANAGE_NICKNAMES")) throw "I do not have the *Manage Nicknames* permission";
// Allow the owner to change anyone's nickname
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has manage_nicknames permission
- if (!member.permissions.has("MANAGE_NICKNAMES"))
- throw "You do not have the *Manage Nicknames* permission";
+ if (!member.permissions.has("MANAGE_NICKNAMES")) throw "You do not have the *Manage Nicknames* permission";
// Allow changing your own nickname
if (member === apply) return true;
// Check if the user is below on the role list
- if (!(memberPos > applyPos))
- throw "You do not have a role higher than that member";
+ if (!(memberPos > applyPos)) throw "You do not have a role higher than that member";
// Allow change
return true;
};