if is cloud domain, delete dns record

merge-requests/1/merge
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.setFooter(this.client.user.username, this.client.user.avatarURL);
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
message.channel.createMessage({ embed });
await this.client.db.Domain.deleteOne({ domain: domain.domain });