Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/classes/MFA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import type {

import type { Client } from "../Client.js";

import { Bot } from "./Bot.js";
import { Server } from "./Server.js";

/**
* Multi-Factor Authentication
*/
Expand Down Expand Up @@ -203,4 +206,36 @@ export class MFATicket {
},
});
}

/**
* Delete server
*/
async deleteServer(server: Server): Promise<void> {
if (!(server.owner?.self ?? server.ownerId === this.#client.user?.id))
throw new Error("NotOwner");

this._consume();
return this.#client.api.delete(`/servers/${server.id}`, undefined, {
headers: {
"X-MFA-Ticket": this.token,
},
});
}

/**
* Delete bot
*/
async deleteBot(bot: Bot): Promise<void> {
if (!(bot.owner?.self ?? bot.ownerId === this.#client.user?.id))
throw new Error("NotOwner");

this._consume();
await this.#client.api.delete(`/bots/${bot.id}`, undefined, {
headers: {
"X-MFA-Ticket": this.token,
},
});

this.#client.bots.delete(bot.id);
}
}
Loading