Skip to content

luisfun/discord-bot-cloudflare-ai-challenge

Repository files navigation

Discord Bot with Cloudflare AI

👉 Demo

Fork, Clone, Install, Dev

Fork and Clone

cd discord-bot-cloudflare-ai-challenge
npm i
npm run dev

Setup AI Gateway

Creat AI Gateway

Get API Endpoint
AI Gateway > AI Paint API Endpoint > Select Workers AI

Set Caching and Rate-limiting
AI Gateway

Creat API Token
Select template Workers AI

npx wrangler secret put Endpoint
npx wrangler secret put Token

Setup Discord bot

Create a New Application from Dashboard.
Copy your APPLICATION ID, PUBLIC KEY and TOKEN, and put them .dev.vars file.

Storing secrets.

npx wrangler secret put DISCORD_APPLICATION_ID
npx wrangler secret put DISCORD_PUBLIC_KEY
npx wrangler secret put DISCORD_TOKEN

Register commands and Deploy.

npm run register
npm run deploy

Enter https://YOUER_PROJECT.YOUER_DOMAIN.workers.dev in the INTERACTIONS ENDPOINT URL.

Create an invite URL from Dashboard.
YOUR_APP > OAuth2 tab > OAuth2 URL Generator > Check SCOPES: bot > URL Copy
Paste the URL into the browser.