mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
feat: Guild.pruneMembers etc
This commit is contained in:
parent
5abbe95750
commit
ea5f3d53a8
@ -50,9 +50,7 @@ export interface ModifyGuildEmoji {
|
|||||||
* @link https://discord.com/developers/docs/resources/guild#create-guild-ban
|
* @link https://discord.com/developers/docs/resources/guild#create-guild-ban
|
||||||
*/
|
*/
|
||||||
export interface CreateGuildBan {
|
export interface CreateGuildBan {
|
||||||
/** Number of days to delete messages for (0-7) */
|
|
||||||
deleteMessageDays?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
deleteMessageDays?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
||||||
/** Reason for the ban */
|
|
||||||
reason?: string;
|
reason?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +66,15 @@ export interface ModifyGuildMember {
|
|||||||
communicationDisabledUntil?: number;
|
communicationDisabledUntil?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @link https://discord.com/developers/docs/resources/guild#begin-guild-prune
|
||||||
|
* */
|
||||||
|
export interface BeginGuildPrune {
|
||||||
|
days?: number;
|
||||||
|
computePruneCount?: boolean;
|
||||||
|
includeRoles?: Snowflake[];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a guild
|
* Represents a guild
|
||||||
* @link https://discord.com/developers/docs/resources/guild#guild-object
|
* @link https://discord.com/developers/docs/resources/guild#guild-object
|
||||||
@ -261,7 +268,7 @@ export class Guild extends BaseGuild implements Model {
|
|||||||
const member = await this.session.rest.runMethod<DiscordMemberWithUser>(
|
const member = await this.session.rest.runMethod<DiscordMemberWithUser>(
|
||||||
this.session.rest,
|
this.session.rest,
|
||||||
"PATCH",
|
"PATCH",
|
||||||
Routes.GUILD_MEMBER(this.id, memberId)
|
Routes.GUILD_MEMBER(this.id, memberId),
|
||||||
{
|
{
|
||||||
nick: options.nick,
|
nick: options.nick,
|
||||||
roles: options.roles,
|
roles: options.roles,
|
||||||
@ -269,11 +276,36 @@ export class Guild extends BaseGuild implements Model {
|
|||||||
deaf: options.deaf,
|
deaf: options.deaf,
|
||||||
channel_id: options.channelId,
|
channel_id: options.channelId,
|
||||||
communication_disabled_until: options.communicationDisabledUntil ? new Date(options.communicationDisabledUntil).toISOString() : undefined,
|
communication_disabled_until: options.communicationDisabledUntil ? new Date(options.communicationDisabledUntil).toISOString() : undefined,
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Member(this.session, member, this.id);
|
return new Member(this.session, member, this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async pruneMembers(options: BeginGuildPrune): Promise<number> {
|
||||||
|
const result = await this.session.rest.runMethod<{ pruned: number }>(
|
||||||
|
this.session.rest,
|
||||||
|
"POST",
|
||||||
|
Routes.GUILD_PRUNE(this.id),
|
||||||
|
{
|
||||||
|
days: options.days,
|
||||||
|
compute_prune_count: options.computePruneCount,
|
||||||
|
include_roles: options.includeRoles,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return result.pruned;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getPruneCount(): Promise<number> {
|
||||||
|
const result = await this.session.rest.runMethod<{ pruned: number }>(
|
||||||
|
this.session.rest,
|
||||||
|
"GET",
|
||||||
|
Routes.GUILD_PRUNE(this.id),
|
||||||
|
);
|
||||||
|
|
||||||
|
return result.pruned;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Guild;
|
export default Guild;
|
||||||
|
@ -48,7 +48,6 @@ export class Role implements Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async delete(): Promise<void> {
|
async delete(): Promise<void> {
|
||||||
// cool jS trick
|
|
||||||
await Guild.prototype.deleteRole.call({ id: this.guildId, session: this.session }, this.id);
|
await Guild.prototype.deleteRole.call({ id: this.guildId, session: this.session }, this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,10 +147,8 @@ export function INTERACTION_ID_TOKEN(interactionId: Snowflake, token: string) {
|
|||||||
export function WEBHOOK(webhookId: Snowflake, token: string, options?: { wait?: boolean; threadId?: Snowflake }) {
|
export function WEBHOOK(webhookId: Snowflake, token: string, options?: { wait?: boolean; threadId?: Snowflake }) {
|
||||||
let url = `/webhooks/${webhookId}/${token}?`;
|
let url = `/webhooks/${webhookId}/${token}?`;
|
||||||
|
|
||||||
if (options) {
|
if (options?.wait !== undefined) url += `wait=${options.wait}`;
|
||||||
if (options.wait !== undefined) url += `wait=${options.wait}`;
|
if (options?.threadId) url += `threadId=${options.threadId}`;
|
||||||
if (options.threadId) url += `threadId=${options.threadId}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@ -158,3 +156,20 @@ export function WEBHOOK(webhookId: Snowflake, token: string, options?: { wait?:
|
|||||||
export function USER_NICK(guildId: Snowflake) {
|
export function USER_NICK(guildId: Snowflake) {
|
||||||
return `/guilds/${guildId}/members/@me`;
|
return `/guilds/${guildId}/members/@me`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @link https://discord.com/developers/docs/resources/guild#get-guild-prune-count
|
||||||
|
* */
|
||||||
|
export interface GetGuildPruneCountQuery {
|
||||||
|
days?: number;
|
||||||
|
includeRoles?: Snowflake | Snowflake[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function GUILD_PRUNE(guildId: Snowflake, options?: GetGuildPruneCountQuery) {
|
||||||
|
let url = `/guilds/${guildId}/prune?`;
|
||||||
|
|
||||||
|
if (options?.days) url += `days=${options.days}`;
|
||||||
|
if (options?.includeRoles) url += `&include_roles=${options.includeRoles}`;
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user