Skip to content

Discord Bot Integration:

Back To: Discord Integration

This section covers how to set up and configure a Discord bot.

Discord bot integration can be useful for various things. For example:

  1. Get notified when a shiny is found.
  2. Get notified when a long-running program is finished or otherwise needs your attention.
  3. Send notifications for live (real-time) hosting.
  4. Use remote control commands to start or stop a program, send controller inputs, take screenshots, etc.

Step 1: Create and set up your Discord bot application

  1. Go to Discord's Developer Portal and create a new application.
  2. Navigate to the Bot tab on the left sidebar and add a new bot. You can give it a username and an avatar if you wish. This is the tab you will get your bot token from, we'll need it later. Under TOKEN, copy the token and save it somewhere. If you forget to copy and save it, just click Reset Token, and copy the new token. Note that this will invalidate the old token.

    Important note: never share or reveal your token to anyone. If you do, other people will be able to access your bot account and abuse it.

  3. Navigate to the Installation tab on the left sidebar. Under Installation Contexts, ensure Guild Install is checked, and User Install is unchecked. Under Install Link, set the dropdown to None.

  4. Make sure your bot is set to private, otherwise anyone will be able to invite it to their servers.

If you want to use message commands instead of slash commands: - Under Privileged Gateway Intents enable Message Content Intent. Save your changes. - Your bot cannot exceed 10,000 users across all servers to use this feature.

<img src="../../DiscordIntegration/images/discord-bot-intents-0.jpg">
  1. Go to the OAuth2 tab in the left sidebar. We will now generate an invite URL with the correct permissions.

Under SCOPES, select bot.

You now have two options:

a. Do not grant any permissions, copy the generated URL below and invite the bot to a server you have Manage Server permissions in. Bot will not have any permissions, you can configure a role in the server or configure on a per-channel basis. This is the preferred option if you are setting up your bot in someone else's server.

b. Grant Send Messages, Embed Links, Attach Files, Read Message History permissions. This will allow you to invite the bot to a server you have Manage Server permissions in, and your bot will have a pre-configured role.

Copy the generated URL shown above and paste it into your browser of choice. Click Continue.

NOTE: If you don't already have a server that you have Manage Server permissions in, one way is to create your own server.

  • On the Discord left sidebar, scroll to the bottom of the list of servers that you're in.
  • Click the + button, Add a Server.
  • Create My Own. Then follow the rest of the prompts to create your own server.

Step 2: Open up the Discord settings.

Open up the Pokémon Automation Computer control program and click on the Settings button in the bottom-left section. This opens up the settings panel. Scroll down to the Discord settings. Enable Discord Integration Settings.

Step 3: Get your Discord bot's token and your user ID.

  1. Paste the Discord Bot token into the Discord Token box. If you haven't already copied the token, head back to the Bot tab in Discord's Developer Portal, reveal and copy your bot's token.

  2. To get your Discord User ID, follow this guide. You will first need to enable Developer mode on your account. Paste your User ID into the Discord User ID box.

Step 4: Set up your channels and notifications.

  1. Click "Add Row". In the Description box enter your own description so it's easier for you to identify channels later on.

  2. Similarly to how you got your User ID in the previous step, get the channel ID you want to send notifications to and paste it into Channel ID. Note: we want the Channel ID, not the Server ID.

  3. If you want your bot to respond to commands in that channel, check Allow Commands.

Step 5: Send a test message and try out commands.

Click Start Bot.

If channel permissions are configured properly, the bot should appear online after a few moments. If it doesn't, check the channel and role permissions.

If the bot is online, good job! Now let's test notifications and commands!

Navigate to any program that sends notifications. All programs that send notifications will have the following section near the bottom of the settings.

Click on any of the "Send Test Message" buttons. If everything worked properly, this will send a message to the configured channel(s).

If it doesn't, there can literally be a million things wrong. A good place to start is to open up the Output Window and look for any errors, and to retrace your steps to make sure you set permissions correctly in your server.

When using Slash commands for the very first time you will have to register them. To do this, just click the "Register Slash Commands" button in the Discord Integration Settings panel. Do not spam this button, clicking once is enough. After registering Slash commands, restart your Discord client for changes to take effect.


Settings overview

  • Run Discord Integration On Launch: If enabled, Discord bot integration will automatically start as soon as you open the program.
  • Register Slash Commands: If using Slash commands, clicking this button will register the commands with Discord. You only need to do this once on a new bot, or if new commands are added in the future.
  • Discord Integration Command Type: Dropdown menu that allows you to choose between the modern slash commands or the older style message commands. Only available when using the D++ library.
  • Discord Token: This is where you'll paste your bot's token. It will be blanked so you don't accidentally reveal it.
  • Discord Command Prefix: Symbol or text your bot will recognize as the start of a command. Does not apply if using Slash commands.
  • Discord Game Status: Flavor text that will appear under your bot's name in the sidebar.
  • Discord Hello Message: Bot's response to the $hi command.
  • Allow Buttons from Users: If enabled, allows users to use button commands (normally restricted to the bot owner). Only use it if you trust the users who have access to your bot.

Discord Channels table - Settings overview

Column: "Description"

Enter your own description for each channel so you can identify them more easily.

Column: "Allow Pings"

If unchecked, you will never be pinged by the bot. If checked, you will be pinged if the notification requests a ping.

In order to be pinged by a notification, all of these conditions must be met:

  1. The notification is sent to your bot.
  2. "Allow Pings" is checked.
  3. "Should Ping" is checked for the respective event in the program's discord notification settings.

Column: "Tags"

This lets you filter what events are sent. A notification is only sent if a tag is shared with the event itself.

A notification is sent only if all of these conditions are met:

  1. The bot is started and Enabled is checked for a given row in Discord settings.
  2. The corresponding event in the program is enabled. (Notifications are enabled for the program and "Enable" is checked for the respective event.)
  3. There is at least one tag in common between the channel and the event type in the program.
  4. The event that is being sent is not being rate limited.

The tag can be any alpha-numeric string and must match exactly. By default the program pre-populates the tags with "Notifs", "Showcase", and "LiveHost". You are free to change them or make your own.

A typical use-case is to send logs ("Notifs") down one channel while broadcasting live-hosting notifications to multiple servers.

Column: "Allow Commands"

This lets you toggle whether your bot will respond to commands in a given channel.

Column: "Channel ID"

This lets you specify and fine-tune channels for notifications and commands.


Command Overview

A general command cheat sheet.

Miscellaneous Commands

  • help: Will post all commands that are available to the invoking user with their parameters and descriptions.
  • status: Will post information about currently running programs and consoles. Good way to find out your console ID (required as a parameter for some commands).
  • about Will provide some general information about the bot.
  • hi: Will post a cute reply to the command invoker.
  • ping: Will reply with ping!

Owner Commands

  • click <console id> <button>: Will send a button input command to the specified console.
  • joystick <console id> <LStick/RStick> <x magnitude (0-255)> <y magnitude (0-255)> <hold ticks>: Will hold the specified joystick for the specified console for a time. Note: if a program is running, remote button commands will be denied. Remotely stop a running program first.

  • start <console id>: Will start a stopped program for the specified console.

  • stop <console id>: Will stop a running program for the specified console.
  • resetserial <console id>: Will reset the serial connection for the specified console.
  • resetcamera <console id>: Will reset the camera view for the specified console.
  • screenshot <console id> <format (png or jpg)>: Will take a screenshot from the specified console and upload it to the channel this command was invoked in.

Troubleshooting

  • My bot won't come online!

If you can see your bot successfully connecting online in the Output Window, most likely your channel and/or role permissions for your bot are wrong. Double-check permissions specifically related to reading messages and viewing channels. If you have assigned your bot a role, view server as the role to make this easier.

  • My bot is getting rate limited!

Add a delay for sending messages. If you're sending messages to tons of channels or are running several program instances using the same token you may want to consider making additional bots. Also make sure you are not registering Slash command too frequently - Discord doesn't like that.

  • My bot's Slash commands are showing up in every channel!

Restrict Slash commands in your server settings.

  • I've registered Slash commands but I don't see them!

Assuming the user/role/channel is not restricted you may just have to wait for a few minutes or restart your Discord client app for the changes to take effect. Discord is slow at caching them.

  • Slash commands don't recognize me as the owner!

If you have "Privileged Gateway Intents" enabled, and your bot has 10,000 or more users across all servers it's in, and you've applied for review to keep the "Message Content" intent (or others), the owner ID will not be read correctly as the bot will return a "team ID" instead.

  • The console ID parameter that worked before no longer works!

Console ID changes as you select/switch programs. Use the status command to check it after switching programs or restarting the program.

  • I've tried everything but it doesn't work!

Post a detailed message in Pokémon Automation's Discord server. For proper human troubleshooting you will be expected to explain how you performed each step in the guide, provide relevant logs, and, if applicable, provide pictures of relevant steps.


Discord Server: