cli icon indicating copy to clipboard operation
cli copied to clipboard

`treehouses message discord` new subcommands using Oauth-Bot/Websockets (fixes #2154)

Open rjpadilla opened this issue 4 years ago • 2 comments

This PR is similar to #2151 but instead of a user-token, a Bot token would be used to access the discord client and webhooks would be used to send messages to your channel.

NOTE: To send a message to your chosen channel, make sure you are the owner of the server and have a webhook integrated to that channel. See https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks for setting up a webhook.

rjpadilla avatar Apr 01 '21 03:04 rjpadilla

When I don't have the client ID, the following commands will return jq errors instead of a custom error handler:

./cli.sh message discord channels "CHAOS SERVER" ./cli.sh message discord send "CHAOS SERVER" "rules" "test"

image

Yah, I should've been more explicit in the instructions that you need a client id set up before using the communication commands. Or I could create an error handler 🤔

rjpadilla avatar Apr 03 '21 02:04 rjpadilla

The script is still buggy, but to send message with the websocket replacement:

  • Run ./cli.sh message discord apitoken <your bot token>
  • Run ./cli.sh message discord authorize <your client id>
  • Run ./cli.sh message discord ws <- to enable sending messages (this is not a feature; will be refactored later)

Then the rest of the commands are the same from the discord apitoken branch.

rjpadilla avatar Apr 08 '21 00:04 rjpadilla