mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53:31 +01:00
resolveImage backport (#1822)
* add resolveImage * add groupDMChannel#setIcon + icon getter * doc fix * crawl no kill pls * *whistles* * channe
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const Channel = require('./Channel');
|
||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||
const Collection = require('../util/Collection');
|
||||
const Constants = require('../util/Constants');
|
||||
|
||||
/*
|
||||
{ type: 3,
|
||||
@@ -105,6 +106,23 @@ class GroupDMChannel extends Channel {
|
||||
return this.client.users.get(this.ownerID);
|
||||
}
|
||||
|
||||
/**
|
||||
* The URL to this guild's icon
|
||||
* @type {?string}
|
||||
* @readonly
|
||||
*/
|
||||
get iconURL() {
|
||||
if (!this.icon) return null;
|
||||
return Constants.Endpoints.Channel(this).Icon(this.client.options.http.cdn, this.icon);
|
||||
}
|
||||
|
||||
edit(data) {
|
||||
const _data = {};
|
||||
if (data.name) _data.name = data.name;
|
||||
if (data.icon) _data.icon = data.icon;
|
||||
return this.client.rest.methods.updateGroupDMChannel(this, _data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this channel equals another channel. It compares all properties, so for most operations
|
||||
* it is advisable to just compare `channel.id === channel2.id` as it is much faster and is often
|
||||
@@ -140,6 +158,20 @@ class GroupDMChannel extends Channel {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new GroupDMChannel icon.
|
||||
* @param {Base64Resolvable|BufferResolvable} icon The new icon of the group dm
|
||||
* @returns {Promise<Guild>}
|
||||
* @example
|
||||
* // Edit the group dm icon
|
||||
* channel.setIcon('./icon.png')
|
||||
* .then(updated => console.log('Updated the channel icon'))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
setIcon(icon) {
|
||||
return this.client.resolver.resolveImage(icon).then(data => this.edit({ icon: data }));
|
||||
}
|
||||
|
||||
/**
|
||||
* When concatenated with a string, this automatically concatenates the channel's name instead of the Channel object.
|
||||
* @returns {string}
|
||||
|
||||
Reference in New Issue
Block a user