1
0
Fork 0

if is cloud domain, delete dns record

refactor/models
Matthew 2019-10-29 19:32:04 -04:00
parent 8fbb4f1a16
commit 20337f7215
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 13 additions and 0 deletions

View File

@ -115,6 +115,19 @@ export default class CWG extends Command {
embed.addField('Port', String(domain.port), true); embed.addField('Port', String(domain.port), true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp(); embed.setTimestamp();
if (domain.domain.includes('cloud.libraryofcode.org')) {
const resultID = await axios({
method: 'get',
url: `https://api.cloudflare.com/client/v4/zones/5e82fc3111ed4fbf9f58caa34f7553a7/dns_records?name=${domain.domain}`,
headers: { Authorization: `Bearer ${this.client.config.cloudflare}` },
});
const recordID = resultID.data.result[0].id;
await axios({
method: 'delete',
url: `https://api.cloudflare.com/client/v4/zones/5e82fc3111ed4fbf9f58caa34f7553a7/dns_records/${recordID}`,
headers: { Authorization: `Bearer ${this.client.config.cloudflare}` },
});
}
// @ts-ignore // @ts-ignore
message.channel.createMessage({ embed }); message.channel.createMessage({ embed });
await this.client.db.Domain.deleteOne({ domain: domain.domain }); await this.client.db.Domain.deleteOne({ domain: domain.domain });