2023-04-02 09:49:47 -04:00
|
|
|
import author from '../messages/User.js';
|
2023-04-01 21:49:27 -04:00
|
|
|
import Guild from './Guild.js'
|
|
|
|
|
import { Channel } from '../messages/message.js';
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default class invite {
|
|
|
|
|
#token;
|
|
|
|
|
|
|
|
|
|
code;
|
|
|
|
|
|
|
|
|
|
/** @type {Guild} */
|
|
|
|
|
guild;
|
|
|
|
|
|
|
|
|
|
/** @type {Channel?} */
|
|
|
|
|
channel;
|
|
|
|
|
|
|
|
|
|
/** @type {member?} */
|
|
|
|
|
inviter;
|
|
|
|
|
|
|
|
|
|
/** @type {EpochTimeStamp} */
|
|
|
|
|
expires_at;
|
|
|
|
|
|
|
|
|
|
/** @type {Number} */
|
|
|
|
|
uses;
|
|
|
|
|
|
|
|
|
|
/** @type {Number} */
|
|
|
|
|
max_uses;
|
|
|
|
|
|
|
|
|
|
/** @type {Number} */
|
|
|
|
|
max_age;
|
|
|
|
|
|
|
|
|
|
/** @type {Boolean} */
|
|
|
|
|
temporary;
|
|
|
|
|
|
|
|
|
|
/** @type {String} */
|
|
|
|
|
created_at;
|
|
|
|
|
|
|
|
|
|
async delete() {
|
|
|
|
|
return new Promise(async (resolve) => {
|
2023-04-02 09:49:47 -04:00
|
|
|
try {
|
|
|
|
|
const headers = { Authorization: this.#token }
|
|
|
|
|
const response = await axios.delete(`https://discord.com/api/invites/${this.code}`, { headers });
|
|
|
|
|
resolve(response.data);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
throw err.data;
|
|
|
|
|
}
|
2023-04-01 21:49:27 -04:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constructor(o, guild, token) {
|
|
|
|
|
this.#token = token;
|
|
|
|
|
for (const k in this) {
|
|
|
|
|
if (o[k]) {
|
|
|
|
|
if (k == 'guild') { this.guild = guild }
|
2023-04-02 09:49:47 -04:00
|
|
|
// else if (k == 'channel') { this.channel = this.guild.channels.cache?.get(o[k]['id']); }
|
|
|
|
|
else if (k == 'inviter') { this.inviter = new author(o[k]); }
|
2023-04-01 21:49:27 -04:00
|
|
|
else { this[k] = o[k]; }
|
|
|
|
|
} else { this[k] = 0; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|