mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-02 21:16:09 +00:00
fix: guild edit
This commit is contained in:
parent
6b931e5661
commit
02f08c5bff
@ -5,6 +5,7 @@ import type {
|
|||||||
RESTPatchAPIAutoModerationRuleJSONBody,
|
RESTPatchAPIAutoModerationRuleJSONBody,
|
||||||
RESTPatchAPIChannelJSONBody,
|
RESTPatchAPIChannelJSONBody,
|
||||||
RESTPatchAPIGuildChannelPositionsJSONBody,
|
RESTPatchAPIGuildChannelPositionsJSONBody,
|
||||||
|
RESTPatchAPIGuildJSONBody,
|
||||||
RESTPatchAPIGuildStickerJSONBody,
|
RESTPatchAPIGuildStickerJSONBody,
|
||||||
RESTPostAPIAutoModerationRuleJSONBody,
|
RESTPostAPIAutoModerationRuleJSONBody,
|
||||||
RESTPostAPIGuildChannelJSONBody,
|
RESTPostAPIGuildChannelJSONBody,
|
||||||
@ -12,7 +13,7 @@ import type {
|
|||||||
} from 'discord-api-types/v10';
|
} from 'discord-api-types/v10';
|
||||||
import { toSnakeCase, type ObjectToLower } from '..';
|
import { toSnakeCase, type ObjectToLower } from '..';
|
||||||
import { resolveFiles } from '../../builders';
|
import { resolveFiles } from '../../builders';
|
||||||
import { BaseChannel, GuildMember, type CreateStickerBodyRequest } from '../../structures';
|
import { BaseChannel, Guild, GuildMember, type CreateStickerBodyRequest } from '../../structures';
|
||||||
import channelFrom from '../../structures/channels';
|
import channelFrom from '../../structures/channels';
|
||||||
import { BaseShorter } from './base';
|
import { BaseShorter } from './base';
|
||||||
import { type GuildStructure, Transformers } from '../../client/transformers';
|
import { type GuildStructure, Transformers } from '../../client/transformers';
|
||||||
@ -65,6 +66,13 @@ export class GuildShorter extends BaseShorter {
|
|||||||
return this.client.proxy.guilds(id).widget.get({ query });
|
return this.client.proxy.guilds(id).widget.get({ query });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async edit(guildId: string, body: RESTPatchAPIGuildJSONBody, reason?: string) {
|
||||||
|
const guild = await this.client.proxy.guilds(guildId).patch({ body, reason });
|
||||||
|
|
||||||
|
if (!this.client.cache.hasGuildsIntent) await this.client.cache.guilds?.patch(guildId, guild);
|
||||||
|
return new Guild(this.client, guild);
|
||||||
|
}
|
||||||
|
|
||||||
list(query?: RESTGetAPICurrentUserGuildsQuery) {
|
list(query?: RESTGetAPICurrentUserGuildsQuery) {
|
||||||
return this.client.proxy
|
return this.client.proxy
|
||||||
.users('@me')
|
.users('@me')
|
||||||
@ -110,7 +118,7 @@ export class GuildShorter extends BaseShorter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
channels = await this.client.proxy.guilds(guildId).channels.get();
|
channels = await this.client.proxy.guilds(guildId).channels.get();
|
||||||
await this.client.cache.channels?.set(
|
await this.client.cache.channels?.patch(
|
||||||
channels.map<[string, APIChannel]>(x => [x.id, x]),
|
channels.map<[string, APIChannel]>(x => [x.id, x]),
|
||||||
guildId,
|
guildId,
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
import type { APIGuild, APIPartialGuild, GatewayGuildCreateDispatchData } from 'discord-api-types/v10';
|
import type {
|
||||||
|
APIGuild,
|
||||||
|
APIPartialGuild,
|
||||||
|
GatewayGuildCreateDispatchData,
|
||||||
|
RESTPatchAPIGuildJSONBody,
|
||||||
|
} from 'discord-api-types/v10';
|
||||||
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 { AutoModerationRule } from './AutoModerationRule';
|
import { AutoModerationRule } from './AutoModerationRule';
|
||||||
@ -77,6 +82,10 @@ export class Guild<State extends StructStates = 'api'> extends (BaseGuild as unk
|
|||||||
channels = BaseChannel.allMethods({ client: this.client, guildId: this.id });
|
channels = BaseChannel.allMethods({ client: this.client, guildId: this.id });
|
||||||
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) {
|
||||||
|
return this.client.guilds.edit(this.id, body, reason);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Maximun custom guild emojis per level */
|
/** Maximun custom guild emojis per level */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user