File tree Expand file tree Collapse file tree
src/main/java/technobot/commands/fun Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88import technobot .commands .Command ;
99import technobot .util .embeds .EmbedUtils ;
1010
11+ import java .net .URLEncoder ;
12+ import java .nio .charset .StandardCharsets ;
13+
1114/**
1215 * Command that googles something for the user.
1316 *
@@ -30,13 +33,7 @@ public void execute(SlashCommandInteractionEvent event) {
3033 event .replyEmbeds (EmbedUtils .createError ("google doesn't like questions longer than 250 characters!" )).queue ();
3134 return ;
3235 }
33-
34- StringBuilder query = new StringBuilder ("?q=" );
35- String [] words = question .strip ().split (" " );
36- for (int i = 0 ; i < words .length ; i ++) {
37- query .append (words [i ]);
38- if (i +1 != words .length ) query .append ("+" );
39- }
40- event .reply ("http://lmgtfy.com/" +query ).queue ();
36+ String query = URLEncoder .encode (question , StandardCharsets .UTF_8 );
37+ event .reply ("http://lmgtfy.com/?q=" +query ).queue ();
4138 }
4239}
You can’t perform that action at this time.
0 commit comments