mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 21:16:09 +00:00
fix(Message): unify guild method (#322)
* fix(Message): unify guild method * fix(Message): guild method overloads
This commit is contained in:
parent
8bc6a345c5
commit
767d2a4302
@ -1,4 +1,4 @@
|
|||||||
import { type AllChannels, Embed } from '..';
|
import { type AllChannels, Embed, ReturnCache } from '..';
|
||||||
import type { ListenerOptions } from '../builders';
|
import type { ListenerOptions } from '../builders';
|
||||||
import {
|
import {
|
||||||
type GuildMemberStructure,
|
type GuildMemberStructure,
|
||||||
@ -72,9 +72,19 @@ export class BaseMessage extends DiscordBase {
|
|||||||
return Formatter.messageLink(this.guildId ?? '@me', this.channelId, this.id);
|
return Formatter.messageLink(this.guildId ?? '@me', this.channelId, this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async guild(force = false): Promise<GuildStructure<'api'> | undefined> {
|
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'> | undefined>;
|
||||||
if (!this.guildId) return;
|
guild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
||||||
return this.client.guilds.fetch(this.guildId, force);
|
guild(mode: 'cache' | 'rest' | 'flow' = 'flow') {
|
||||||
|
if (!this.guildId)
|
||||||
|
return (
|
||||||
|
mode === 'cache' ? (this.client.cache.adapter.isAsync ? Promise.resolve() : undefined) : Promise.resolve()
|
||||||
|
) as any;
|
||||||
|
switch (mode) {
|
||||||
|
case 'cache':
|
||||||
|
return this.client.cache.guilds?.get(this.guildId);
|
||||||
|
default:
|
||||||
|
return this.client.guilds.fetch(this.guildId, mode === 'rest');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
channel(force = false): Promise<AllChannels> {
|
channel(force = false): Promise<AllChannels> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user