diff --git a/README.md b/README.md index 9edf241..7e76f4f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ biscuit -### Install (for [node18](https://nodejs.org/en/download/)) +## Install (for [node18](https://nodejs.org/en/download/)) ```sh-session npm install @biscuitland/core @@ -13,7 +13,7 @@ yarn add @biscuitland/core 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 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 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! - Scalable -### Example bot (TS/JS) +## Example bot (TS/JS) ```js -import { Session } from '@biscuitland/core'; +import { ChatInputApplicationCommandBuilder, Session } from '@biscuitland/core'; import { GatewayIntents } from '@biscuitland/api-types'; -const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages; -const session = new Session({ token: 'your token', intents }); +const session = new Session({ token: 'your token', intents: GatewayIntents.Guilds }); -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); + await session.upsertApplicationCommands(commands, 'GUILD_ID'); }); -session.events.on('messageCreate', (message) => { - if (message.content.startsWith('!ping')) { - message.reply({ content: 'pong!' }); +session.events.on('interactionCreate', (interaction) => { + if (interaction.isCommand()) { + if (interaction.commandName === 'ping') { + interaction.respond({ with: { content: 'pong!' } }); + } } }); 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+ - redis cache (wip) - no optimal way to deliver a webspec bun version to the registry (#50) diff --git a/packages/cache/README.md b/packages/cache/README.md index e69de29..f9f35f8 100644 --- a/packages/cache/README.md +++ b/packages/cache/README.md @@ -0,0 +1,11 @@ +# @biscuitland/cache +[](https://github.com/oasisjs/biscuit) +[](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) diff --git a/packages/core/README.md b/packages/core/README.md index e69de29..1127db2 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -0,0 +1,62 @@ +# @biscuitland/core +[](https://github.com/oasisjs/biscuit) +[](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)