Skip to content

Commit

Permalink
add PartyMember#chatBan method
Browse files Browse the repository at this point in the history
  • Loading branch information
tnfAngel committed Dec 8, 2023
1 parent e12d9b9 commit 8d08800
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/structures/party/ClientParty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ class ClientParty extends Party {
return this.chat.send(content);
}

/**
* Ban a member from this party chat
* @param member The member that should be banned
*/
public async chatBan(member: string) {
return this.chat.ban(member);
}

/**
* Updates this party's privacy settings
* @param privacy The updated party privacy
Expand Down
11 changes: 11 additions & 0 deletions src/structures/party/PartyChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ class PartyChat extends Base {
await this.client.xmpp.leaveMUC(this.jid, this.nick);
this.isConnected = false;
}

/**
* Ban a member from this party chat
* @param member The member that should be banned
*/
public async ban(member: string) {
await this.joinLock.wait();
if (!this.isConnected) await this.join();

return this.client.xmpp?.ban(this.jid, member);
}
}

export default PartyChat;
9 changes: 9 additions & 0 deletions src/structures/party/PartyMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ class PartyMember extends User {
return (this.party as any).hideMember(this.id, hide);
}

/**
* Bans this member from the client's party.
*/
public async chatBan() {
// This is a very hacky solution, but it's required since we cannot import ClientParty (circular dependencies)
if (typeof (this.party as any).chatBan !== 'function') throw new PartyPermissionError();
return (this.party as any).chatBan(this.id);
}

/**
* Updates this members data
* @param data The update data
Expand Down
8 changes: 8 additions & 0 deletions src/xmpp/XMPP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,14 @@ class XMPP extends Base {
public async leaveMUC(jid: string, nick: string) {
return this.connection!.leaveRoom(jid, nick);
}

/**
* Bans a member from a multi user chat room
* @param member The member that should be banned
*/
public async ban(jid: string, member: string) {
return this.connection!.ban(jid, `${member}@${Endpoints.EPIC_PROD_ENV}`);
}
}

export default XMPP;

0 comments on commit 8d08800

Please sign in to comment.