Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luckyyang/ckb-nft-guild-bot
https://github.com/luckyyang/ckb-nft-guild-bot
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/luckyyang/ckb-nft-guild-bot
- Owner: luckyyang
- Created: 2022-02-16T04:22:35.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-06T01:47:39.000Z (over 1 year ago)
- Last Synced: 2024-10-14T02:15:02.620Z (about 1 month ago)
- Language: TypeScript
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Content
- [Demo](#demo)
- [Installation](#installation)
- [Use global command only](#use-global-command-only)
- [Use CommonJS](#use-commonjs)
- [Remove rest api server](#remove-rest-api-server)# Demo
[CodeSandbox](https://codesandbox.io/s/github/oceanroleplay/discord.ts-example)
# Installation
**Clone Repository**
```bash
git clone https://github.com/oceanroleplay/discord.ts-example
```**Enter bot directory**
```bash
cd discord.ts-example
```**Install Dependencies**
```bash
npm install
```**Build your bot**
```bash
npm run build
```**Set your bot token**
For windows user only
```bash
# For command prompt
set BOT_TOKEN=REPLACE_THIS_WITH_YOUR_TOKEN# For powershell
$env:BOT_TOKENS = "REPLACE_THIS_WITH_YOUR_TOKEN"
```For linux user only
```bash
export BOT_TOKEN=REPLACE_THIS_WITH_YOUR_TOKEN
```**Start your bot**
```bash
npm run serve
```you are done, you will see your bot up and running. For detailed installation guide, please [see this](https://oceanroleplay.github.io/discord.ts/docs/installation)
# 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?
### comment [this line in main.ts](https://github.com/oceanroleplay/discord.ts-example/blob/main/src/main.ts#L18)
## 2. How do I make specific guild command?
### use [@Guild](https://discord-ts.js.org/docs/decorators/general/guild) decorator on [@Slash](https://discord-ts.js.org/docs/decorators/commands/slash), [check more information](https://discord-ts.js.org/docs/decorators/general/guild)
# Use CommonJS
This repo is targed to use ECMAScript modules by default. Follow these steps to use CommonJS.
## Update package.json
```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
```json
{
"compilerOptions": {
"target": "ESNext",
"module": "CommonJS"
// ...
}
}
```## Update main.ts
```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](https://github.com/oceanroleplay/discord.ts-example/tree/main/src)
1. Remove api reference from importx path in [main.ts#L57](https://github.com/oceanroleplay/discord.ts-example/blob/main/src/main.ts#L57)
1. Comment out or remove the code from [main.ts#L5](https://github.com/oceanroleplay/discord.ts-example/blob/main/src/main.ts#L5) and [main.ts#L66](https://github.com/oceanroleplay/discord.ts-example/blob/main/src/main.ts#L66) - [main.ts#L81](https://github.com/oceanroleplay/discord.ts-example/blob/main/src/main.ts#L81)
1. 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](https://discord.gg/yHQY9fexH9)** or open a **[issue](https://github.com/oceanroleplay/discord.ts-example/issues)**
# Thank you
Show your support for [discordx](https://www.npmjs.com/package/discordx) by giving us a star on [github](https://github.com/oceanroleplay/discord.ts).