Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from Abhijith4124/dev
Browse files Browse the repository at this point in the history
Version 1
  • Loading branch information
Abhijith4124 authored Feb 14, 2024
2 parents 3e64353 + 23a8b02 commit 990ba1d
Show file tree
Hide file tree
Showing 16 changed files with 946 additions and 265 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ AhhhBot is designed to enhance your Palworld gaming experience by allowing you t
## Features

- Whitelisting: Control access to your Palworld Game Server by managing whitelisted players directly from Discord.
- Player Spoofing Prevention: Prevent hackers from pretending to be another player on your server.
- Advanced Whitelisting: Whitelist Players on your server using thier SteamId, PlayerUid and even thier In Game Name to prevent any spoofing.
- In-Game Join/Leave Messages: Keep track of player activity with automatic announcements when players join or leave your Palworld server.
- Server Status Channel: Ability to setup a Server Status channel and the bot will automatically display the Current Server Status, Online Players, Max Player Count, Peak Player Count and a Player list.
- Discord Game Log Channel: Ability to setup a Game Log channel for the bot to post Game Server logs like Player Join/Leave, Non Whitelisted Player being kicked, Player Whitelisted, etc.
Expand All @@ -19,6 +21,9 @@ AhhhBot is designed to enhance your Palworld gaming experience by allowing you t
- Player Management: Easily ban or kick players from your Palworld Game Server using Discord commands.
- Broadcast Messages: Send messages directly to your Palworld server for all players to see, facilitating server-wide communication.
- PlayerUID and Steam ID Whitelisting: Support for both PlayerUID and Steam ID whitelisting, offering flexibility in player identification and management.

## Screenshots
![Welcome](https://i.ibb.co/1Jbnd3L/welcome.png)
## Commands

### Server Configuration
Expand All @@ -38,23 +43,39 @@ AhhhBot is designed to enhance your Palworld gaming experience by allowing you t
### Whitelisting Players
- `/whitelist [server] [enabled]`: Enable or disable whitelist for a Palworld Server.
- `/addwhitelist [server] [steamid] [playeruid] [discorduser]`: Add a player to the whitelist. Optionally, mention the Discord user for role assignment and announcement.
- `/removewhitelist [server] [steamid] [playeruid] [discorduser]`: Remove a player from the whitelist. Optionally, mention discord user to remove associated Discord roles.
- `/removewhitelist [server] [playername] [discorduser]`: Remove a player from the whitelist. Optionally, mention discord user to remove associated Discord roles.
- -`/linkwhitelist [server] [playername] [discorduser]`: Links a Game Player to a Discord User, granting them Whitelist roles and Welcome message if specified.
- -`/unlinkwhitelist [server] [playername]`: Unlinks a Game Player from a Discord User, removes thier Whitelist roles if specified.

### Miscellaneous Commands
- `/save`: Save the current Palworld game state.
- `/broadcast [server] [message]`: Send a message to players on the Palworld Server.
- `/banplayer [server] [playersteamid]`: Ban a player by their Steam ID.
- `/kickplayer [server] [playersteamid]`: Kick a player by their Steam ID.

### UI Options
##
![Server Configuration](https://i.ibb.co/Jt3RJt5/server-config.png)
- Configure Server Using the UI

##
![Whitelist UI](https://i.ibb.co/qJcksh8/whitelist.png)
- Whitelist Player Straight from the log

##
![Spoof Detection](https://i.ibb.co/V2PRVSC/spoof-prevention.pngg)
- Ban Detected Players Instantly with just a click!


## Config File
Edit the config.json file in the root directory

```
{
"token": "your_discord_bot_token",
"botApplicationId": "your_bot_id"
"debug": false,
"token": "",
"botApplicationId": "",
"customStatusMessage": ""
}
```

Expand Down
37 changes: 6 additions & 31 deletions commands/moderation/banplayer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const {getServerPlayersInfo, kickPlayer, banPlayer} = require("../../utils/palworld/palworldRCONWrapper");
const {EmbedBuilder, SlashCommandBuilder} = require("discord.js");
const {logToGameLogChannel} = require("../../utils/discord/logger");
const {SlashCommandBuilder} = require("discord.js");
const {PermissionFlagsBits} = require("discord-api-types/v10");
module.exports = {
data: new SlashCommandBuilder()
Expand All @@ -20,38 +19,14 @@ module.exports = {
)
.setDefaultMemberPermissions(PermissionFlagsBits.BanMembers),
async execute(interaction) {
const db = interaction.client.db;

await interaction.deferReply();
let serverName = interaction.options.getString("server");
let playerSteamId = interaction.options.getString("playersteamid");

const guildServersKey = `${interaction.guild.id}_PalServers`;
let guildServers = db.get(guildServersKey);

const kickEmbed = new EmbedBuilder().setColor(0x0099FF);

if (!guildServers) {
kickEmbed.setTitle("Server Does not Exist");
kickEmbed.setDescription("You have not added any PalWorld Servers to the bot");
await interaction.reply({ embeds: [kickEmbed] });
return;
}

const server = guildServers.find(server => server.serverName === serverName);

if (!server) {
kickEmbed.setTitle("Server Does not Exist");
kickEmbed.setDescription("Invalid Server to Ban Player from");
await interaction.reply({ embeds: [kickEmbed] });
return;
}

banPlayer(server.host, server.RCONPort, server.password, playerSteamId);

kickEmbed.setTitle("Banned Player");
kickEmbed.setDescription(`Banned Player with the Steam Id ${playerSteamId} from the server ${serverName}`);
await interaction.reply({ embeds: [kickEmbed] });
logToGameLogChannel(interaction.client, interaction.guild.id, serverName, "Banned Player", `Banned Player with the Steam Id ${playerSteamId} from the server ${serverName}`);
await banPlayer(interaction, {
serverName: serverName,
playerSteamId: playerSteamId
});
},
async autocomplete(interaction) {
const db = interaction.client.db;
Expand Down
36 changes: 6 additions & 30 deletions commands/moderation/kickplayer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const {getServerPlayersInfo, kickPlayer} = require("../../utils/palworld/palworldRCONWrapper");
const {EmbedBuilder, SlashCommandBuilder} = require("discord.js");
const {logToGameLogChannel} = require("../../utils/discord/logger");
const {SlashCommandBuilder} = require("discord.js");
const {PermissionFlagsBits} = require("discord-api-types/v10");
module.exports = {
data: new SlashCommandBuilder()
Expand All @@ -20,38 +19,15 @@ module.exports = {
)
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers),
async execute(interaction) {
const db = interaction.client.db;
await interaction.deferReply();

let serverName = interaction.options.getString("server");
let playerSteamId = interaction.options.getString("playersteamid");

const guildServersKey = `${interaction.guild.id}_PalServers`;
let guildServers = db.get(guildServersKey);

const kickEmbed = new EmbedBuilder().setColor(0x0099FF);

if (!guildServers) {
kickEmbed.setTitle("Server Does not Exist");
kickEmbed.setDescription("You have not added any PalWorld Servers to the bot");
await interaction.reply({ embeds: [kickEmbed] });
return;
}

const server = guildServers.find(server => server.serverName === serverName);

if (!server) {
kickEmbed.setTitle("Server Does not Exist");
kickEmbed.setDescription("Invalid Server to Kick Player from");
await interaction.reply({ embeds: [kickEmbed] });
return;
}

kickPlayer(server.host, server.RCONPort, server.password, playerSteamId);

kickEmbed.setTitle("Kicked Player");
kickEmbed.setDescription(`Kicked Player with the Steam Id ${playerSteamId} from the server ${serverName}`);
await interaction.reply({ embeds: [kickEmbed] });
logToGameLogChannel(interaction.client, interaction.guild.id, serverName, "Kicked Player", `Kicked Player with the Steam Id ${playerSteamId} from the server ${serverName}`);
await kickPlayer(interaction, {
serverName: serverName,
playerSteamId: playerSteamId
})
},
async autocomplete(interaction) {
const db = interaction.client.db;
Expand Down
3 changes: 3 additions & 0 deletions commands/server/serverconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ module.exports = {
const statusChannelId = menuInteraction.values[0];

if (statusChannelId) {
const statusMessageIdKey = `${statusChannelId}_${serverName.replaceAll(" ", "_")}_StatusMessageId`;
db.delete(statusMessageIdKey);

db.set(statusChannelIdKey, statusChannelId);
await menuInteraction.reply({ content: `Status Channel Set to <#${statusChannelId}>` });
}
Expand Down
61 changes: 17 additions & 44 deletions commands/whitelist/addwhitelist.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const {SlashCommandBuilder, EmbedBuilder} = require("discord.js");
const {SlashCommandBuilder, EmbedBuilder, TextInputBuilder, RoleSelectMenuBuilder, ActionRowBuilder, ModalBuilder} = require("discord.js");
const config = require('../../config.json');
const {PermissionFlagsBits} = require("discord-api-types/v10");
const {whitelistPlayer} = require("../../utils/palworld/whitelistManager");

module.exports = {
data: new SlashCommandBuilder()
Expand All @@ -11,6 +12,10 @@ module.exports = {
.setDescription("The server you want to add the player to")
.setRequired(true)
.setAutocomplete(true)
).addStringOption(option =>
option.setName("ingamename")
.setDescription("In Game Name of the player to whitelist")
.setRequired(true)
).addStringOption(option =>
option.setName("steamid")
.setDescription("Steam ID of the player to whitelist")
Expand All @@ -29,53 +34,18 @@ module.exports = {
await interaction.deferReply();

const serverName = interaction.options.getString("server");
const inGameName = interaction.options.getString("ingamename").trim();
const steamId = interaction.options.getString("steamid").trim();
const playerUid = interaction.options.getString("playeruid").trim();
const discordUser = interaction.options.getUser("discorduser");

const db = interaction.client.db;
const guildId = interaction.guild.id;

const whitelistedPlayersListKey = `${guildId}_${serverName.replaceAll(" ", "_")}_WhitelistedPlayerList`;
let whitelistedPlayers = db.get(whitelistedPlayersListKey);

if (!whitelistedPlayers) {
whitelistedPlayers = [];
}

if (whitelistedPlayers.find(player => player.steamid === steamId && player.playeruid === playerUid)) {
const alreadyWhitelistedEmbed = new EmbedBuilder()
.setColor(0x0099FF).setTitle("Player is already whitelisted").setDescription("Player is already whitelisted");
await interaction.editReply({ embeds: [alreadyWhitelistedEmbed] });
return;
}

whitelistedPlayers.push({ steamid: steamId, playeruid: playerUid, discorduser: discordUser });
db.set(whitelistedPlayersListKey, whitelistedPlayers);

const whitelistAnnouncementChannelIdKey = `${guildId}_${serverName.replaceAll(" ", "_")}_WhitelistAnnouncementChannelId`;
const whitelistRoleIdKey = `${guildId}_${serverName.replaceAll(" ", "_")}_WhitelistRoleId`;

const whitelistAnnouncementChannelId = db.get(whitelistAnnouncementChannelIdKey);
const whitelistRoleId = db.get(whitelistRoleIdKey);

const whitelistedEmbed = new EmbedBuilder()
.setColor(0x0099FF).setTitle("Player Whitelisted").setDescription(`Player ${discordUser ? discordUser : ""} has been whitelisted for the server ${serverName}`);
interaction.editReply({ embeds:[whitelistedEmbed] })

if (whitelistAnnouncementChannelId) {
const announcementChannel = await interaction.client.channels.cache.get(whitelistAnnouncementChannelId);
if (announcementChannel && whitelistRoleId && discordUser) {
const role = interaction.guild.roles.cache.get(whitelistRoleId);
if (role) {
let guildUser = await interaction.guild.members.fetch(discordUser);
await guildUser.roles.add(role);
}
const whitelistedAnnouncementEmbed = new EmbedBuilder()
.setColor(0x0099FF).setTitle("Player Whitelisted").setDescription(`Player ${discordUser ? discordUser : ""} has been whitelisted for the server ${serverName}`);
await announcementChannel.send({ embeds: [whitelistedAnnouncementEmbed] });
}
}
await whitelistPlayer(interaction, {
serverName:serverName,
inGameName: inGameName,
steamId: steamId,
playerUid: playerUid,
discordUser: discordUser
});
},
async autocomplete(interaction) {
const db = interaction.client.db;
Expand All @@ -95,5 +65,8 @@ module.exports = {

await interaction.respond(guildServers.map(server => ({ name: server.serverName, value: server.serverName }) ));
}
},
async addWhiteList() {

}
}
Loading

0 comments on commit 990ba1d

Please sign in to comment.