mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-03 08:39:04 +00:00
Add Kick Command To Discord Bot & Fix Type In ConfigLoader
This commit is contained in:
@@ -73,7 +73,7 @@ public class ConfigLoader {
|
||||
}
|
||||
|
||||
public static void loadSecrets() throws IOException {
|
||||
if (!new File("data/Secrets.json").exists()) {
|
||||
if (!new File("data/secrets.json").exists()) {
|
||||
initialize();
|
||||
System.out.println("Please open \"data/secrets.json\" file and enter your discord token bot there!");
|
||||
System.out.println("Please open \"data/secrets.json\" file and enter your Website Password there!");
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.rs2.integrations.discord;
|
||||
|
||||
import com.rs2.GameConstants;
|
||||
import com.rs2.game.players.Client;
|
||||
import com.rs2.game.players.Player;
|
||||
import com.rs2.game.players.PlayerHandler;
|
||||
import org.javacord.api.DiscordApi;
|
||||
import org.javacord.api.DiscordApiBuilder;
|
||||
import org.javacord.api.entity.channel.TextChannel;
|
||||
@@ -39,12 +42,22 @@ public class JavaCord {
|
||||
}
|
||||
api.addMessageCreateListener(event -> {
|
||||
|
||||
if (event.getMessageContent().startsWith("::w" + GameConstants.WORLD + " movehome")) {
|
||||
if (event.getMessageContent().startsWith("::w" + GameConstants.WORLD + " kick")) {
|
||||
if (event.getMessageAuthor().isServerAdmin()) {
|
||||
System.out.println("perms");
|
||||
event.getChannel().sendMessage("perms");
|
||||
String playerToKick = event.getMessageContent().replace("::w" + GameConstants.WORLD + " kick ", "");
|
||||
for (Player player2 : PlayerHandler.players) {
|
||||
if (player2 != null) {
|
||||
if (player2.playerName.equalsIgnoreCase(playerToKick)) {
|
||||
Client c2 = (Client) player2;
|
||||
event.getChannel().sendMessage("You have kicked " + playerToKick + ".");
|
||||
c2.disconnected = true;
|
||||
c2.logout(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
event.getChannel().sendMessage("You do not have permission to preform this command");
|
||||
event.getChannel().sendMessage("You do not have permission to perform this command");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user