translate: i aint implementing autocomplete rn
This commit is contained in:
		
							parent
							
								
									dc146d17e1
								
							
						
					
					
						commit
						deafb62ca2
					
				
					 1 changed files with 10 additions and 7 deletions
				
			
		| 
						 | 
					@ -182,24 +182,27 @@ translateInteraction.options.content = {
 | 
				
			||||||
translateInteraction.options.from = {
 | 
					translateInteraction.options.from = {
 | 
				
			||||||
  name: "from",
 | 
					  name: "from",
 | 
				
			||||||
  type: ApplicationCommandOptionTypes.STRING,
 | 
					  type: ApplicationCommandOptionTypes.STRING,
 | 
				
			||||||
  description: "Language to translate from (default: Auto Detect)",
 | 
					  description: "Language to translate from (default: auto)",
 | 
				
			||||||
  default: "auto",
 | 
					  default: "auto",
 | 
				
			||||||
  choices: Object.entries(languageCodeToName).map(([code, name]) => ({name, value: code})),
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
translateInteraction.options.to = {
 | 
					translateInteraction.options.to = {
 | 
				
			||||||
  name: "to",
 | 
					  name: "to",
 | 
				
			||||||
  type: ApplicationCommandOptionTypes.STRING,
 | 
					  type: ApplicationCommandOptionTypes.STRING,
 | 
				
			||||||
  description: "Language to translate to (default: English)",
 | 
					  description: "Language to translate to (default: en)",
 | 
				
			||||||
  default: "en",
 | 
					  default: "en",
 | 
				
			||||||
  choices: Object.entries(languageCodeToName)
 | 
					};
 | 
				
			||||||
    .filter(([code]) => code !== "auto")
 | 
					translateInteraction.options.languages = {
 | 
				
			||||||
    .map(([code, name]) => ({name, value: code})),
 | 
					  name: "languages",
 | 
				
			||||||
 | 
					  type: ApplicationCommandOptionTypes.BOOLEAN,
 | 
				
			||||||
 | 
					  description: "List languages instead of translating",
 | 
				
			||||||
 | 
					  default: false,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
translateInteraction.callback = async function (interaction) {
 | 
					translateInteraction.callback = async function (interaction) {
 | 
				
			||||||
  const text = this.getOption(interaction, "text");
 | 
					  const text = this.getOption(interaction, "text");
 | 
				
			||||||
  const from = this.getOption(interaction, "from");
 | 
					  const from = this.getOption(interaction, "from");
 | 
				
			||||||
  const to = this.getOption(interaction, "to");
 | 
					  const to = this.getOption(interaction, "to");
 | 
				
			||||||
 | 
					  const languages = this.getOption(interaction, "languages");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return translate.callback(interaction, text, text.split(" "), {from, to});
 | 
					  return translate.callback(interaction, text, text.split(" "), {from, to, languages});
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
hf.registerCommand(translateInteraction);
 | 
					hf.registerCommand(translateInteraction);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue