mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
chore: fixes update
This commit is contained in:
parent
f977c1c120
commit
35e85ba628
41
README.md
41
README.md
@ -28,37 +28,34 @@ The Proxy object enables dynamic, flexible and efficient calls to the API, it is
|
||||
|
||||
## Example bot (TS/JS)
|
||||
|
||||
```js
|
||||
```ts
|
||||
import { Session } from '@biscuitland/core';
|
||||
import { GatewayIntentBits, InteractionType, InteractionResponseType } from '@biscuitland/common';
|
||||
|
||||
const session = new Session({
|
||||
intents: GatewayIntentBits.Guilds,
|
||||
token: 'your token goes here'
|
||||
intents: GatewayIntentBits.Guilds,
|
||||
token: 'your token goes here'
|
||||
});
|
||||
|
||||
const commands = [{
|
||||
const commands = [
|
||||
{
|
||||
name: 'ping',
|
||||
description: 'Replies with pong!'
|
||||
}];
|
||||
}
|
||||
];
|
||||
|
||||
session.on('READY', (payload) => {
|
||||
const username = payload.user.username;
|
||||
console.log('I\'m ready! logged in as %s', username);
|
||||
|
||||
const [shardId, _shardCount] = payload.shard ?? [0, 0];
|
||||
|
||||
if (shardId === 0) session.managers.application.bulkCommands(session.applicationId!, commands);
|
||||
session.once('READY', (payload) => {
|
||||
const username = payload.user.username;
|
||||
console.log('Logged in as: %s', username);
|
||||
session.managers.applications.bulkCommands(session.applicationId, commands);
|
||||
});
|
||||
|
||||
session.on('INTERACTION_CREATE', (interaction) => {
|
||||
if (interaction.type !== InteractionType.ApplicationCommand) return;
|
||||
session.managers.interaction.reply(interaction.id, interaction.token, {
|
||||
body: {
|
||||
type: InteractionResponseType.ChannelMessageWithSource,
|
||||
data: { content: 'pong!' }
|
||||
}
|
||||
});
|
||||
if (interaction.type !== InteractionType.ApplicationCommand) return;
|
||||
session.managers.interactions.reply(interaction.id, interaction.token, {
|
||||
type: InteractionResponseType.ChannelMessageWithSource,
|
||||
data: { content: 'pong!' }
|
||||
});
|
||||
});
|
||||
|
||||
session.start();
|
||||
@ -68,8 +65,4 @@ session.start();
|
||||
* [Website](https://biscuitjs.com/)
|
||||
* [Documentation](https://docs.biscuitjs.com/)
|
||||
* [Discord](https://discord.gg/XNw2RZFzaP)
|
||||
* [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) | [helpers](https://www.npmjs.com/package/@biscuitland/helpers)
|
||||
|
||||
## Known issues:
|
||||
- node18 is required to run the library, however --experimental-fetch flag should work on node16+
|
||||
- no optimal way to deliver a webspec bun version to the registry (#50)
|
||||
* [core](https://www.npmjs.com/package/@biscuitland/core) | [rest](https://www.npmjs.com/package/@biscuitland/rest) | [ws](https://www.npmjs.com/package/@biscuitland/ws) | [helpers](https://www.npmjs.com/package/@biscuitland/helpers)
|
||||
|
@ -15,14 +15,14 @@ yarn add @biscuitland/core
|
||||
|
||||
### Example bot
|
||||
`project/index.js`:
|
||||
```js
|
||||
```ts
|
||||
import { Session } from '@biscuitland/core';
|
||||
import { GatewayIntentBits } from "discord-api-types/v10";
|
||||
import { GatewayIntentBits } from '@biscuitland/common';
|
||||
|
||||
const session = new Session({ token: 'your token', intents: GatewayIntentBits.Guilds });
|
||||
|
||||
session.events.on('READY', (payload) => {
|
||||
console.log('Logged in as:', payload.user.username);
|
||||
session.on('READY', (payload, shardId) => {
|
||||
console.log('Logged in as: %s in shard #%s', payload.user.username, shardId);
|
||||
});
|
||||
|
||||
session.start();
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@biscuitland/core",
|
||||
"version": "3.0.2",
|
||||
"version": "3.0.3",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
|
@ -13,16 +13,16 @@ export class MainManager {
|
||||
this.guilds = new GuildManager(this.session);
|
||||
this.members = new MemberManager(this.session);
|
||||
this.channels = new ChannelManager(this.session);
|
||||
this.application = new ApplicationManager(this.session);
|
||||
this.interaction = new InteractionManager(this.session);
|
||||
this.webhook = new WebhookManager(this.session);
|
||||
this.applications = new ApplicationManager(this.session);
|
||||
this.interactions = new InteractionManager(this.session);
|
||||
this.webhooks = new WebhookManager(this.session);
|
||||
}
|
||||
|
||||
users: UserManager;
|
||||
guilds: GuildManager;
|
||||
members: MemberManager;
|
||||
channels: ChannelManager;
|
||||
application: ApplicationManager;
|
||||
interaction: InteractionManager;
|
||||
webhook: WebhookManager;
|
||||
applications: ApplicationManager;
|
||||
interactions: InteractionManager;
|
||||
webhooks: WebhookManager;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ export class Session<On extends boolean = boolean> extends EventEmitter2 {
|
||||
ctx.gateway = new GatewayManager({
|
||||
token: this.options.token,
|
||||
intents: this.options.intents ?? 0,
|
||||
connection: this.options.defaultGatewayOptions?.connection ?? (await this.rest.get('/gateway/bot')),
|
||||
connection: this.options.defaultGatewayOptions?.connection ?? (await this.api.gateway.bot.get()),
|
||||
async handlePayload(shard, data) {
|
||||
const { t, d } = data;
|
||||
if (!(t && d)) return;
|
||||
@ -95,6 +95,12 @@ export class Session<On extends boolean = boolean> extends EventEmitter2 {
|
||||
...this.options.defaultGatewayOptions
|
||||
});
|
||||
|
||||
ctx.once('READY', (payload) => {
|
||||
const { user, application } = payload;
|
||||
this.botId = user.id;
|
||||
this.applicationId = application.id;
|
||||
});
|
||||
|
||||
await ctx.gateway.spawnShards();
|
||||
}
|
||||
}
|
||||
|
@ -18,4 +18,4 @@ yarn add @biscuitland/helpers
|
||||
* [Website](https://biscuitjs.com/)
|
||||
* [Documentation](https://docs.biscuitjs.com/)
|
||||
* [Discord](https://discord.gg/XNw2RZFzaP)
|
||||
* [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)
|
||||
* [core](https://www.npmjs.com/package/@biscuitland/core) | [rest](https://www.npmjs.com/package/@biscuitland/rest) | [ws](https://www.npmjs.com/package/@biscuitland/ws)
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@biscuitland/helpers",
|
||||
"version": "3.0.4",
|
||||
"version": "3.0.5",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@biscuitland/rest",
|
||||
"version": "3.0.2",
|
||||
"version": "3.0.3",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
|
@ -23,21 +23,29 @@ yarn add @biscuitland/ws
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import { GatewayManager } from '@biscuitland/ws';
|
||||
import { BiscuitREST } from '@biscuitland/rest';
|
||||
import { GatewayIntentBits, Routes} from '@biscuitland/common';
|
||||
import { GatewayManager } from "@biscuitland/ws";
|
||||
import { BiscuitREST, Router } from "@biscuitland/rest";
|
||||
import { GatewayIntentBits } from "@biscuitland/common";
|
||||
|
||||
const intents = GatewayIntentBits.Guilds;
|
||||
const token = 'your token goes here';
|
||||
const token = "your token goes here";
|
||||
const rest = new BiscuitREST({ token });
|
||||
const api = new Router(rest).createProxy();
|
||||
|
||||
(async () => {
|
||||
const connection = await rest.get(Routes.gatewayBot())
|
||||
const connection = await api.gateway.bot.get();
|
||||
|
||||
// gateway bot code ↓
|
||||
const ws = new GatewayManager({ token, intents, connection });
|
||||
// gateway bot code ↓
|
||||
const ws = new GatewayManager({
|
||||
token,
|
||||
intents,
|
||||
connection,
|
||||
async handlePayload(shardId, payload) {
|
||||
console.log("Received payload on shard #%s", shardId, payload);
|
||||
},
|
||||
});
|
||||
|
||||
await ws.spawnShards();
|
||||
await ws.spawnShards();
|
||||
})();
|
||||
```
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@biscuitland/ws",
|
||||
"version": "3.0.2",
|
||||
"version": "3.0.3",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
|
Loading…
x
Reference in New Issue
Block a user