Primary Repository for PartBot
GPL-3.0 License
Base code for PartBot, a Bot on Pokémon Showdown.
Features: At this point, there's way, way too many to list. Honestly just go through the code to find out.
config.js
. Enter the Bot prefix, Bot username, Bot password, Bot avatar, Bot status, Bot owner, and an array of rooms you'd like the Bot to join. Scroll down and add the IDs of the users that you would like to set in their respective ranks. For more details on ranks, read below.npm install
npm run update-data
node bot.js
If all goes well, you should get a prompt notifying you of your Bot having connected.
Node.js (> Node 14.0.0)
Rank | Permissions |
---|---|
Locked | Limited access to help commands. |
None | Standard access. |
Gamma | Hangman and broadcasting access. |
Beta | Moderation, Tour, and Game access. |
Alpha | Control and Edit access. |
Coder | Code, Maintainence access. |
Admin | Complete access. |
Auth | Rank |
---|---|
+ | Gamma |
% | Beta |
*, @, #, &, ~ | Alpha (~ is still supported for sideservers) |
For room-specific authority, edit the ./data/DATA/roomauth.json file, and add the auth as a property of the room key (it already has an example).
PartBot has the following structure:
client.js
is responsible for handling the connection between the Bot and the server. You will almost never be needed to edit this.bot.js
is the main file. It contains references to all the other files and initiates the Bot. It also contains the PM handler.handlers/chat.js
handles messages sent in chat, and messages that start with the prefix are redirected to the command handler, whose code can be found in commands.js
.handlers/discord.js
contains the Discord command handler.handlers/autores.js
and discord_chat.js
handle the PS and Discord autores, respectively.global.js
instantiates all global variables, including data.handlers/battle.js
handles the battle interface, handlers/router.js
handles the website, handlers/schedule.js
has scheduled daily functions, handlers/ticker.js
handles the internal ticker (a function which runs periodically every 20 seconds), handlers/tours.js
handles tournament-related stuff.commands/ROOM/COMMAND.js
, with ROOM being 'global' for global commands. PM commands, similarly, are all in pmcommands
.pages
contains most of the HTML-related templates and pages for the website, while public
files can be accessed from anywhere through ${websiteLink}/public/filepath
.data
folder contains all the relevant data files required to run the Bot. It also contains the tools.js
and hotpatch.js
files, which are used to expose the utilities and hotpatching mechanisms.PartBot's code has a variety of global variables, all of which can be found from global.js. Commonly used ones include:
toID
: The single most-used function in PartBot's code. Coverts a string input to its ID. (This was formerly known as toId, feel free to convert it to toID wherever you see it)unxa
: "Unexpected number of arguments."tools
: A global object with various useful functions. Go through ./data/tools.js
to view / edit them.data
: A global object that stores most of the data (Pokedex, moves, etc). Check the requires in ./globals.js
to view the individual sources, which are mostly in ./data/DATA
.GAMES
: PartBot's Games module. You can find most of PartBot's games here; the module is in data/GAMES
.Bot
: The PS client. The class is defined in client.js
, but the instance is global. Primary functions include Bot.say(roomid, text)
and Bot.pm(userid, text)
. State is mostly stored under various keys in the main object, and room data can be found in Bot.rooms
. Most games are assigned to the Bot.rooms[roomid]
object.Once you've set up the configuration file, there are still a couple steps left to set up Discord. If you have token
set to false, ignore these steps.
config.js
and replace the string 'ADMIN_ID'
with your Discord ID.(Yeah, that was it)
How do I get the token for my Bot?
First, open the Discord Developer Portal. If you haven't already done so, create an Application and set it up. After converting the application to a Bot, go to the Bot section and copy your token. This token grants access to your application, so keep it private.
How do I get my Discord ID?
Go to Discord settings and enable Developer Mode. Once enabled, right click your name and copy the ID.
How do I invite my Bot to a server?
You can only invite the Bot to servers in which you have the Manage Server
permission. Open your application on the Discord Developer Portal, and go to OAuth2. In Scopes, select Bot, and scroll down to select the relevant permissions. After this, simply visit the link that pops up below Scopes. This link may be shared and used multiple times.
PartBot now supports separate leaderboards and shops. Even better, leaderboards can have any number of unique currencies. Documentation for these will come soon. 😅
PartMan - Lead Developer
Ecuacion - client.js base
Many thanks to the numerous people who helped me start out with this years ago.