Giter Club home page Giter Club logo

discord.ts-example's Introduction

⚠️ Moved to discordx-templates

Contact Details

GitHub: https://github.com/oceanroleplay

Email: [email protected]

Discord: Harry#5791

Discord Server: https://discord-ts.js.org/discord


Discord server NPM version NPM downloads Build status paypal

Create a discord bot with TypeScript and Decorators!

Content

Demo

CodeSandbox

Installation

Clone Repository

git clone https://github.com/oceanroleplay/discord.ts-example

Enter bot directory

cd discord.ts-example

Install Dependencies

npm install

Build your bot

npm run build

Set your bot token

For windows user only

# For command prompt
set BOT_TOKEN=REPLACE_THIS_WITH_YOUR_BOT_TOKEN

# For powershell
$ENV:BOT_TOKEN="REPLACE_THIS_WITH_YOUR_BOT_TOKEN"

For linux user only

export BOT_TOKEN=REPLACE_THIS_WITH_YOUR_BOT_TOKEN

Start your bot

npm run serve

you are done, you will see your bot up and running. For detailed installation guide, please see this

Use global command only

This repository uses guild commands instead of global commands by default. This is because global command needs approximately 15 minutes to update itself every time.

1. How do I use global command only?

2. How do I make specific guild command?

Use CommonJS

This repo is targeted to use ECMAScript modules by default. Follow these steps to use CommonJS.

Update package.json

{
  // ...
  "type": "commonjs",
  // ...
  "scripts": {
    "build": "tsc",
    "dev": "ts-node src/main.ts",
    "start": "nodemon --exec ts-node src/main.ts",
    "serve": "node build/main.js"
  }
  // ...
}

Update tsconfig.json

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "CommonJS"
    // ...
  }
}

Update main.ts

async function run() {
  // with cjs
  await importx(__dirname + "/{events,commands}/**/*.{ts,js}");
  // with ems
  // await importx(dirname(import.meta.url) + "/{events,commands}/**/*.{ts,js}");
  client.login(process.env.BOT_TOKEN ?? ""); // provide your bot token
}

Remove rest api server

There are only a few lines of basic code, which you need to either comment out or remove to disable the API server

  1. Delete the api folder from the src folder
  2. Remove api reference from importx path in main.ts#L57
  3. Comment out or remove the code from main.ts#L5 and main.ts#L66 - main.ts#L81
  4. Run npm uninstall koa @koa/router @discordx/koa @types/koa @types/koa__router

The API server has been removed from the discord bot

☎️ Need help?

Ask in discord server or open a issue

Thank you

Show your support for discordx by giving us a star on github.

discord.ts-example's People

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.