mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
feat(invites): add invites shortcuts
This commit is contained in:
parent
1731d2de6b
commit
ca26338a4c
18
package.json
18
package.json
@ -23,13 +23,13 @@
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@changesets/cli": "^2.28.1",
|
||||
"@commitlint/cli": "^19.7.1",
|
||||
"@commitlint/config-conventional": "^19.7.1",
|
||||
"@types/node": "^22.13.5",
|
||||
"@commitlint/cli": "^19.8.0",
|
||||
"@commitlint/config-conventional": "^19.8.0",
|
||||
"@types/node": "^22.14.0",
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^15.4.3",
|
||||
"typescript": "^5.7.3",
|
||||
"vitest": "^3.0.6"
|
||||
"lint-staged": "^15.5.0",
|
||||
"typescript": "^5.8.2",
|
||||
"vitest": "^3.1.1"
|
||||
},
|
||||
"homepage": "https://seyfert.dev",
|
||||
"repository": {
|
||||
@ -69,5 +69,11 @@
|
||||
"*.ts": [
|
||||
"biome check --write"
|
||||
]
|
||||
},
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"@biomejs/biome",
|
||||
"esbuild"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
796
pnpm-lock.yaml
generated
796
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -23,6 +23,7 @@ import {
|
||||
EmojiShorter,
|
||||
GuildShorter,
|
||||
InteractionShorter,
|
||||
InvitesShorter,
|
||||
LogLevels,
|
||||
Logger,
|
||||
type MakeRequired,
|
||||
@ -81,6 +82,9 @@ export class BaseClient {
|
||||
interactions = new InteractionShorter(this);
|
||||
voiceStates = new VoiceStateShorter(this);
|
||||
soundboards = new SoundboardShorter(this);
|
||||
invites = new InvitesShorter(this);
|
||||
|
||||
/**@internal */
|
||||
|
||||
debugger?: Logger;
|
||||
|
||||
|
@ -3,6 +3,8 @@ export * from './it/utils';
|
||||
export * from './it/colors';
|
||||
export { CustomizeLoggerCallback, AssignFilenameCallback, LogLevels, Logger, LoggerOptions } from './it/logger';
|
||||
export * from './it/formatter';
|
||||
// circular lol
|
||||
export * from './shorters/invites';
|
||||
//
|
||||
export * from './shorters/channels';
|
||||
export * from './shorters/emojis';
|
||||
|
45
src/common/shorters/invites.ts
Normal file
45
src/common/shorters/invites.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import type { RESTPostAPIChannelInviteJSONBody } from '../../types';
|
||||
import { toCamelCase } from '../it/utils';
|
||||
import { BaseShorter } from './base';
|
||||
|
||||
export class InvitesShorter extends BaseShorter {
|
||||
get(code: string) {
|
||||
return this.client.proxy
|
||||
.invites(code)
|
||||
.get()
|
||||
.then(x => toCamelCase(x));
|
||||
}
|
||||
|
||||
delete(code: string, reason?: string) {
|
||||
return this.client.proxy
|
||||
.invites(code)
|
||||
.delete({ reason })
|
||||
.then(x => toCamelCase(x));
|
||||
}
|
||||
|
||||
channels = {
|
||||
create: ({ channelId, reason, ...body }: CreateInviteFromChannel) =>
|
||||
this.client.proxy
|
||||
.channels(channelId)
|
||||
.invites.post({ body, reason })
|
||||
.then(x => toCamelCase(x)),
|
||||
list: (channelId: string) =>
|
||||
this.client.proxy
|
||||
.channels(channelId)
|
||||
.invites.get()
|
||||
.then(x => toCamelCase(x)),
|
||||
};
|
||||
|
||||
guilds = {
|
||||
list: (guildId: string) =>
|
||||
this.client.proxy
|
||||
.guilds(guildId)
|
||||
.invites.get()
|
||||
.then(x => toCamelCase(x)),
|
||||
};
|
||||
}
|
||||
|
||||
export interface CreateInviteFromChannel extends RESTPostAPIChannelInviteJSONBody {
|
||||
channelId: string;
|
||||
reason?: string;
|
||||
}
|
@ -104,15 +104,17 @@ export type SnakeCase<S extends string> = S extends `${infer A}${infer Rest}`
|
||||
: `${A}${SnakeCase<Rest>}`
|
||||
: Lowercase<S>;
|
||||
|
||||
export type ObjectToLower<T> = Identify<{
|
||||
[K in keyof T as CamelCase<Exclude<K, symbol | number>>]: T[K] extends unknown[]
|
||||
? Identify<ObjectToLower<T[K][0]>[]>
|
||||
: T[K] extends object
|
||||
? Identify<ObjectToLower<T[K]>>
|
||||
: AuxIsStrictlyUndefined<T[K]> extends true
|
||||
? undefined
|
||||
: ObjectToLowerUndefined<T[K]>;
|
||||
}>;
|
||||
export type ObjectToLower<T> = T extends unknown[]
|
||||
? ObjectToLower<T[0]>[]
|
||||
: Identify<{
|
||||
[K in keyof T as CamelCase<Exclude<K, symbol | number>>]: T[K] extends unknown[]
|
||||
? Identify<ObjectToLower<T[K][0]>[]>
|
||||
: T[K] extends object
|
||||
? Identify<ObjectToLower<T[K]>>
|
||||
: AuxIsStrictlyUndefined<T[K]> extends true
|
||||
? undefined
|
||||
: ObjectToLowerUndefined<T[K]>;
|
||||
}>;
|
||||
|
||||
export type ObjectToLowerUndefined<T> = T extends unknown[]
|
||||
? ObjectToLower<T[0]>[]
|
||||
|
@ -1,5 +1,6 @@
|
||||
import type { GuildMemberStructure, GuildStructure } from '../client';
|
||||
import type { UsingClient } from '../commands';
|
||||
import type { CreateInviteFromChannel } from '../common';
|
||||
import type { ObjectToLower, StructPropState, StructStates, ToClass } from '../common/types/util';
|
||||
import type { APIGuild, APIPartialGuild, GatewayGuildCreateDispatchData, RESTPatchAPIGuildJSONBody } from '../types';
|
||||
import { AutoModerationRule } from './AutoModerationRule';
|
||||
@ -82,6 +83,12 @@ export class Guild<State extends StructStates = 'api'> extends (BaseGuild as unk
|
||||
edit(body: RESTPatchAPIGuildJSONBody, reason?: string): Promise<GuildStructure<'api'>> {
|
||||
return this.client.guilds.edit(this.id, body, reason);
|
||||
}
|
||||
|
||||
invites = {
|
||||
list: () => this.client.invites.guilds.list(this.id),
|
||||
create: (data: CreateInviteFromChannel) => this.client.invites.channels.create(data),
|
||||
delete: (code: string, reason?: string) => this.client.invites.delete(code, reason),
|
||||
};
|
||||
}
|
||||
|
||||
/** Maximun custom guild emojis per level */
|
||||
|
@ -24,6 +24,7 @@ import {
|
||||
} from '../client';
|
||||
import type { SeyfertChannelMap, UsingClient } from '../commands';
|
||||
import {
|
||||
type CreateInviteFromChannel,
|
||||
type EmojiResolvable,
|
||||
type MessageCreateBodyRequest,
|
||||
type MessageUpdateBodyRequest,
|
||||
@ -213,6 +214,16 @@ export class BaseGuildChannel extends BaseChannel<ChannelType> {
|
||||
super(client, rest);
|
||||
}
|
||||
|
||||
invites = {
|
||||
list: () => this.client.invites.channels.list(this.id),
|
||||
create: (data: Omit<CreateInviteFromChannel, 'channelId'>) =>
|
||||
this.client.invites.channels.create({
|
||||
...data,
|
||||
channelId: this.id,
|
||||
}),
|
||||
delete: (code: string, reason?: string) => this.client.invites.delete(code, reason),
|
||||
};
|
||||
|
||||
permissionOverwrites = {
|
||||
fetch: (): ReturnType<Overwrites['get']> =>
|
||||
this.client.cache.overwrites?.get(this.id) ||
|
||||
|
Loading…
x
Reference in New Issue
Block a user