commit
1125ffd5fb
4 changed files with 100 additions and 16 deletions
|
|
@ -127,7 +127,8 @@ public class Hadder {
|
||||||
new ServerStatsCommand(),
|
new ServerStatsCommand(),
|
||||||
new ProfileCommand(),
|
new ProfileCommand(),
|
||||||
new CodeCommand(),
|
new CodeCommand(),
|
||||||
new MoveAllCommand()), config, helpCommand);
|
new MoveAllCommand(),
|
||||||
|
new CoronaCommand()), config, helpCommand);
|
||||||
|
|
||||||
builder.addEventListeners(
|
builder.addEventListeners(
|
||||||
new MentionListener(rethink),
|
new MentionListener(rethink),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
|
||||||
|
*
|
||||||
|
* Licensed under the GNU Affero General Public License, Version 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.bbn.hadder.commands.misc;
|
||||||
|
|
||||||
|
import com.bbn.hadder.commands.Command;
|
||||||
|
import com.bbn.hadder.commands.CommandEvent;
|
||||||
|
import com.bbn.hadder.utils.MessageEditor;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class CoronaCommand implements Command {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executed(String[] args, CommandEvent e) {
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
Request request = new Request.Builder().url("https://api.covid.stream/latest/numbers").build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Response response = client.newCall(request).execute();
|
||||||
|
JSONObject json = new JSONObject(response.body().string()).getJSONObject("data");
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.append("`Confirmed cases:` **").append(json.get("totalConfirmedNumbers")).append("**\n").append("`Deaths:` **").append(json.get("totalDeathNumbers")).append("** \n").append("`Recovered:` **").append(json.get("totalRecoveredNumbers")).append("** \n");
|
||||||
|
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO).setDescription(stringBuilder).build()).queue();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR)
|
||||||
|
.setTitle("API Error")
|
||||||
|
.setDescription("Try again later!")
|
||||||
|
.build()).queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] labels() {
|
||||||
|
return new String[]{"corona"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String description() {
|
||||||
|
return "commands.misc.corona.help.description";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String usage() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String example() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,46 +1,56 @@
|
||||||
/*
|
/*
|
||||||
* @author Hax / Hax6775 / Schlauer_Hax
|
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
|
||||||
|
*
|
||||||
|
* Licensed under the GNU Affero General Public License, Version 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.bbn.hadder.commands.misc;
|
package com.bbn.hadder.commands.misc;
|
||||||
|
|
||||||
import com.bbn.hadder.commands.Command;
|
import com.bbn.hadder.commands.Command;
|
||||||
import com.bbn.hadder.commands.CommandEvent;
|
import com.bbn.hadder.commands.CommandEvent;
|
||||||
import com.bbn.hadder.core.Perm;
|
import com.bbn.hadder.core.Perm;
|
||||||
import com.bbn.hadder.core.Perms;
|
import com.bbn.hadder.core.Perms;
|
||||||
import net.dv8tion.jda.api.Permission;
|
import com.bbn.hadder.utils.MessageEditor;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
|
@Perms(Perm.VOICE_MOVE_OTHERS)
|
||||||
public class MoveAllCommand implements Command {
|
public class MoveAllCommand implements Command {
|
||||||
|
|
||||||
@Perms(Perm.VOICE_MOVE_OTHERS)
|
|
||||||
@Override
|
@Override
|
||||||
public void executed(String[] args, CommandEvent e) {
|
public void executed(String[] args, CommandEvent e) {
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
Objects.requireNonNull(e.getGuild().getVoiceChannelById(args[0])).getMembers().forEach(
|
int count = e.getGuild().getVoiceChannelById(args[0]).getMembers().size();
|
||||||
|
e.getGuild().getVoiceChannelById(args[0]).getMembers().forEach(
|
||||||
member -> e.getGuild().moveVoiceMember(member, e.getGuild().getVoiceChannelById(args[1])).queue()
|
member -> e.getGuild().moveVoiceMember(member, e.getGuild().getVoiceChannelById(args[1])).queue()
|
||||||
);
|
);
|
||||||
} else {
|
e.getChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
|
||||||
e.getHelpCommand().sendHelp(this, e);
|
"commands.misc.moveall.success.title", "",
|
||||||
}
|
"commands.misc.moveall.success.description", String.valueOf(count))
|
||||||
|
.build()).queue();
|
||||||
|
} else e.getHelpCommand().sendHelp(this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] labels() {
|
public String[] labels() {
|
||||||
return new String[]{"moveall", "move-all"};
|
return new String[]{"moveall", "move-all", "ma"};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String description() {
|
public String description() {
|
||||||
return "Moves All users in channel1 to channel2";
|
return "commands.misc.moveall.help.description";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String usage() {
|
public String usage() {
|
||||||
return "[channel1] [channel2]";
|
return "[source-channel] [target-channel]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,10 @@ commands.misc.code.success.description = This message contains some information
|
||||||
commands.misc.code.error.title = Code not found
|
commands.misc.code.error.title = Code not found
|
||||||
commands.misc.code.error.description = I can't find the specified invite code.
|
commands.misc.code.error.description = I can't find the specified invite code.
|
||||||
commands.misc.code.help.description = Shows information about a invite code.
|
commands.misc.code.help.description = Shows information about a invite code.
|
||||||
|
commands.misc.moveall.success.title = Successfully moved
|
||||||
|
commands.misc.moveall.success.description = I successfully moved %extra% members. Have fun!
|
||||||
|
commands.misc.moveall.help.description = Moves all users in the source channel to the target channel.
|
||||||
|
commands.misc.corona.help.description = Show the newest stats about COVID-19
|
||||||
|
|
||||||
commands.moderation.ban.success.title = Successfully banned
|
commands.moderation.ban.success.title = Successfully banned
|
||||||
commands.moderation.ban.success.description = I successfully baned %extra%
|
commands.moderation.ban.success.description = I successfully baned %extra%
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue