Discord bot using python errbot

1 Install errbot with pyenv

pip install cryptography

pip install cryptography --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include" # Mac OSX

pip install cffi

pip install errbot

2 Install discord for errbot


$ git clone https://github.com/gbin/err-backend-discord.git

$ pip install discord

and add:

BACKEND = 'Discord'
BOT_EXTRA_BACKEND_DIR = '/path_to/err-backend-discord'

Authentication

Create an application, then a bot user and you can directly use the token of the bot user in your config.py

BOT_IDENTITY = {
    'token': 'changeme'
}

Use “Generate OAuth2 URL” tool in app page to generate URL and access URL in browser.

3 discord api for commandline

POST /channels/{channel.id}/messages

Before using this endpoint, you must connect to and identify with a gateway at least once.

Post a message to a guild text or DM channel. If operating on a guild channel, this endpoint requires the ‘SEND_MESSAGES’ permission to be present on the current user. Does your bot have the ‘SEND_MESSAGES’ permission in that channel?

no? well goto the channel settings and give it permission.

Has your bot connected and identified with the gateway at least once?

no? well you should probably go do that, best to use a library already made for it.

If this issue still persists despite attempting the solutions above perhaps you are malforming your POST request somehow.


© 2015-2020 tendant