mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-04 05:56:09 +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,6 +1,6 @@
|
||||
{
|
||||
"name": "@biscuitland/helpers",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.1",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
@ -23,7 +23,7 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@biscuitland/common": "^0.0.1"
|
||||
"@biscuitland/common": "^0.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.7.14",
|
||||
|
@ -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. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user