cameroncros / OctoPrint-DiscordRemote

Discord plugin for OctoPrint
MIT License
66 stars 34 forks source link

OctoPrint-DiscordRemote

DiscordRemote is a plugin allowing Octoprint to send notifications to a Discord channel. The plugin connects to a DiscordShim which manages the actual discord interactions.

There is an existing DiscordShim that is already setup, or users may create and use their own DiscordShim instance.

This is forked from https://github.com/bchanudet/OctoPrint-Octorant.

Note, using this plug-in requires either:

License : MIT

Credits

Benjamin Chanudet for their initial plugin, which this is based on.

OctopusProteins for their work on the enclosure plugin, file upload capabilities and presence updates.

megasaturnv for their assistance with configuring the access settings.

goscicki for their help testing the /gcode capability.

timothy-b for their help fixing the help command handling.

wchill for the custom embed in notification change.

SgtKiLLx for various typo fixes.

Zinc-OS for adding Raspberry Pi throttling status to the status message.

Stwend for adding split zip support, to get around the 8mb discord limit.

Mary for preventing the bot replying to other bots, and avoiding downloading non-gcode/zip files.

Milo Mirate for adding ETA to status.

jneilliii for Print Scheduler support.

grantrules for fixing presence.

MrFrickinFixit for assisting with debugging the network issues in v5.0

Changelog

See the release history to get a quick summary of what's new in the latest versions.

Setup

Install the plugin

Install via the bundled Plugin Manager or manually using this URL:

https://github.com/cameroncros/OctoPrint-DiscordRemote/archive/master.zip

Tips

API

There are currently 2 API's available for interacting with the bot. These can be used by sending a POST request to [octoprint_url]/api/plugin/discordremote, with JSON in the body of the request.

Send command

This API lets you send a command as if you typed it in discord. The response will be sent to discord. The JSON format is:

{
    "command": "executeCommand",
    "args": "COMMAND GOES HERE"
}

Send message

This API lets you send a message directly to discord. The JSON format is:

{
    "command": "sendMessage",
    "title": "TITLE GOES HERE",
    "description": "DESCRIPTION GOES HERE",
    "color": 0x123456,
    "image": "BASE64 ENCODED FILE DATA HERE",
    "imagename": "IMAGE NAME GOES HERE"
}

Commands

To get a list of available commands and arguments, type /help into the discord channel. The bot will return all available commands. Commands can also be sent via the web interface, by clicking the button in the top panel that looks like a game controller. Files can be uploaded to the discord channel directly, and they will be downloaded into OctoPrint automatically. You can use the /unzip command to manage zip files.

Configuration

The plugin can be configured in the configuration panel, under the "DiscordRemote" panel.

Discord Settings

In order for you to be sure these settings work, every time you change one of them, a test message will be sent to the corresponding Discord Channel. If you don't receive it, something is most likely wrong!

Access Settings

The access settings allow specific commands to be limited to specific users.

If the current command and user combination matches any of the rules, it will be executed. If additional rules are required, manually editing the config will be required.

Message Settings

Here you can customize every message handled by DiscordRemote.

Message format

Messages are regular Discord messages, which means you can use :

Some events also support variables, here is a basic list : Common :

Printing process : started event :

Printing process : failed event :

Printing process : done event :

Printing process : failed event :

Printing process : paused event :

Printing process : resumed event :

Printing progress event :

Printer state : error

For more reference, you can go to the Octoprint documentation on Events

Issues and Help

If you encounter any trouble don't hesitate to open an issue. I'll gladly do my best to help you setup this plugin.