【发布时间】:2022-01-04 19:09:49
【问题描述】:
您好,我正在尝试为我的不和谐机器人创建一个 nick 命令,但我收到了这个错误。我的机器人正在使用类型脚本。
错误: 表达式expected.ts (1109)
当我替换时
const 提到的成员 = 消息? message.mentions.members?.first():
与
const 提到的成员 = 消息? message.mentions.members?.first(),
它修复了 const nickName = args.slice(1).join(" ");但给了我错误
':' 预期 ts(1005) [19,76]
代码:
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 there nickname!');
if (!mentionedMember) return message.reply('Please mention a user for me to change there nickname \`>nickname @user nickname\`');
if (!nickName) return message.reply('Please mention a nickname for me to change this users 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 then me i cant 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(`Successfuly Changed ${mentionedMember} Nickname to ${nickName}`);
//changes the nickname to the specified nickname and sends a message Successfuly
},
}as ICommand
【问题讨论】:
-
你做了
?,但应该是?.
标签: typescript discord discord.js