No description
This repository has been archived on 2026-04-12. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • TypeScript 99%
  • PowerShell 1%
Find a file
2021-01-31 12:00:15 +09:00
.vscode feat: format 2021-01-24 22:58:46 +09:00
src feat: sudo bypass 2021-01-30 12:36:19 +09:00
test feat: su command 2021-01-31 12:00:15 +09:00
.gitignore feat: init typescript project and basic bot 2021-01-22 20:47:10 +09:00
.npmignore feat: readme 2021-01-26 10:46:13 +09:00
.prettierrc feat: remove semicolon 2021-01-22 20:57:52 +09:00
package.json feat: install node-fetch & change unload class name 2021-01-30 12:22:51 +09:00
README.md fix: readme 2021-01-27 13:38:43 +09:00
tsconfig.json feat: something 2021-01-29 09:34:42 +09:00
yarn.lock feat: install node-fetch & change unload class name 2021-01-30 12:22:51 +09:00

COMMAND.TS

타입스크립트로 작성된 discord.js 커맨드 프레임워크입니다.

설치

npm i discord.js reflect-metadata @pikostudio/command.ts

설정

tsconfig.json

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "skipLibCheck": true
  }
}

index.ts

import 'reflect-metadata'
import { CommandClient } from '@pikostudio/command.ts'

const client = new CommandClient({
  currentDir: __dirname,
  commandHandler: {
    prefix: '!',
  },
  watch: true,
  // auto로 설정시 자동으로 애플리케이션에서 가져옵니다.
  owners: 'auto',
})

client.loadExtensions('extensions/test')

client.login('token')

extensions/test.ts

import { Arg, Command, Extension, Listener, Msg } from '@pikostudio/command.ts'
import { Message } from 'discord.js'

export default class Test extends Extension {
  @Command()
  say(
    @Msg() msg: Message, // 메시지 받기
    @Arg({ required: true, rest: true }) content: string, // 인자 받기
    // + 인자는 순서대로 받습니다. rest를 사용하려면 꼭 마지막 인자로 사용해주세요
  ) {
    return msg.reply(content)
  }

  // 로드 이벤트
  load() {}

  // 언로드 이벤트

  unload() {}

  // 명령어 사용시 실행됩니다. 반환된 값이 false일시 명령어 사용을 중지합니다.
  /*async*/ permit(/* message */) {
    return true
  }

  @Listener('ready') // 리스너
  async ready() {
    console.log('bot ready!')
  }
}