1+ use std:: borrow:: Cow ;
2+ use std:: collections:: HashMap ;
3+
14use serenity:: builder:: { CreateCommand , CreateCommandOption } ;
25use serenity:: model:: application:: CommandOptionType ;
36
4- pub fn register ( ) -> CreateCommand {
7+ fn new_map < ' a > ( key : & ' a str , value : & ' a str ) -> HashMap < Cow < ' a , str > , Cow < ' a , str > > {
8+ let mut map = HashMap :: with_capacity ( 1 ) ;
9+ map. insert ( Cow :: Borrowed ( key) , Cow :: Borrowed ( value) ) ;
10+ map
11+ }
12+
13+ pub fn register ( ) -> CreateCommand < ' static > {
514 CreateCommand :: new ( "welcome" )
615 . description ( "Welcome a user" )
716 . name_localized ( "de" , "begrüßen" )
@@ -20,27 +29,28 @@ pub fn register() -> CreateCommand {
2029 . add_string_choice_localized (
2130 "Welcome to our cool server! Ask me if you need help" ,
2231 "pizza" ,
23- [ (
32+ new_map (
2433 "de" ,
2534 "Willkommen auf unserem coolen Server! Frag mich, falls du Hilfe brauchst" ,
26- ) ] ,
35+ ) ,
36+ )
37+ . add_string_choice_localized (
38+ "Hey, do you want a coffee?" ,
39+ "coffee" ,
40+ new_map ( "de" , "Hey, willst du einen Kaffee?" ) ,
2741 )
28- . add_string_choice_localized ( "Hey, do you want a coffee?" , "coffee" , [ (
29- "de" ,
30- "Hey, willst du einen Kaffee?" ,
31- ) ] )
3242 . add_string_choice_localized (
3343 "Welcome to the club, you're now a good person. Well, I hope." ,
3444 "club" ,
35- [ (
45+ new_map (
3646 "de" ,
3747 "Willkommen im Club, du bist jetzt ein guter Mensch. Naja, hoffentlich." ,
38- ) ] ,
48+ ) ,
3949 )
4050 . add_string_choice_localized (
4151 "I hope that you brought a controller to play together!" ,
4252 "game" ,
43- [ ( "de" , "Ich hoffe du hast einen Controller zum Spielen mitgebracht!" ) ] ,
53+ new_map ( "de" , "Ich hoffe du hast einen Controller zum Spielen mitgebracht!" ) ,
4454 ) ,
4555 )
4656}
0 commit comments