mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-03 00:31:51 +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 {
|
public static void loadSecrets() throws IOException {
|
||||||
if (!new File("data/Secrets.json").exists()) {
|
if (!new File("data/secrets.json").exists()) {
|
||||||
initialize();
|
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 discord token bot there!");
|
||||||
System.out.println("Please open \"data/secrets.json\" file and enter your Website Password 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;
|
package com.rs2.integrations.discord;
|
||||||
|
|
||||||
import com.rs2.GameConstants;
|
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.DiscordApi;
|
||||||
import org.javacord.api.DiscordApiBuilder;
|
import org.javacord.api.DiscordApiBuilder;
|
||||||
import org.javacord.api.entity.channel.TextChannel;
|
import org.javacord.api.entity.channel.TextChannel;
|
||||||
@@ -39,12 +42,22 @@ public class JavaCord {
|
|||||||
}
|
}
|
||||||
api.addMessageCreateListener(event -> {
|
api.addMessageCreateListener(event -> {
|
||||||
|
|
||||||
if (event.getMessageContent().startsWith("::w" + GameConstants.WORLD + " movehome")) {
|
if (event.getMessageContent().startsWith("::w" + GameConstants.WORLD + " kick")) {
|
||||||
if (event.getMessageAuthor().isServerAdmin()) {
|
if (event.getMessageAuthor().isServerAdmin()) {
|
||||||
System.out.println("perms");
|
String playerToKick = event.getMessageContent().replace("::w" + GameConstants.WORLD + " kick ", "");
|
||||||
event.getChannel().sendMessage("perms");
|
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 {
|
} 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