mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +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 GuildMemberStructure,
|
||||
@ -72,9 +72,19 @@ export class BaseMessage extends DiscordBase {
|
||||
return Formatter.messageLink(this.guildId ?? '@me', this.channelId, this.id);
|
||||
}
|
||||
|
||||
async guild(force = false): Promise<GuildStructure<'api'> | undefined> {
|
||||
if (!this.guildId) return;
|
||||
return this.client.guilds.fetch(this.guildId, force);
|
||||
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'> | undefined>;
|
||||
guild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
||||
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> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user