It is a simple Discord bot based on CHART-IMG API with serverless Cloudflare Workers. It supports all public TradingView symbols, and the preset symbols can be customized by modifying the file config.json
.
You are welcome to use this bot if you don't want to customize your own. It will always run with the latest version.
Slash Commands are the new, exciting way to interact with bots on Discord. With Slash Commands, all you have to do is type /
and you're ready to use your preset commands.
/invite
/price query
/chart query
You can customize the commands by modifying config.json
.
/price crypto
/price stock
/price forex
/chart query
/chart crypto
/chart stock
/chart forex
- Cloudflare Account for the serverless workers
- CHART-IMG Account for API Key
CHART_IMG_API_KEY
- Discord Developer Portal for
DISCORD_APPLICATION_ID
,DISCORD_PUBLIC_KEY
,DISCORD_TOKEN
To install wrangler, ensure you have npm installed, preferably using a Node version manager like Volta or nvm to avoid permission issues or to easily change Node.js versions, then run:
$ npm install -g wrangler
$ wrangler login
To start, you need to create a discord app through the Discord Developer Dashboard:
-
Click
New Application
, and choose a name -
Copy your
Application ID
andPublic Key
, and put them in the filewrangler.toml
. -
Now click on the
Bot
tab on the left sidebar, and create a bot! You can choose the same name as your app. -
Grab the
token
for your bot, and store it somewhere safe. (For security reasons, you can only view your bot token once. If you misplace your token, you'll have to generate a new one.)
[env.production.vars]
DISCORD_APPLICATION_ID = "YOUR_DISCORD_APPLICATION_ID"
DISCORD_PUBLIC_KEY = "YOUR_DISCORD_PUBLIC_KEY"
Create secret environment variables using wrangler secret.
wrangler secret put DISCORD_TOKEN --env production
$ wrangler secret put DISCORD_TOKEN --env production
⛅️ wrangler 2.0.15
--------------------
Enter a secret value: ****************************************
🌀 Creating the secret for script chart-img-discord-bot-production
✨ Success! Uploaded secret DISCORD_TOKEN
wrangler secret put CHART_IMG_API_KEY --env production
$ wrangler secret put CHART_IMG_API_KEY --env production
⛅️ wrangler 2.0.15
--------------------
Enter a secret value: ****************************************
🌀 Creating the secret for script chart-img-discord-bot-production
✨ Success! Uploaded secret CHART_IMG_API_KEY
Register Discord slash commands.
npm run setup:production
$ npm run setup:production
> cf-chart-img-discord-bot@0.1.0 setup:production
> node src/setup.js --env production
? Enter DISCORD_TOKEN secret value : [input is hidden]
Publish your Cloudflare Worker and get a invoke URL.
npm run deploy:production
$ npm run publish:production
> cf-chart-img-discord-bot@0.1.0 publish:production
> wrangler publish --env production
⛅️ wrangler 2.0.15
--------------------
▲ [WARNING] Enabling node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs.
Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.
Your worker has access to the following bindings:
- Vars:
- DEBUG: "false"
- DISCORD_APPLICATION_ID: "YOUR_DISCORD_APPLICATION_ID"
- DISCORD_PUBLIC_KEY: "YOUR_DISCORD_PUBLIC_KEY..."
Total Upload: 215.95 KiB / gzip: 42.86 KiB
Uploaded chart-img-discord-bot-production (1.85 sec)
Published chart-img-discord-bot-production (0.22 sec)
chart-img-discord-bot-production.YOUR_ID.workers.dev
Set your Interactions Endpoint URL https://chart-img-discord-bot-production.YOUR_ID.workers.dev
from the previous step.