Hello, I'm currently working on creating a nick command for my discord bot in TypeScript, but I encountered an error. Here is the issue:
Error: Expression expected.ts (1109)
When I replace
const mentionedMember = message? message.mentions.members?.first():
with
const mentionedMember = message? message.mentions.members?.first(),
It resolves the issue with const nickName = args.slice(1).join(" "); but it gives me the error
':' expected ts(1005) [19,76]
Here is the code snippet:
import "discord.js";
import { ICommand } from "wokcommands";
export default{
name: 'nickname',
category: 'Moderation',
aliases: ['nick'],
description: 'Nicks a user',
permissions: ['MANAGE_NICKNAMES'],
slash: 'both',
testonly: true,
callback: async({ client, message, args}) => {
const mentionedMember = message? message.mentions.members?.first() :
const nickName = args.slice(1).join(" ");
//gets the nickname
if (!args[0]) return message.reply('You did not mention a user for me to change their nickname!');
if (!mentionedMember) return message.reply('Please mention a user for me to change their nickname \`>nickname @user nickname\`');
if (!nickName) return message.reply('Please mention a nickname for me to change this user's nickname');
//returns an error message if there isn't a user mentioned or the new nick is not specified
if (!mentionedMember.kickable) return message.reply('This User Has a senior rank than me and I cannot change his nickname')
//checks if the user that has been mentioned is below the bot in rank of roles, if not the bot won't be able to change the nickname
await mentionedMember.setNickname(nickName) && await message.reply(`Successfully Changed ${mentionedMember} Nickname to ${nickName}`);
//changes the nickname to the specified nickname and sends a message successfully
},
}as ICommand