mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
feat: Guild.editMember
This commit is contained in:
parent
44a9f11fd6
commit
5abbe95750
@ -1,7 +1,7 @@
|
||||
import type { Model } from "./Base.ts";
|
||||
import type { Snowflake } from "../util/Snowflake.ts";
|
||||
import type { Session } from "../session/Session.ts";
|
||||
import type { DiscordEmoji, DiscordGuild, DiscordInviteMetadata, DiscordRole } from "../vendor/external.ts";
|
||||
import type { DiscordEmoji, DiscordGuild, DiscordMemberWithUser, DiscordInviteMetadata, DiscordRole } from "../vendor/external.ts";
|
||||
import type { GetInvite } from "../util/Routes.ts";
|
||||
import {
|
||||
DefaultMessageNotificationLevels,
|
||||
@ -56,6 +56,18 @@ export interface CreateGuildBan {
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @link https://discord.com/developers/docs/resources/guild#modify-guild-member
|
||||
* */
|
||||
export interface ModifyGuildMember {
|
||||
nick?: string;
|
||||
roles?: Snowflake[];
|
||||
mute?: boolean;
|
||||
deaf?: boolean;
|
||||
channelId?: Snowflake;
|
||||
communicationDisabledUntil?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a guild
|
||||
* @link https://discord.com/developers/docs/resources/guild#guild-object
|
||||
@ -236,14 +248,32 @@ export class Guild extends BaseGuild implements Model {
|
||||
/**
|
||||
* Kicks the member
|
||||
*/
|
||||
async kickMember(memebrId: Snowflake, { reason }: { reason?: string }) {
|
||||
async kickMember(memberId: Snowflake, { reason }: { reason?: string }) {
|
||||
await this.session.rest.runMethod<undefined>(
|
||||
this.session.rest,
|
||||
"DELETE",
|
||||
Routes.GUILD_MEMBER(this.id, memebrId),
|
||||
Routes.GUILD_MEMBER(this.id, memberId),
|
||||
{ reason },
|
||||
);
|
||||
}
|
||||
|
||||
async editMember(memberId: Snowflake, options: ModifyGuildMember) {
|
||||
const member = await this.session.rest.runMethod<DiscordMemberWithUser>(
|
||||
this.session.rest,
|
||||
"PATCH",
|
||||
Routes.GUILD_MEMBER(this.id, memberId)
|
||||
{
|
||||
nick: options.nick,
|
||||
roles: options.roles,
|
||||
mute: options.mute,
|
||||
deaf: options.deaf,
|
||||
channel_id: options.channelId,
|
||||
communication_disabled_until: options.communicationDisabledUntil ? new Date(options.communicationDisabledUntil).toISOString() : undefined,
|
||||
},
|
||||
);
|
||||
|
||||
return new Member(this.session, member, this.id);
|
||||
}
|
||||
}
|
||||
|
||||
export default Guild;
|
||||
|
@ -3,7 +3,7 @@ import type { Snowflake } from "../util/Snowflake.ts";
|
||||
import type { Session } from "../session/Session.ts";
|
||||
import type { DiscordMemberWithUser } from "../vendor/external.ts";
|
||||
import type { ImageFormat, ImageSize } from "../util/shared/images.ts";
|
||||
import type { CreateGuildBan } from "./Guild.ts";
|
||||
import type { CreateGuildBan, ModifyGuildMember } from "./Guild.ts";
|
||||
import { iconBigintToHash, iconHashToBigInt } from "../util/hash.ts";
|
||||
import User from "./User.ts";
|
||||
import Guild from "./Guild.ts";
|
||||
@ -68,6 +68,12 @@ export class Member implements Model {
|
||||
return this;
|
||||
}
|
||||
|
||||
async edit(options: ModifyGuildMember): Promise<Member> {
|
||||
const member = await Guild.prototype.editMember.call({ id: this.guildId, session: this.session }, this.user.id, options);
|
||||
|
||||
return member;
|
||||
}
|
||||
|
||||
/** gets the user's avatar */
|
||||
avatarUrl(options: { format?: ImageFormat; size?: ImageSize } = { size: 128 }) {
|
||||
let url: string;
|
||||
|
Loading…
x
Reference in New Issue
Block a user