Fix Corona command
This commit is contained in:
parent
8fb3aeda91
commit
70e32ebbc6
1 changed files with 6 additions and 2 deletions
|
|
@ -31,13 +31,17 @@ public class CoronaCommand implements Command {
|
||||||
@Override
|
@Override
|
||||||
public void executed(String[] args, CommandEvent e) {
|
public void executed(String[] args, CommandEvent e) {
|
||||||
OkHttpClient client = new OkHttpClient();
|
OkHttpClient client = new OkHttpClient();
|
||||||
Request request = new Request.Builder().url("https://corona.lmao.ninja/all").build();
|
Request request = new Request.Builder().url("https://corona.lmao.ninja/v2/all").build();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Response response = client.newCall(request).execute();
|
Response response = client.newCall(request).execute();
|
||||||
JSONObject json = new JSONObject(response.body().string());
|
JSONObject json = new JSONObject(response.body().string());
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
stringBuilder.append("`Confirmed cases:` **").append(json.get("cases")).append("**\n").append("`Deaths:` **").append(json.get("deaths")).append("** \n").append("`Recovered:` **").append(json.get("recovered")).append("** \n").append("`Active cases:` **").append(json.get("active")).append("**");
|
stringBuilder
|
||||||
|
.append("`Confirmed cases:` **").append(json.get("cases")).append("**\n")
|
||||||
|
.append("`Deaths:` **").append(json.get("deaths")).append("** \n")
|
||||||
|
.append("`Recovered:` **").append(json.get("recovered")).append("** \n")
|
||||||
|
.append("`Active cases:` **").append(json.get("active")).append("**");
|
||||||
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO).setDescription(stringBuilder).build()).queue();
|
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO).setDescription(stringBuilder).build()).queue();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR)
|
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue