mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
add webhooks v8 (#759)
* 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.
This commit is contained in:
39
src/Structures/Webhook.js
Normal file
39
src/Structures/Webhook.js
Normal file
@@ -0,0 +1,39 @@
|
||||
"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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user