如何添加将接受字符串discord-js的选项



我找不到解决问题的方法。我想创建一个change_nick命令,但我不知道要使用的此选项的类型/编号。

我的命令创建者:

commands.create
(
{
name: 'change_nick',
description: 'changes nick for specified person',
options:
[
{
name: 'user',
description: 'user that name will be changed',
type: 6,
},
{
name: "new_username",
description: "new username",
type: "" //that's what I'm searching for,
},
]
},
);

我试着浏览和阅读文档,但找不到任何

如果你想接受一个字符串,那么它是数字3:

commands.create({
name: 'change_nick',
description: 'changes nick for specified person',
options: [
{
name: 'user',
description: 'user that name will be changed',
type: 6,
},
{
name: 'new_username',
description: 'new username',
type: 3, //that's what I'm searching for,
},
],
});
附件子命令
类型
布尔型5
频道7
整数4
可提及9
数字10
角色8
字符串3
子命令组2
用户6

文档说它是类型3。
在discord.js中,您也可以这样做:
v13
const { Constants } = require('discord.js');
,然后使用
Constants.ApplicationCommandOptionTypes.STRING
v14
const { ApplicationCommandOptionType } = require('discord.js');
然后使用
ApplicationCommandOptionType.String

最新更新