Code Monkey home page Code Monkey logo

discord-slash-commands's Introduction

Discord Slash Command

This is a discord bot for RealDevSquad discord server capable of using slash commands.

The bot is written in TypeScript and will be hosted on cloudflare workers. Cloudflare workers provide us with a serverless environment to run our code.

In case you are thinking of using any NPM package on it please check if it is compatible with the Cloudflare workers. You can do so by visiting the following link: https://workers.cloudflare.com/works

To get an example and look at runtime apis for cloudflare workers you can go to: https://developers.cloudflare.com/workers/runtime-apis

To start the server use

npm start

This will start your server on localhost:8787

To connect this to your own bot you need a https end point. To get a https endpoint that redirects all the traffic to your localhost, we are using ngrok

To start this, run the command

npm run ngrok

You can not commit your changes unless it satisfies the required format. To check the formatting of the file run

npm run format-check

To check the linting issues use

npm run lint-check

To fix the formatting issue use

npm run format-fix

We are using itty-router over here which is a light weight router designed for cloudflare workers. In case you are interested in it you could read more about it here:

We need few environment variables for this project to work, they are as follows:

DISCORD_TOKEN: The token generated for your bot while creating a discord application
DISCORD_PUBLIC_KEY: Public key of your Discord bot helps to verify the bot and apply interaction url
DISCORD_APPLICATION_ID: The application id of your bot.
DISCORD_GUILD_ID: Id of the guild where you want to install the slash commands.

To add more commands you need to modify following files:

- src/constants/commands.ts (Export your commands as a constant)
- src/register.ts (import the newly added command here and assign it to the commands array)
- now run `npm run register`

discord-slash-commands's People

Contributors

ritikjaiswal75 avatar shreya-mishra avatar fakhruddinkw avatar dashdeipayan avatar prakashchoudhary07 avatar sahsisunny avatar ankushdharkar avatar bksh05 avatar j24m avatar ajeyakrishna-k avatar samyakshah3008 avatar iamitprakash avatar vinit717 avatar rohan09-raj avatar vvaibhavdesai avatar anishpawaskar avatar bhtibrewal avatar khushi818 avatar lakshayman avatar nashitshayan avatar vinayak-trivedi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.