import { Command , CommandClient } from 'detritus-client' ; import { CommandTypes , GoogleLocales } from '../../../constants' ; import { Formatter , Parameters } from '../../../utils' ; import { BaseCommand } from '../basecommand' ; export interface CommandArgsBefore { locale ? : GoogleLocales ; } export interface CommandArgs { locale : GoogleLocales ; } export const COMMAND_NAME = 'set my locale' ; export default class SetMyLocaleCommand extends BaseCommand { constructor ( client ) { super ( client , { name : COMMAND_NAME , aliases : [ 'set my language' ] , default : null , label : 'locale' , metadata : { description : 'Set your default language preference.' , examples : [ `${ COMMAND_NAME } en-us` , `${ COMMAND_NAME } german` , ] , type : CommandTypes . SETTINGS , usage : '<locale>' , } , type : Parameters . locale , } ) ; } onBeforeRun ( context , args ) { return ! ! args . locale ; } onCancelRun ( context , args ) { return context . editOrReply ( '⚠ Provide some kind of language' ) ; } async run ( context , args ) { return Formatter . Commands . SettingsMeLocale . createMessage ( context , { locale : args . locale } ) ; } }