1
0
Fork 0

Added command

refactor/models
Bsian 2020-03-30 16:41:06 +01:00
parent 8ca73f2b62
commit f96b35f20e
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,40 @@
import { Message } from 'eris';
import axios from 'axios';
import { Client } from '..';
import { Command } from '../class';
export default class Cloudflare extends Command {
constructor(client: Client) {
super(client);
this.name = 'cloudflare';
this.description = 'Remove an entry from Cloudflare DNS records';
this.permissions = {
roles: ['525441307037007902'],
};
this.aliases = ['cf'];
this.enabled = true;
}
public async run(message: Message, args: string[]) {
try {
const msg = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Locating entry...***`);
const { data } = await axios({
method: 'get',
url: `https://api.cloudflare.com/client/v4/zones/5e82fc3111ed4fbf9f58caa34f7553a7/dns_records?name=${args[0]}`,
headers: { Authorization: `Bearer ${this.client.config.cloudflare}` },
});
if (!data.result.length) return msg.edit(`${this.client.stores.emojis.error} ***Entry not found***`);
msg.edit(`${this.client.stores.emojis.success} ***Located entry***\n${this.client.stores.emojis.loading} ***Deleting entry...***`);
const { id }: { id: string } = data.result[0];
await axios({
method: 'delete',
url: `https://api.cloudflare.com/client/v4/zones/5e82fc3111ed4fbf9f58caa34f7553a7/dns_records/${id}`,
headers: { Authorization: `Bearer ${this.client.config.cloudflare}` },
});
this.client.commands.get('cwg').subcommands.get('create').enabled = true;
return msg.edit(`${this.client.stores.emojis.success} ***Located entry***\n${this.client.stores.emojis.success} ***Deleted entry***`);
} catch (error) {
return this.client.util.handleError(error, message, this);
}
}
}

View File

@ -1,5 +1,6 @@
export { default as announce } from './announce'; export { default as announce } from './announce';
export { default as bearer } from './bearer'; export { default as bearer } from './bearer';
export { default as cloudflare } from './cloudflare';
export { default as createaccount } from './createaccount'; export { default as createaccount } from './createaccount';
export { default as cwg } from './cwg'; export { default as cwg } from './cwg';
export { default as deleteaccount } from './deleteaccount'; export { default as deleteaccount } from './deleteaccount';