Example
Hey guys,
can anyone tell me how to add such an input field to a slash command in Discord.js (v.14)?
Example above.
Look at the discord.js doc here
When you create a command, you have just to set the options parameters :
client.application.commands.create({
type: "CHAT_INPUT",
name: "mycommand",
description: "My awesome command",
options: [
{
type: "STRING",
name: "firstparameter",
description: "My first parameter",
required: true
}
]
});
Related
I'm writing a VS Code Extension using the Language Server Protocol.
I'm having a strange issue with the word completion feature.
connection.onCompletion(
(_textDocumentPosition: TextDocumentPositionParams): CompletionItem[] => {
return [
{
label: 'foo',
kind: CompletionItemKind.Text,
data: 1
},
{
label: 'bar',
kind: CompletionItemKind.Text,
data: 2
},
{
label: 'nfoo',
kind: CompletionItemKind.Text,
data: 3
},
{
label: 'nbar',
kind: CompletionItemKind.Text,
data: 4
},
];
}
);
The LSP-Sample does this just fine. But in my implementation, this only prompts word completion in VS Code for the words starting with "n".
Even more confusing, if I install the Cloud Code extension from Google, all words start showing up as options.
See these GIFs:
without Cloud Code extension: https://gyazo.com/3ca97983e748910a0a93d2937950f8b5
with the Cloud Code extension: https://gyazo.com/73db98ce43583f4edec2a2af3817ec3a
Any ideas what this could be related to? And why another VS Code extension can interfere with my extension?
according to the fastify 4.0 docs, the default options for Ajv include removeAdditional: true. I have a queryString schema, and when I send a query with a param that is not in the schema, I expect that param to be removed. But no such thing happens. The schema itself is pretty run-of-the-mill
querystring: {
type: "object",
properties: { … }
}
Some of my params are of type array, and there too I would like any additional values (outside of those specified via enum to be removed. How can I achieve this?
update: I am adding the actual schema below (with some info snipped for brevity)
{
'$schema': 'https://json-schema.org/draft/2020-12/schema',
'$id': 'https://example.com/treatments.schema.json',
title: 'Treatments',
summary: 'Fetches treatments',
description: 'Treatments are…',
response: {},
querystring: {
type: 'object',
additionalProperties: false,
properties: {
treatmentId: {
type: "string",
maxLength: 32,
minLength: 32,
description: "A 32 character string: treatmentId=388D179E0D564775C3925A5B93C1C407"
},
… <snipped> …
}
},
tags: [ 'zenodeo' ]
}
I know the schema is being validated because http://localhost:3010/v3/treatments?treatmentId=foo gives an error {"statusCode":400,"error":"Bad Request","message":"querystring/treatmentId must NOT have fewer than 32 characters"} (that is good 👍🏽) but the additionalProperties: false constraint is still not working because http://localhost:3010/v3/treatments?foo=bar gives no error and foo is also not removed from request.query (that is not good 👎🏽)
With removeAdditional: true you must still set additionalProperties: false on your schema:
querystring: {
type: "object",
properties: { … },
additionalProperties: false
}
See https://ajv.js.org/json-schema.html#additionalproperties
You can also change the default behavior to removeAdditional: 'all' in which case you don't have to set additionalProperties: false on your schema.
See about halfway down the page here: https://www.fastify.io/docs/latest/Reference/Validation-and-Serialization/
Is it not possible to use an object type as a reference in sanity? For example this is not working. When I go to the field nothing shows up. If I can't do this how can I access the indexPage objects that have been created under other documents?
export const indexPage = {
title: "Index Page",
name: "indexPage",
type: "object",
fields: [
{
title: "Subheading",
name: "subheading",
type: "array",
of: [{ type: 'block' }]
},
{
title: "Content",
name: "content",
type: "array",
of: [{ type: "block" }]
},
]
}
// in another file
export const coolPage = {
title: "Cool Page",
name: "coolPage",
type: "object",
fields: [
{
title: "Reference Index Page",
name: "refIndexPage",
type: "reference",
to: [{ type: 'indexPage' }]
}
]
}
References can only point to other documents; not to a specific part of a document. So to achieve this, indexPage would need to be a document.
I think modelling indexPage as a document would be a viable option in your case. You mentioned "indexPage objects that have been created under other documents". Instead of creating indexPage data inside a specific document, indexPage should be its own document type. Any other document can then connect to it via a reference. This approach should be really flexible for you.
Sanity Studio recently added support for "references in place", which makes this workflow even better. The studio now allows you to create a document to reference while you are editing the document that references it—without leaving the editor. You can see a demo here (no extra work on your part is needed here, it's handled automatically by Sanity Studio).
In summary: if you have a piece of data you'd like to share between multiple documents, model it as its own document type that is referenced by every document that is related.
I use 'Docusaurus' to docs but I don`t know How to config multi-language sideBar.
[
'#docusaurus/preset-classic',
{
docs: {
path: 'docs',
routeBasePath: '/',
sidebarPath: require.resolve('./sidebars.js')
},
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
},
],
]```
The code only use a kind of sidebars, if I switch the language The sidebars can`t switch.
run the write-translations command, for example your locale is zh-cn, when command finished, you will get a current.json file in the i18n/zh-cn/docusaurus-plugin-content-docs directory
yarn run write-translations -- --locale zh-cn
the current.json contains the docs sidebar's category labels, modify it like the following:
{
"version.label": {
"message": "5.0.0.alpha.1",
"description": "The label for version current"
},
"sidebar.docsSidebar.category.Getting Started": {
"message": "开始上手",
"description": "The label for category Getting Started in sidebar docsSidebar"
},
"sidebar.docsSidebar.category.Guides": {
"message": "指南",
"description": "The label for category Guides in sidebar docsSidebar"
}
}
for more details, refer to:https://docusaurus.io/docs/next/i18n/tutorial#translate-plugin-data
Docusaurus allows you to add a navbar item so the user can select the language they want. You can enable the dropdown by adding the code below, as explained in the official documentation, to the docusaurus.config.js file.
If you want to find out more you can also have a look at this video in which I explain all the steps you need to follow to translate your Docusaurus website.
module.exports = {
themeConfig: {
navbar: {
items: [
{
type: 'localeDropdown',
position: 'left',
},
],
},
},
};
if I switch the language The sidebars can`t switch
If you properly prepared i18n JSON files, when you switch the locale (language), the sidebar label will show different languages.
I'm using a website with Gridsome and I use markdown files to feed content to the website.
I have little experience with markdown. While I don't really understand how md files work, I managed to get it working with a few tutorials until I started adding arrays into the md file see below.
content/home/index.md
---
metaTitle: this is the meta title tag
metaDescription: metadescription
someArray: [alpha, beta, delta] //I tried adding an array like this and it worked fine
imgArray: [{url: "someurl", alt: "some alt", caption: "some caption}, {url: "someurl", alt: "some alt", caption: "some caption}] //this did not work and caused an error
---
my question is whether adding an array of objects in markdown files possible? if it is, how do I write it? thanks very much!
In your YAML, the array is invalid in that it's missing quotes after some caption.
The section of metadata you're describing is the YAML frontmatter, and it's not specific to Gridsome or Vue.
Yes, object arrays are allowed in YAML either as comma-separated objects:
imgArray2: [
{url: "someurl", alt: "some alt", caption: "some caption"},
{url: "someurl", alt: "some alt", caption: "some caption"}
]
demo
...or as lists, where each element starts on a new line with a hyphen prefix:
imgArray:
- {url: "someurl", alt: "some alt", caption: "some caption"}
- {url: "someurl", alt: "some alt", caption: "some caption"}
demo