mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
Added resolveImage to reduce code duplication (#1820)
* add client#resolveImage * oops * resolveFile fix * async is the future * async * update doc example * build fix * doc fix * fix docs * thx hydar
This commit is contained in:
@@ -157,18 +157,11 @@ class GroupDMChannel extends Channel {
|
||||
|
||||
/**
|
||||
* Sets a new icon for this Group DM.
|
||||
* @param {Base64Resolvable} icon The new icon of this Group DM
|
||||
* @param {Base64Resolvable|BufferResolvable} icon The new icon of this Group DM
|
||||
* @returns {Promise<GroupDMChannel>}
|
||||
*/
|
||||
setIcon(icon) {
|
||||
if (typeof icon === 'string' && icon.startsWith('data:')) {
|
||||
return this.edit({ icon });
|
||||
} else if (!icon) {
|
||||
return this.edit({ icon: null });
|
||||
} else {
|
||||
return this.client.resolver.resolveBuffer(icon)
|
||||
.then(data => this.edit({ icon: this.client.resolver.resolveBase64(data) }));
|
||||
}
|
||||
async setIcon(icon) {
|
||||
return this.edit({ icon: await this.client.resolver.resolveImage(icon) });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user