mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-04 22:16:08 +00:00
fix: return cache types
This commit is contained in:
parent
2e1c9797ea
commit
80b9edf512
@ -1,4 +1,4 @@
|
|||||||
import type { ReturnCache } from '../..';
|
import type { ReturnCache } from '../../cache';
|
||||||
import type { Client, WorkerClient } from '../../client';
|
import type { Client, WorkerClient } from '../../client';
|
||||||
import type {
|
import type {
|
||||||
GuildMemberStructure,
|
GuildMemberStructure,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { ReturnCache } from '../..';
|
import type { ReturnCache } from '../../cache';
|
||||||
import type {
|
import type {
|
||||||
GuildMemberStructure,
|
GuildMemberStructure,
|
||||||
GuildStructure,
|
GuildStructure,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { ReturnCache } from '../../src';
|
import type { ReturnCache } from '../cache';
|
||||||
import type { AutoModerationRuleStructure, GuildMemberStructure, GuildStructure } from '../client';
|
import type { AutoModerationRuleStructure, GuildMemberStructure, GuildStructure } from '../client';
|
||||||
import type { UsingClient } from '../commands';
|
import type { UsingClient } from '../commands';
|
||||||
import type { MethodContext, ObjectToLower } from '../common';
|
import type { MethodContext, ObjectToLower } from '../common';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { GuildMemberStructure } from '../client';
|
import type { GuildMemberStructure, GuildStructure } from '../client';
|
||||||
import type { UsingClient } from '../commands';
|
import type { UsingClient } from '../commands';
|
||||||
import type { ObjectToLower, StructPropState, StructStates, ToClass } from '../common/types/util';
|
import type { ObjectToLower, StructPropState, StructStates, ToClass } from '../common/types/util';
|
||||||
import type { APIGuild, APIPartialGuild, GatewayGuildCreateDispatchData, RESTPatchAPIGuildJSONBody } from '../types';
|
import type { APIGuild, APIPartialGuild, GatewayGuildCreateDispatchData, RESTPatchAPIGuildJSONBody } from '../types';
|
||||||
@ -79,7 +79,7 @@ export class Guild<State extends StructStates = 'api'> extends (BaseGuild as unk
|
|||||||
emojis = GuildEmoji.methods({ client: this.client, guildId: this.id });
|
emojis = GuildEmoji.methods({ client: this.client, guildId: this.id });
|
||||||
bans = GuildBan.methods({ client: this.client, guildId: this.id });
|
bans = GuildBan.methods({ client: this.client, guildId: this.id });
|
||||||
|
|
||||||
edit(body: RESTPatchAPIGuildJSONBody, reason?: string) {
|
edit(body: RESTPatchAPIGuildJSONBody, reason?: string): Promise<GuildStructure<'api'>> {
|
||||||
return this.client.guilds.edit(this.id, body, reason);
|
return this.client.guilds.edit(this.id, body, reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { ReturnCache } from '../../src';
|
import type { ReturnCache } from '../cache';
|
||||||
import type { GuildBanStructure, GuildStructure } from '../client';
|
import type { GuildBanStructure, GuildStructure } from '../client';
|
||||||
import type { UsingClient } from '../commands';
|
import type { UsingClient } from '../commands';
|
||||||
import { Formatter, type MethodContext, type ObjectToLower } from '../common';
|
import { Formatter, type MethodContext, type ObjectToLower } from '../common';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { ReturnCache } from '../../src';
|
|
||||||
import type { BaseCDNUrlOptions } from '../api';
|
import type { BaseCDNUrlOptions } from '../api';
|
||||||
|
import type { ReturnCache } from '../cache';
|
||||||
import type { GuildEmojiStructure, GuildStructure } from '../client';
|
import type { GuildEmojiStructure, GuildStructure } from '../client';
|
||||||
import type { UsingClient } from '../commands';
|
import type { UsingClient } from '../commands';
|
||||||
import { type EmojiShorter, Formatter, type MethodContext, type ObjectToLower } from '../common';
|
import { type EmojiShorter, Formatter, type MethodContext, type ObjectToLower } from '../common';
|
||||||
|
@ -7,7 +7,7 @@ export type GuildMemberData =
|
|||||||
| GatewayGuildMemberAddDispatchData
|
| GatewayGuildMemberAddDispatchData
|
||||||
| APIInteractionDataResolvedGuildMember;
|
| APIInteractionDataResolvedGuildMember;
|
||||||
|
|
||||||
import type { ReturnCache } from '../';
|
import type { GuildRoleStructure, ReturnCache } from '../';
|
||||||
import {
|
import {
|
||||||
type DMChannelStructure,
|
type DMChannelStructure,
|
||||||
type GuildMemberStructure,
|
type GuildMemberStructure,
|
||||||
@ -38,7 +38,6 @@ import type {
|
|||||||
RESTPutAPIGuildBanJSONBody,
|
RESTPutAPIGuildBanJSONBody,
|
||||||
RESTPutAPIGuildMemberJSONBody,
|
RESTPutAPIGuildMemberJSONBody,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import type { GuildRole } from './GuildRole';
|
|
||||||
import { PermissionsBitField } from './extra/Permissions';
|
import { PermissionsBitField } from './extra/Permissions';
|
||||||
|
|
||||||
export interface BaseGuildMember extends DiscordBase, ObjectToLower<Omit<APIGuildMember, 'user' | 'roles'>> {}
|
export interface BaseGuildMember extends DiscordBase, ObjectToLower<Omit<APIGuildMember, 'user' | 'roles'>> {}
|
||||||
@ -133,7 +132,7 @@ export class BaseGuildMember extends DiscordBase {
|
|||||||
get roles() {
|
get roles() {
|
||||||
return {
|
return {
|
||||||
keys: Object.freeze(this._roles.concat(this.guildId)) as string[],
|
keys: Object.freeze(this._roles.concat(this.guildId)) as string[],
|
||||||
list: (force = false): Promise<GuildRole[]> =>
|
list: (force = false): Promise<GuildRoleStructure[]> =>
|
||||||
this.client.roles
|
this.client.roles
|
||||||
.list(this.guildId, force)
|
.list(this.guildId, force)
|
||||||
.then(roles => roles.filter(role => this.roles.keys.includes(role.id))),
|
.then(roles => roles.filter(role => this.roles.keys.includes(role.id))),
|
||||||
@ -141,9 +140,9 @@ export class BaseGuildMember extends DiscordBase {
|
|||||||
remove: (id: string) => this.client.members.removeRole(this.guildId, this.id, id),
|
remove: (id: string) => this.client.members.removeRole(this.guildId, this.id, id),
|
||||||
permissions: (force = false) =>
|
permissions: (force = false) =>
|
||||||
this.roles.list(force).then(roles => new PermissionsBitField(roles.map(x => BigInt(x.permissions.bits)))),
|
this.roles.list(force).then(roles => new PermissionsBitField(roles.map(x => BigInt(x.permissions.bits)))),
|
||||||
sorted: (force = false): Promise<GuildRole[]> =>
|
sorted: (force = false): Promise<GuildRoleStructure[]> =>
|
||||||
this.roles.list(force).then(roles => roles.sort((a, b) => b.position - a.position)),
|
this.roles.list(force).then(roles => roles.sort((a, b) => b.position - a.position)),
|
||||||
highest: (force = false): Promise<GuildRole> => this.roles.sorted(force).then(roles => roles[0]),
|
highest: (force = false): Promise<GuildRoleStructure> => this.roles.sorted(force).then(roles => roles[0]),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { ReturnCache } from '../../src';
|
import type { ReturnCache } from '../cache';
|
||||||
import type { GuildRoleStructure, GuildStructure } from '../client';
|
import type { GuildRoleStructure, GuildStructure } from '../client';
|
||||||
import type { UsingClient } from '../commands';
|
import type { UsingClient } from '../commands';
|
||||||
import { Formatter, type MethodContext, type ObjectToLower } from '../common';
|
import { Formatter, type MethodContext, type ObjectToLower } from '../common';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { ReturnCache } from '../../src';
|
import type { ReturnCache } from '../cache';
|
||||||
import type { GuildStructure, GuildTemplateStructure } from '../client';
|
import type { GuildStructure, GuildTemplateStructure } from '../client';
|
||||||
import type { UsingClient } from '../commands';
|
import type { UsingClient } from '../commands';
|
||||||
import type { MethodContext, ObjectToLower } from '../common';
|
import type { MethodContext, ObjectToLower } from '../common';
|
||||||
|
@ -42,9 +42,9 @@ import {
|
|||||||
type RESTPostAPIInteractionCallbackResult,
|
type RESTPostAPIInteractionCallbackResult,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
|
|
||||||
import type { ReturnCache } from '../../src';
|
|
||||||
import type { RawFile } from '../api';
|
import type { RawFile } from '../api';
|
||||||
import { ActionRow, Embed, Modal, PollBuilder, resolveAttachment, resolveFiles } from '../builders';
|
import { ActionRow, Embed, Modal, PollBuilder, resolveAttachment, resolveFiles } from '../builders';
|
||||||
|
import type { ReturnCache } from '../cache';
|
||||||
import {
|
import {
|
||||||
type EntitlementStructure,
|
type EntitlementStructure,
|
||||||
type GuildRoleStructure,
|
type GuildRoleStructure,
|
||||||
|
@ -30,8 +30,16 @@ export class Poll extends Base {
|
|||||||
return this.client.messages.endPoll(this.channelId, this.messageId);
|
return this.client.messages.endPoll(this.channelId, this.messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAnswerVoters(id: ValidAnswerId): Promise<UserStructure[]> {
|
/**
|
||||||
if (!this.answers.find(x => x.answerId === id)) throw new Error('Invalid answer id');
|
* @param id - The ID of the answer whose voters need to be fetched.
|
||||||
|
* @param checkAnswer - A flag that determines if the answer ID should be validated before fetching voters.
|
||||||
|
* Default is `false`. If `true`, the method checks if the answer ID exists in the list
|
||||||
|
* of answers and throws an error if not.
|
||||||
|
*/
|
||||||
|
async getAnswerVoters(id: ValidAnswerId, checkAnswer = false): Promise<UserStructure[]> {
|
||||||
|
if (checkAnswer && !this.answers.find(answer => answer.answerId === id)) {
|
||||||
|
throw new Error('Invalid answer id');
|
||||||
|
}
|
||||||
return this.client.messages.getAnswerVoters(this.channelId, this.messageId, id);
|
return this.client.messages.getAnswerVoters(this.channelId, this.messageId, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { GuildStructure, RawFile, StickerStructure, UsingClient } from '..';
|
import type { GuildStructure, RawFile, StickerStructure, UsingClient } from '..';
|
||||||
import type { ReturnCache } from '../../src';
|
|
||||||
import type { Attachment, AttachmentBuilder } from '../builders';
|
import type { Attachment, AttachmentBuilder } from '../builders';
|
||||||
|
import type { ReturnCache } from '../cache';
|
||||||
import { Transformers, type UserStructure } from '../client/transformers';
|
import { Transformers, type UserStructure } from '../client/transformers';
|
||||||
import type { MethodContext, ObjectToLower } from '../common';
|
import type { MethodContext, ObjectToLower } from '../common';
|
||||||
import type { APISticker, RESTPatchAPIGuildStickerJSONBody, RESTPostAPIGuildStickerFormDataBody } from '../types';
|
import type { APISticker, RESTPatchAPIGuildStickerJSONBody, RESTPostAPIGuildStickerFormDataBody } from '../types';
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
import type { AllGuildVoiceChannels, UserStructure, UsingClient, VoiceStateStructure } from '../';
|
import type {
|
||||||
import type { GuildStructure, ReturnCache } from '../../src';
|
AllGuildVoiceChannels,
|
||||||
|
GuildStructure,
|
||||||
|
ReturnCache,
|
||||||
|
UserStructure,
|
||||||
|
UsingClient,
|
||||||
|
VoiceStateStructure,
|
||||||
|
} from '../';
|
||||||
import type { VoiceStateResource } from '../cache/resources/voice-states';
|
import type { VoiceStateResource } from '../cache/resources/voice-states';
|
||||||
import { type GuildMemberStructure, Transformers } from '../client/transformers';
|
import { type GuildMemberStructure, Transformers } from '../client/transformers';
|
||||||
import type { ObjectToLower } from '../common';
|
import type { ObjectToLower } from '../common';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { ReturnCache } from '../../src';
|
import type { ReturnCache } from '../cache';
|
||||||
import {
|
import {
|
||||||
type AnonymousGuildStructure,
|
type AnonymousGuildStructure,
|
||||||
type GuildStructure,
|
type GuildStructure,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import type { WorkerClient } from '../..';
|
import type { ReturnCache, WorkerClient } from '../..';
|
||||||
import type { ReturnCache } from '../../../src';
|
|
||||||
import type { GuildStructure } from '../../client';
|
import type { GuildStructure } from '../../client';
|
||||||
import { type ObjectToLower, calculateShardId } from '../../common';
|
import { type ObjectToLower, calculateShardId } from '../../common';
|
||||||
import type { ImageOptions } from '../../common/types/options';
|
import type { ImageOptions } from '../../common/types/options';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user