mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
* add webhook structure and getChannelWebhooks as well as getServerWebhooks * add sendMessage * add the ability to edit create and delete hooks * remove server wide cache and add getter.
40 lines
755 B
JavaScript
40 lines
755 B
JavaScript
"use strict";
|
|
|
|
import {Endpoints} from "../Constants";
|
|
/* example data
|
|
{
|
|
id: '164585980739846145'
|
|
name: 'wlfSS',
|
|
roles: [ '135829612780322816' ],
|
|
require_colons: false,
|
|
managed: true,
|
|
}
|
|
*/
|
|
|
|
export default class Webhook {
|
|
constructor(data, server, channel, user) {
|
|
this.server = server;
|
|
this.channel = channel;
|
|
this.id = data.id;
|
|
this.user = user || data.user;
|
|
this.name = data.name;
|
|
this.avatar = data.avatar;
|
|
this.token = data.token
|
|
}
|
|
|
|
get getURL() {
|
|
return `https://canary.discordapp.com/api/webhooks/${this.channel.id}/${this.token.id}`;
|
|
}
|
|
|
|
toObject() {
|
|
let keys = ['id', 'name', 'avatar', 'token'],
|
|
obj = {};
|
|
|
|
for (let k of keys) {
|
|
obj[k] = this[k];
|
|
}
|
|
|
|
return obj;
|
|
}
|
|
}
|