mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 04:56:07 +00:00
fix (#138)
This commit is contained in:
parent
87cdad0b03
commit
88d687d697
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@biscuitland/common",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"type": "module",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@biscuitland/core",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.1",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
@ -23,9 +23,9 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@biscuitland/common": "^0.0.1",
|
||||
"@biscuitland/rest": "^3.0.0",
|
||||
"@biscuitland/ws": "^3.0.0",
|
||||
"@biscuitland/common": "^0.0.2",
|
||||
"@biscuitland/rest": "^3.0.1",
|
||||
"@biscuitland/ws": "^3.0.1",
|
||||
"eventemitter2": "^6.4.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
18
packages/core/src/utils/types.ts
Normal file
18
packages/core/src/utils/types.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import type { ImageFormat } from '@biscuitland/common';
|
||||
|
||||
export type EditNickname = { nick?: string; reason?: string };
|
||||
|
||||
/**
|
||||
* @link https://discord.com/developers/docs/reference#image-formatting
|
||||
*/
|
||||
export type ImageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096;
|
||||
export type ImageOptions = {
|
||||
format?: ImageFormat;
|
||||
size?: ImageSize;
|
||||
};
|
||||
|
||||
export enum ThreadTypes {
|
||||
AnnouncementThread = 10,
|
||||
PublicThread = 11,
|
||||
PrivateThread = 12
|
||||
}
|
60
packages/core/src/utils/utils.ts
Normal file
60
packages/core/src/utils/utils.ts
Normal file
@ -0,0 +1,60 @@
|
||||
import { ReplaceRegex } from '@biscuitland/common';
|
||||
import { DiscordEpoch } from '@biscuitland/common';
|
||||
import { ImageFormat } from '@biscuitland/common';
|
||||
import type { ImageSize } from './types';
|
||||
|
||||
/**
|
||||
* Convert a timestamp to a snowflake.
|
||||
* @param timestamp The timestamp to convert.
|
||||
* @returns The snowflake.
|
||||
*/
|
||||
export function snowflakeToTimestamp(id: string): number {
|
||||
return (Number(id) >> 22) + DiscordEpoch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format an image URL.
|
||||
* @param url The URL to format.
|
||||
* @param size The size of the image.
|
||||
* @param format The format of the image.
|
||||
* @returns The formatted URL.
|
||||
*/
|
||||
export function formatImageURL(url: string, size: ImageSize = 128, format?: ImageFormat): string {
|
||||
return `${url}.${format ?? (url.includes('/a_') ? 'gif' : 'jpg')}?size=${size}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bot ID from a token.
|
||||
* @param token The token to get the bot ID from.
|
||||
* @returns The bot ID.
|
||||
* @warning Discord staff has mentioned this may not be stable forever xd.
|
||||
*/
|
||||
export function getBotIdFromToken(token: string): string {
|
||||
return Buffer.from(token.split('.')[0], 'base64').toString('ascii');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an object to a URLSearchParams object.
|
||||
* @param obj The object to convert.
|
||||
* @returns The URLSearchParams object.
|
||||
*/
|
||||
export function objectToParams(obj: object): URLSearchParams {
|
||||
const query = new URLSearchParams();
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (!value) continue;
|
||||
query.append(ReplaceRegex.camel(key), String(value));
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channel link from a channel ID and guild ID.
|
||||
*
|
||||
* @param channelId The channel ID.
|
||||
* @param guildId The guild ID.
|
||||
* @returns The channel link.
|
||||
*/
|
||||
export function channelLink(channelId: string, guildId?: string) {
|
||||
return `https://discord.com/channels/${guildId ?? '@me'}/${channelId}`;
|
||||
}
|
@ -1,75 +1,75 @@
|
||||
{
|
||||
"name": "@biscuitland/helpers",
|
||||
"version": "3.0.0",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/**"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"clean": "rm -rf dist && rm -rf .turbo",
|
||||
"dev": "tsup --watch"
|
||||
},
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.mjs"
|
||||
},
|
||||
"require": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@biscuitland/common": "^0.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.7.14",
|
||||
"tsup": "^6.1.3"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"author": "Yuzuru <yuzuru@programmer.net>",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Yuzuru",
|
||||
"url": "https://github.com/yuzudev",
|
||||
"author": true
|
||||
},
|
||||
{
|
||||
"name": "miia",
|
||||
"url": "https://github.com/dragurimu"
|
||||
},
|
||||
{
|
||||
"name": "n128",
|
||||
"url": "https://github.com/nicolito128"
|
||||
},
|
||||
{
|
||||
"name": "socram03",
|
||||
"url": "https://github.com/socram03"
|
||||
},
|
||||
{
|
||||
"name": "Drylozu",
|
||||
"url": "https://github.com/Drylozu"
|
||||
}
|
||||
],
|
||||
"homepage": "https://biscuitjs.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/oasisjs/biscuit.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/oasisjs/biscuit"
|
||||
},
|
||||
"keywords": [
|
||||
"api",
|
||||
"discord",
|
||||
"bots",
|
||||
"typescript",
|
||||
"botdev"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
"name": "@biscuitland/helpers",
|
||||
"version": "3.0.1",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/**"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"clean": "rm -rf dist && rm -rf .turbo",
|
||||
"dev": "tsup --watch"
|
||||
},
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.mjs"
|
||||
},
|
||||
"require": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@biscuitland/common": "^0.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.7.14",
|
||||
"tsup": "^6.1.3"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"author": "Yuzuru <yuzuru@programmer.net>",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Yuzuru",
|
||||
"url": "https://github.com/yuzudev",
|
||||
"author": true
|
||||
},
|
||||
{
|
||||
"name": "miia",
|
||||
"url": "https://github.com/dragurimu"
|
||||
},
|
||||
{
|
||||
"name": "n128",
|
||||
"url": "https://github.com/nicolito128"
|
||||
},
|
||||
{
|
||||
"name": "socram03",
|
||||
"url": "https://github.com/socram03"
|
||||
},
|
||||
{
|
||||
"name": "Drylozu",
|
||||
"url": "https://github.com/Drylozu"
|
||||
}
|
||||
],
|
||||
"homepage": "https://biscuitjs.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/oasisjs/biscuit.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/oasisjs/biscuit"
|
||||
},
|
||||
"keywords": [
|
||||
"api",
|
||||
"discord",
|
||||
"bots",
|
||||
"typescript",
|
||||
"botdev"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@biscuitland/rest",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.1",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@biscuitland/ws",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.1",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
@ -24,8 +24,8 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@biscuitland/common": "^0.0.1",
|
||||
"@biscuitland/rest": "^3.0.0",
|
||||
"@biscuitland/common": "^0.0.2",
|
||||
"@biscuitland/rest": "^3.0.1",
|
||||
"ws": "^8.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -105,6 +105,7 @@ export class Shard {
|
||||
else this.offlineSendQueue.push(resolve);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/** Close the socket connection to discord if present. */
|
||||
@ -575,8 +576,8 @@ export class Shard {
|
||||
}
|
||||
|
||||
/** This function communicates with the management process, in order to know whether its free to identify. When this function resolves, this means that the shard is allowed to send an identify payload to discord. */
|
||||
async requestIdentify(): Promise<void> {}
|
||||
async requestIdentify(): Promise<void> { }
|
||||
|
||||
/** This function communicates with the management process, in order to tell it can identify the next shard. */
|
||||
async shardIsReady(): Promise<void> {}
|
||||
async shardIsReady(): Promise<void> { }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user