mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
feat(Webhook): add ability to change channel and specify reason to edit (#3587)
* feat(Webhook): add ability to change channel and specify reason to edit * fix(RESTMethods): update channelID of the webhook too
This commit is contained in:
@@ -801,13 +801,23 @@ class RESTMethods {
|
||||
.then(data => new Webhook(this.client, data));
|
||||
}
|
||||
|
||||
editWebhook(webhook, name, avatar) {
|
||||
return this.rest.makeRequest('patch', Endpoints.Webhook(webhook.id, webhook.token), false, {
|
||||
name,
|
||||
avatar,
|
||||
}).then(data => {
|
||||
editWebhook(webhook, options, reason) {
|
||||
let endpoint;
|
||||
let auth;
|
||||
|
||||
// Changing the channel of a webhook or specifying a reason requires a bot token
|
||||
if (options.channel_id || reason) {
|
||||
endpoint = Endpoints.Webhook(webhook.id);
|
||||
auth = true;
|
||||
} else {
|
||||
endpoint = Endpoints.Webhook(webhook.id, webhook.token);
|
||||
auth = false;
|
||||
}
|
||||
|
||||
return this.rest.makeRequest('patch', endpoint, auth, options, undefined, reason).then(data => {
|
||||
webhook.name = data.name;
|
||||
webhook.avatar = data.avatar;
|
||||
webhook.channelID = data.channel_id;
|
||||
return webhook;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user