A guide on how to get started with cloudflare workers and yor.ts
This guide provides a basic outline to set up a Discord bot and integrate it with Cloudflare Workers. Further details and code specifics for each step will be needed based on your specific requirements and programming language preferences.
Creating Discord Application
Creating a Discord Bot and Obtaining Credentials
Inviting Bot to Server
Creating a new project
npm init
/yarn init
/pnpm init
to initialize a package.jsonnpm install yor.ts@latest
/yarn add yor.ts@latest
/pnpm install yor.ts@latest
to install yor.tsDownloading cloudflare workers cli
Run npm install -g wrangler
/yarn global add wrangler
/pnpm add -g wrangler
to install the cli
Run wrangler login
to login to your cloudflare account
Run wrangler init
to create a new project
Put the following in wrangler.toml
:
Creating src/index.ts
src/index.ts
:Esbuild and polyfill
Install esbuild and esbuild-plugin-node-polyfill: Run npm install --save-dev esbuild esbuild-plugin-node-polyfill
or yarn add --dev esbuild esbuild-plugin-node-polyfill
or pnpm add --save-dev esbuild esbuild-plugin-node-polyfill
to install these packages as dev dependencies.
Update the package.json file: Add the following scripts to the scripts section of your package.json file:
Create build.js.
Add the following to the build.js config file:
Running the project
npm run build
or yarn build
or pnpm build
to build the projectwrangler deploy
to deploy your projectTesting the bot
Testing to see if it works
/ping
A guide on how to get started with cloudflare workers and yor.ts
This guide provides a basic outline to set up a Discord bot and integrate it with Cloudflare Workers. Further details and code specifics for each step will be needed based on your specific requirements and programming language preferences.
Creating Discord Application
Creating a Discord Bot and Obtaining Credentials
Inviting Bot to Server
Creating a new project
npm init
/yarn init
/pnpm init
to initialize a package.jsonnpm install yor.ts@latest
/yarn add yor.ts@latest
/pnpm install yor.ts@latest
to install yor.tsDownloading cloudflare workers cli
Run npm install -g wrangler
/yarn global add wrangler
/pnpm add -g wrangler
to install the cli
Run wrangler login
to login to your cloudflare account
Run wrangler init
to create a new project
Put the following in wrangler.toml
:
Creating src/index.ts
src/index.ts
:Esbuild and polyfill
Install esbuild and esbuild-plugin-node-polyfill: Run npm install --save-dev esbuild esbuild-plugin-node-polyfill
or yarn add --dev esbuild esbuild-plugin-node-polyfill
or pnpm add --save-dev esbuild esbuild-plugin-node-polyfill
to install these packages as dev dependencies.
Update the package.json file: Add the following scripts to the scripts section of your package.json file:
Create build.js.
Add the following to the build.js config file:
Running the project
npm run build
or yarn build
or pnpm build
to build the projectwrangler deploy
to deploy your projectTesting the bot
Testing to see if it works
/ping