Update docs (#84)

* Update core README

* Update cache README

* Update README

* Update README

* Fix example & add links

* Add links
This commit is contained in:
Nicolas 2022-07-31 02:36:11 -03:00 committed by GitHub
parent a793b528a0
commit a560f5f5f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 100 additions and 12 deletions

View File

@ -4,7 +4,7 @@
<img align="right" src="https://raw.githubusercontent.com/oasisjs/biscuit/main/assets/icon.svg" alt="biscuit"/> <img align="right" src="https://raw.githubusercontent.com/oasisjs/biscuit/main/assets/icon.svg" alt="biscuit"/>
### Install (for [node18](https://nodejs.org/en/download/)) ## Install (for [node18](https://nodejs.org/en/download/))
```sh-session ```sh-session
npm install @biscuitland/core npm install @biscuitland/core
@ -13,7 +13,7 @@ yarn add @biscuitland/core
for further reading join our [Discord](https://discord.gg/zmuvzzEFz2) for further reading join our [Discord](https://discord.gg/zmuvzzEFz2)
### Most importantly, biscuit is: ## Most importantly, biscuit is:
- A wrapper to interface the Discord API - A wrapper to interface the Discord API
- A bleeding edge library - A bleeding edge library
@ -21,34 +21,49 @@ for further reading join our [Discord](https://discord.gg/zmuvzzEFz2)
Biscuit is primarily inspired by Discord.js and Discordeno but it does not include a cache layer by default, we believe Biscuit is primarily inspired by Discord.js and Discordeno but it does not include a cache layer by default, we believe
that you should not make software that does things it is not supposed to do. that you should not make software that does things it is not supposed to do.
### Why biscuit?: ## Why biscuit?:
- [Minimal](https://en.wikipedia.org/wiki/Unix_philosophy), non feature-rich! - [Minimal](https://en.wikipedia.org/wiki/Unix_philosophy), non feature-rich!
- Scalable - Scalable
### Example bot (TS/JS) ## Example bot (TS/JS)
```js ```js
import { Session } from '@biscuitland/core'; import { ChatInputApplicationCommandBuilder, Session } from '@biscuitland/core';
import { GatewayIntents } from '@biscuitland/api-types'; import { GatewayIntents } from '@biscuitland/api-types';
const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages; const session = new Session({ token: 'your token', intents: GatewayIntents.Guilds });
const session = new Session({ token: 'your token', intents });
session.events.on('ready', ({ user }) => { const commands = [
new ChatInputApplicationCommandBuilder()
.setName('ping')
.setDescription('Replys with pong!')
.toJSON(),
]
session.events.on('ready', async ({ user }) => {
console.log('Logged in as:', user.username); console.log('Logged in as:', user.username);
await session.upsertApplicationCommands(commands, 'GUILD_ID');
}); });
session.events.on('messageCreate', (message) => { session.events.on('interactionCreate', (interaction) => {
if (message.content.startsWith('!ping')) { if (interaction.isCommand()) {
message.reply({ content: 'pong!' }); if (interaction.commandName === 'ping') {
interaction.respond({ with: { content: 'pong!' } });
}
} }
}); });
session.start(); session.start();
``` ```
### Known issues: ## Links
* [Website](https://biscuitjs.com/)
* [Documentation](https://docs.biscuitjs.com/)
* [Discord](https://discord.gg/evqgTQYqn7)
* [core](https://www.npmjs.com/package/@biscuitland/core) | [api-types](https://www.npmjs.com/package/@biscuitland/api-types) | [cache](https://www.npmjs.com/package/@biscuitland/cache) | [rest](https://www.npmjs.com/package/@biscuitland/rest) | [ws](https://www.npmjs.com/package/@biscuitland/ws)
## Known issues:
- node18 is required to run the library, however --experimental-fetch flag should work on node16+ - node18 is required to run the library, however --experimental-fetch flag should work on node16+
- redis cache (wip) - redis cache (wip)
- no optimal way to deliver a webspec bun version to the registry (#50) - no optimal way to deliver a webspec bun version to the registry (#50)

View File

@ -0,0 +1,11 @@
# @biscuitland/cache
[<img src="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white">](https://github.com/oasisjs/biscuit)
[<img src="https://img.shields.io/badge/Discord-5865F2?style=for-the-badge&logo=discord&logoColor=white">](https://discord.gg/KfNW3CpRfJ)
Structures to create a custom cache completely decoupled from the rest of the library. You can choose to use a `MemoryCacheAdapter` or a `RedisCacheAdapter` according to your needs.
## Links
* [Website](https://biscuitjs.com/)
* [Documentation](https://docs.biscuitjs.com/)
* [Discord](https://discord.gg/evqgTQYqn7)
* [core](https://www.npmjs.com/package/@biscuitland/core) | [api-types](https://www.npmjs.com/package/@biscuitland/api-types) | [cache](https://www.npmjs.com/package/@biscuitland/cache) | [rest](https://www.npmjs.com/package/@biscuitland/rest) | [ws](https://www.npmjs.com/package/@biscuitland/ws)

View File

@ -0,0 +1,62 @@
# @biscuitland/core
[<img src="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white">](https://github.com/oasisjs/biscuit)
[<img src="https://img.shields.io/badge/Discord-5865F2?style=for-the-badge&logo=discord&logoColor=white">](https://discord.gg/KfNW3CpRfJ)
Classes, functions and main structures to create an application with biscuit. Core contains the essentials to launch you to develop your own customized and scalable bot.
## Getting Started
### Install (for [node18](https://nodejs.org/en/download/))
```sh-session
npm install @biscuitland/core
yarn add @biscuitland/core
```
### Example bot
`project/index.js`:
```js
import { ChatInputApplicationCommandBuilder, Session } from '@biscuitland/core';
import { GatewayIntents } from '@biscuitland/api-types';
const session = new Session({ token: 'your token', intents: GatewayIntents.Guilds });
const commands = [
new ChatInputApplicationCommandBuilder()
.setName('ping')
.setDescription('Replys with pong!')
.toJSON(),
]
session.events.on('ready', async ({ user }) => {
console.log('Logged in as:', user.username);
await session.upsertApplicationCommands(commands, 'GUILD_ID');
});
session.events.on('interactionCreate', (interaction) => {
if (interaction.isCommand()) {
if (interaction.commandName === 'ping') {
interaction.respond({ with: { content: 'pong!' } });
}
}
});
session.start();
```
### Execute
For node 18.+:
```
B:\project> node index.js
```
For node 16.+:
```
B:\project> node --experimenta-fetch index.js
```
## Links
* [Website](https://biscuitjs.com/)
* [Documentation](https://docs.biscuitjs.com/)
* [Discord](https://discord.gg/evqgTQYqn7)
* [core](https://www.npmjs.com/package/@biscuitland/core) | [api-types](https://www.npmjs.com/package/@biscuitland/api-types) | [cache](https://www.npmjs.com/package/@biscuitland/cache) | [rest](https://www.npmjs.com/package/@biscuitland/rest) | [ws](https://www.npmjs.com/package/@biscuitland/ws)