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)
|
## Example bot (TS/JS)
|
||||||
|
|
||||||
```js
|
```ts
|
||||||
import { Session } from '@biscuitland/core';
|
import { Session } from '@biscuitland/core';
|
||||||
import { GatewayIntentBits, InteractionType, InteractionResponseType } from '@biscuitland/common';
|
import { GatewayIntentBits, InteractionType, InteractionResponseType } from '@biscuitland/common';
|
||||||
|
|
||||||
const session = new Session({
|
const session = new Session({
|
||||||
intents: GatewayIntentBits.Guilds,
|
intents: GatewayIntentBits.Guilds,
|
||||||
token: 'your token goes here'
|
token: 'your token goes here'
|
||||||
});
|
});
|
||||||
|
|
||||||
const commands = [{
|
const commands = [
|
||||||
|
{
|
||||||
name: 'ping',
|
name: 'ping',
|
||||||
description: 'Replies with pong!'
|
description: 'Replies with pong!'
|
||||||
}];
|
}
|
||||||
|
];
|
||||||
|
|
||||||
session.on('READY', (payload) => {
|
session.once('READY', (payload) => {
|
||||||
const username = payload.user.username;
|
const username = payload.user.username;
|
||||||
console.log('I\'m ready! logged in as %s', username);
|
console.log('Logged in as: %s', username);
|
||||||
|
session.managers.applications.bulkCommands(session.applicationId, commands);
|
||||||
const [shardId, _shardCount] = payload.shard ?? [0, 0];
|
|
||||||
|
|
||||||
if (shardId === 0) session.managers.application.bulkCommands(session.applicationId!, commands);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
session.on('INTERACTION_CREATE', (interaction) => {
|
session.on('INTERACTION_CREATE', (interaction) => {
|
||||||
if (interaction.type !== InteractionType.ApplicationCommand) return;
|
if (interaction.type !== InteractionType.ApplicationCommand) return;
|
||||||
session.managers.interaction.reply(interaction.id, interaction.token, {
|
session.managers.interactions.reply(interaction.id, interaction.token, {
|
||||||
body: {
|
type: InteractionResponseType.ChannelMessageWithSource,
|
||||||
type: InteractionResponseType.ChannelMessageWithSource,
|
data: { content: 'pong!' }
|
||||||
data: { content: 'pong!' }
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
session.start();
|
session.start();
|
||||||
@ -68,8 +65,4 @@ session.start();
|
|||||||
* [Website](https://biscuitjs.com/)
|
* [Website](https://biscuitjs.com/)
|
||||||
* [Documentation](https://docs.biscuitjs.com/)
|
* [Documentation](https://docs.biscuitjs.com/)
|
||||||
* [Discord](https://discord.gg/XNw2RZFzaP)
|
* [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)
|
* [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)
|
||||||
|
|
||||||
## 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)
|
|
||||||
|
@ -15,14 +15,14 @@ yarn add @biscuitland/core
|
|||||||
|
|
||||||
### Example bot
|
### Example bot
|
||||||
`project/index.js`:
|
`project/index.js`:
|
||||||
```js
|
```ts
|
||||||
import { Session } from '@biscuitland/core';
|
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 });
|
const session = new Session({ token: 'your token', intents: GatewayIntentBits.Guilds });
|
||||||
|
|
||||||
session.events.on('READY', (payload) => {
|
session.on('READY', (payload, shardId) => {
|
||||||
console.log('Logged in as:', payload.user.username);
|
console.log('Logged in as: %s in shard #%s', payload.user.username, shardId);
|
||||||
});
|
});
|
||||||
|
|
||||||
session.start();
|
session.start();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@biscuitland/core",
|
"name": "@biscuitland/core",
|
||||||
"version": "3.0.2",
|
"version": "3.0.3",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
@ -13,16 +13,16 @@ export class MainManager {
|
|||||||
this.guilds = new GuildManager(this.session);
|
this.guilds = new GuildManager(this.session);
|
||||||
this.members = new MemberManager(this.session);
|
this.members = new MemberManager(this.session);
|
||||||
this.channels = new ChannelManager(this.session);
|
this.channels = new ChannelManager(this.session);
|
||||||
this.application = new ApplicationManager(this.session);
|
this.applications = new ApplicationManager(this.session);
|
||||||
this.interaction = new InteractionManager(this.session);
|
this.interactions = new InteractionManager(this.session);
|
||||||
this.webhook = new WebhookManager(this.session);
|
this.webhooks = new WebhookManager(this.session);
|
||||||
}
|
}
|
||||||
|
|
||||||
users: UserManager;
|
users: UserManager;
|
||||||
guilds: GuildManager;
|
guilds: GuildManager;
|
||||||
members: MemberManager;
|
members: MemberManager;
|
||||||
channels: ChannelManager;
|
channels: ChannelManager;
|
||||||
application: ApplicationManager;
|
applications: ApplicationManager;
|
||||||
interaction: InteractionManager;
|
interactions: InteractionManager;
|
||||||
webhook: WebhookManager;
|
webhooks: WebhookManager;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ export class Session<On extends boolean = boolean> extends EventEmitter2 {
|
|||||||
ctx.gateway = new GatewayManager({
|
ctx.gateway = new GatewayManager({
|
||||||
token: this.options.token,
|
token: this.options.token,
|
||||||
intents: this.options.intents ?? 0,
|
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) {
|
async handlePayload(shard, data) {
|
||||||
const { t, d } = data;
|
const { t, d } = data;
|
||||||
if (!(t && d)) return;
|
if (!(t && d)) return;
|
||||||
@ -95,6 +95,12 @@ export class Session<On extends boolean = boolean> extends EventEmitter2 {
|
|||||||
...this.options.defaultGatewayOptions
|
...this.options.defaultGatewayOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ctx.once('READY', (payload) => {
|
||||||
|
const { user, application } = payload;
|
||||||
|
this.botId = user.id;
|
||||||
|
this.applicationId = application.id;
|
||||||
|
});
|
||||||
|
|
||||||
await ctx.gateway.spawnShards();
|
await ctx.gateway.spawnShards();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,5 +17,5 @@ yarn add @biscuitland/helpers
|
|||||||
## Links
|
## Links
|
||||||
* [Website](https://biscuitjs.com/)
|
* [Website](https://biscuitjs.com/)
|
||||||
* [Documentation](https://docs.biscuitjs.com/)
|
* [Documentation](https://docs.biscuitjs.com/)
|
||||||
* [Discord](https://discord.gg/XNw2RZFzaP)
|
* [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",
|
"name": "@biscuitland/helpers",
|
||||||
"version": "3.0.4",
|
"version": "3.0.5",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@biscuitland/rest",
|
"name": "@biscuitland/rest",
|
||||||
"version": "3.0.2",
|
"version": "3.0.3",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
@ -23,21 +23,29 @@ yarn add @biscuitland/ws
|
|||||||
## Example
|
## Example
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { GatewayManager } from '@biscuitland/ws';
|
import { GatewayManager } from "@biscuitland/ws";
|
||||||
import { BiscuitREST } from '@biscuitland/rest';
|
import { BiscuitREST, Router } from "@biscuitland/rest";
|
||||||
import { GatewayIntentBits, Routes} from '@biscuitland/common';
|
import { GatewayIntentBits } from "@biscuitland/common";
|
||||||
|
|
||||||
const intents = GatewayIntentBits.Guilds;
|
const intents = GatewayIntentBits.Guilds;
|
||||||
const token = 'your token goes here';
|
const token = "your token goes here";
|
||||||
const rest = new BiscuitREST({ token });
|
const rest = new BiscuitREST({ token });
|
||||||
|
const api = new Router(rest).createProxy();
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const connection = await rest.get(Routes.gatewayBot())
|
const connection = await api.gateway.bot.get();
|
||||||
|
|
||||||
// gateway bot code ↓
|
// gateway bot code ↓
|
||||||
const ws = new GatewayManager({ token, intents, connection });
|
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",
|
"name": "@biscuitland/ws",
|
||||||
"version": "3.0.2",
|
"version": "3.0.3",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user