{"_id":"@clemens_e/shori","_rev":"1-91840afeed3b0efc59372ed643d2c7fa","name":"@clemens_e/shori","dist-tags":{"latest":"1.0.16"},"versions":{"1.0.16":{"name":"@clemens_e/shori","version":"1.0.16","description":"Simple Typescript discord.js framework","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","build-watch":"tsc -w","generate-barrels":"barrelsby --delete -d ./src"},"author":{"name":"Clemens-E"},"license":"ISC","dependencies":{"discord.js":"^12.0.2","readdirp":"^3.3.0","reflect-metadata":"^0.1.13","rxjs":"^6.5.4","tsyringe":"^4.1.0"},"devDependencies":{"@types/reflect-metadata":"^0.1.0","@types/node":"^13.1.2","@types/ws":"^6.0.4","@typescript-eslint/eslint-plugin":"^2.14.0","@typescript-eslint/parser":"^2.14.0","barrelsby":"^2.2.0","eslint":"^6.8.0","typescript":"^3.7.4"},"repository":{"type":"git","url":"git+https://github.com/Clemens-E/shori.git"},"bugs":{"url":"https://github.com/Clemens-E/shori/issues"},"homepage":"https://github.com/Clemens-E/shori#readme","gitHead":"b4bb20cebff1cda7eacddb1fe996f3d77e4e5c16","_id":"@clemens_e/shori@1.0.16","_nodeVersion":"12.2.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-n2iQt8qEGuoVw9TklV04v1l1OJyzdytE5q35cg+1Y/ggJ2+yuaIS4x7fN2WS6zxWm3yyWCr4WR/a6tSJy9OesA==","shasum":"eb65cf36e47ddd6c1142ff9795f0fa3661200ea7","tarball":"https://registry.npmjs.org/@clemens_e/shori/-/shori-1.0.16.tgz","fileCount":80,"unpackedSize":51196,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJenyfsCRA9TVsSAnZWagAAx7sP/RbJdNWJ6lzBDH0YbThY\nKNSqFzBRMbcW1ZKvuqYvkCZ+Y1+WpR8ei/6YMZ8FkRgpDqTzrAg3YDfIMAOE\ngvGPHj3VaUi6qstFdKeWw/0X0ft1gGhbi4QHa5EiApsfllbjpv+J6JbveJvq\nKw5gJvU0u7/x0FUe6pSvFp9sSxBNle77DYPfbfEHltczgPWwpDHnUUU4p+R5\n7RfllSupFroyb7/tWVZGqgtGWKbW2IRBSUA7ISvvUwHiZR7twvelTJstGI1t\nPYFcNfU9NVMjY1ef5dRf4JgzUn9QlsHKCvuEGr0dUGOcI7FYoQTTi2hK19Lt\nIUbnDGc7q0KvnV64RmmuiKZbGEqrsov9K97nL19sQZRa36YQypM6tCo6QutA\nPD9izs1iKOTNMq43S9So7TmjRPGLht5L4H/3sUGKkIAhKjHYS5oBGTFaKaYf\n4AgZ9JzPsZ3j1ldA+u0RdU9GM8VFH4pUgU7VE77WDm91La/h6bAelj3ONlAf\nlANYAPi8yT6ft86Qf6Lmjt05WHoIUCW3ULAgMCficxjzp15XxEyRIsYzcn/D\n31z+HoTyYAUzHmc3rAfictpmRBKRrfWa8jNPMCRaa3RalbTQmhYFDpVG9Dlj\nlUsfkpKszEhrkUk5n7WsWH4OJUsE7u8U5UdaFSTotRYBJ/t/ff7yhKMva0wr\n5SSX\r\n=fjib\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDHDPzS5C49OBMXKg80vQLhfur5RBD7ox4y0kScXkreWgIgCNru9196ASKpP+q7gjN+zc2VI20wL4j4PgucWKDfhyo="}]},"maintainers":[{"name":"clemens_e","email":"clemensertle@gmail.com"}],"_npmUser":{"name":"clemens_e","email":"clemensertle@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/shori_1.0.16_1587488748069_0.2840296665294031"},"_hasShrinkwrap":false}},"time":{"created":"2020-04-21T17:05:48.023Z","1.0.16":"2020-04-21T17:05:48.230Z","modified":"2022-04-04T23:16:19.606Z"},"maintainers":[{"name":"clemens_e","email":"clemensertle@gmail.com"}],"description":"Simple Typescript discord.js framework","homepage":"https://github.com/Clemens-E/shori#readme","repository":{"type":"git","url":"git+https://github.com/Clemens-E/shori.git"},"author":{"name":"Clemens-E"},"bugs":{"url":"https://github.com/Clemens-E/shori/issues"},"license":"ISC","readme":"## Shori\nSimple Typescript discord.js framework providing decorators and DI\n\n---\n\n### Should I use this?\n\nprobably not.\n\n### Usage\n\nStart by extending the ShoriClient, like this:\n\n``` ts\nclass ExampleClient extends ShoriClient {\n\n  constructor(shoriOptions: ShoriOptions, clientOptions: ClientOptions) {\n    super(shoriOptions, clientOptions);\n  }\n\n  public getPrefix(id: string): Promise<string> {\n    // should make a database request here\n    // returning undefined will make it use the default prefix\n    return undefined;\n  }\n  \n}\n```\n\n#### Commands\n\nCommands have to extend the `CommandBase` class and have the `Command` Decorator\n\n``` ts\n@Command('test')\nclass TestCommand extends CommandBase {\n\n  // shori provide dependency injection with tsyringe\n  // on how to provide a service, read down below in the Service chapter\n  constructor(private fileService: FileService) {super();}\n\n  public async exec(message: Message, args: string[]): Promise<any> {\n    message.reply( `hi, this works. My Prefix: ${this.client.prefix}` );\n  }\n\n}\n```\n\n### Services\n\nA Service is a class that provides methods and actions for your project, for example a class that provides methods to interact with the filesystem, you dont want that logic inside your commands.\n\n``` ts\n@Service()\nexport class FileService {\n\n  public async init(): Promise<void> {\n    // run things that your service needs to fully work,\n    // this method will be called and awaited before the client starts\n    // e.g. creating database connections, ensuring folders etc...\n    await this.doStuff();\n  }\n  \n}\n```\n\nThe `@Service()` decorator will make the class a singleton, and thus can be injected into commands (or any other knows class in the shori context)\n\nIts important to know that every Service *must* be provided in the service array in the shori client options.\n\nshori will then call every services init method and wait for its Promise to resolve before the client starts the connection to discord\n\n#### Events\n\nEvents simply have to be decorated with an `Event` Decorator\n\n``` ts\nimport {Client, Event} from 'shori';\n\nexport class SomeClass {\n\n  // shori will inject the client  \n  @Client() \n  private client: ExampleClient\n\n  @Event('ready')\n  ready(): void {\n    console.log('client is ready');\n    console.log(this.client.channels.size);\n  }\n\n}\n```\n\n**Warning:** \\\nshori will register every class you use `@Command` , `@Event` or `@Service` on as a singleton, do not create instances yourself, \nbut use DI or container.resolve from tsyringe\n\n","readmeFilename":"README.md"}