Skip to content

winglessraven/AMP-Discord-Bot

Repository files navigation

AMP Discord Bot Plugin

A full featured Discord bot plugin for AMP by Cubecoders that can be used to display the server status in a dynamically updating info panel along with the ability to manage the server directly from Discord.

  • Use buttons or commands to start/stop/restart/kill/update/manage.
  • Send console commands directly from Discord to your server.
  • Send server output to a Discord channel.
  • Track playtime of players.
  • Assign permissions to a role so only select members can manage the server.

Important

The plugin cannot be used on ADS. It can only run on non-ADS instances.

Submit any bug reports or feature requests here

Any known issues and workarounds can be found here

If you appreciate my work on this plugin, feel free to buy me a beer to keep me fueled up here

Discord Info Panel:

Bot Info Example

Web Panel:

Web Panel Example

Command Reference

Command Description
/[BOT NAME] info Display Server Info
/[BOT NAME] start-server Start the Server
/[BOT NAME] stop-server Stop the Server
/[BOT NAME] restart-server Restart the Server
/[BOT NAME] kill-server Kill the Server
/[BOT NAME] update-server Update the Server
/[BOT NAME] console [command] Send a command to the server
/[BOT NAME] playtime Show playtime leaderboard
/[BOT NAME] full-playtime-list Show full playtime list with last seen value
/[BOT NAME] take-backup Send a request to the AMP Panel to create an instance backup

Note: If Remove Bot Name is enabled in settings then the commands will exclude the name.

Configuration Steps

Install Script

Thanks to Bluscream there is now a handy install script to take care of activating instances, downloading the plugin, and enabling it.

The script can be found here.

For instructions to run the script, see here.

Configure AMP

Before the plugin can be used you need to configure AMP in a specific way. NOTE: The plugin cannot be used on ADS. It can only run on non-ADS instances.

Activate with a Developer Licence

  • Request a developer licence from AMP via the licence portal https://manage.cubecoders.com/Login
  • Once you have received the licence log into your server console and as the amp user run ampinstmgr stop [ADS INSTANCE NAME] followed by ampinstmgr reactivate [INSTANCE NAME] [DEVELOPER KEY] where [INSTANCE NAME] is the name of your instance you want to set up a bot for and [DEVELOPER KEY] is the key received from CubeCoders.
  • Start your ADS instance again with ampinstmgr start [ADS INSTANCE NAME].

Installing and Enabling the Plugin

  • Edit the AMPConfig.conf file in the root folder of your instance (e.g. /home/amp/.ampdata/instances/INSTANCENAME01/AMPConfig.conf)
  • Under AMP.LoadPlugins add DiscordBotPlugin to the list (e.g. AMP.LoadPlugins=["FileManagerPlugin","EmailSenderPlugin","WebRequestPlugin","LocalFileBackupPlugin","CommonCorePlugin","DiscordBotPlugin"])
  • In the plugins folder for your instance (e.g. /home/amp/.ampdata/instances/INSTANCENAME01/Plugins/) create a new folder called DiscordBotPlugin and insert the .dll file from the current release
  • Restart your instance with ampinstmgr restart [INSTANCE NAME]
  • Log in to your instance and you will see a new menu item under Configuration for the Discord Bot

Menu Item

Configure your Discord Bot

Create the Application

Create the Bot

  • Click Bot on the menu bar along the left, then click Add Bot
  • Give your bot an icon and enable Server Members Intent (this is to ensure that cached member groups are not used if using permissions for controlling servers (start/stop/update/restart/kill)) AND Message Content Intent (this is for writing chat messages back to Minecraft servers if enabled)
  • Save your changes
  • Copy your bot token and paste it in the token field of the Discord Bot menu in AMP

Configure Permissions and Add to your Discord Server

  • Click the OAuth2 option on the left hand menu followed by URL Generator
  • Select bot and applications.commands followed by Send Messages,Manage Messages,Embed Links, and Read Message History
  • Copy the resulting URL and paste into a new browser tab

Tip

The resulting URL will be similar to this, but with your application ID under client_id:

https://discord.com/oauth2/authorize?client_id=12345&permissions=92160&integration_type=0&scope=bot+applications.commands

  • Log in if nedded and add the bot to your Discord server by selecting it in the list
  • If you plan to use pemissions for the server commands, create a new role on your Discord server to use later on.

AMP Menu Settings

Option Description
Discord Bot Token Enter your Discord bot token here
Bot Tagline This is in the footer of the messages from the bot
Server Display Name Name of the server displayed in the info panel
Server Connection URL URL that players can use to join the game server
Server Password If you have a server password that you want your users to see enter it here
Modpack URL This will show as a link in the info panel, useful if you are running a modpack or have a steam workshop collection for the server mods being used
Game Image URL A publicly accessible image to be shown in the info panel
Valid Player Count Set to true if the server has a valid player count, this will determine if the online count is shown in Discord
Bot Activated If the bot should be activated
Bot Refresh Interval How often, in seconds, the bot should update the presence and info message. Recommended minimum 30 seconds otherwise requests to Discord could be throttled
Restrict Functions to Discord Role If server commands (start/stop/restart/kill/update) should be restricted to a Discord Role
Discord Role Name Role name associated with the permissions for the previous setting
Log Button Presses and Commands Toggle if button presses and command use should be logged
Button Log Channel (Name OR ID) Name or ID of the channel to log button presses in. If blank it will be logged to the same channel as the info panel
Post Join and Leave Messages If the bot should post user join and leave events to a Discord channel
Post Join and Leave Messages Channel (Name OR ID) Channel name or ID for the bot to post join and leave events to (only if enabled)
Base Management URL Address to be used to manage instances. Should be in the format of amp.domain.com or your external IP address
Display Start Button Toggle the start button on the info panel
Display Stop Button Toggle the stop button on the info panel
Display Restart Button Toggle the restart button on the info panel
Display Kill Button Toggle the kill button on the info panel
Display Update Button Toggle the update button on the info panel
Display Manage Button Toggle the manage button on the info panel
Display Backup Button Toggle the backup button on the info panel
Display Online Player List Show a list of online players in the info panel (if supported)
Change Displayed Status Change default AMP status text to custom (see here)
Online Server Bot Presence Text Change the presence text when the application is running. Use {OnlinePlayers} and {MaximumPlayers} as variables
Display Playtime Leaderboard Toggle the playtime leaderboard on the info panel
Remove Bot Name Removes the bot name from the base command to allow granular permissions from within the Discord server settings
Additional Embed Field Title Add an additional field in the info panel embed, put your title here
Additional Embed Field Text Add an additional field in the info panel embed, put your content here
Send Chat to Discord Send chat messages to a Discord channel
Chat Discord Channel Discord channel name to send chat messages to (if enabled)
Send Chat from Discord to Server Attempt to send chat messages from Discord chat channel to the server (currently only supported for Minecraft)
Send Console to Discord Send console output to a Discord channel
Console Discord Channel Discord channel name to send console output to (if enabled)
Enable Web Panel Enable the web panel. This will create a html file in a similar format to the Discord info panel for website embeds. Additional steps are required to map the html file to make it accessible. See the Wiki

AMP Discord Bot Colours

The Discord Bot Colours section give you the ability to change the colour of your embedded messages in Discord. For each option you want to change insert the hex colour code required.

AMP Discord Bot Game Specific

The Discord Bot Game Specific section is for game specific settings. These will be added over time as requested.

Option Description
Valheim Join Code Keep track of the Valheim join code in the console output and add it to the info panel accordingly