Make DjDev happy

This commit is contained in:
ayntee 2020-12-26 11:05:26 +04:00
parent c7d117cd54
commit 95c2200386

View file

@ -47,9 +47,12 @@ export class Emoji extends Base {
async edit(data: ModifyGuildEmojiParams): Promise<Emoji> { async edit(data: ModifyGuildEmojiParams): Promise<Emoji> {
if (this.id === null) throw new Error('Emoji ID is not valid.') if (this.id === null) throw new Error('Emoji ID is not valid.')
if (this.guild === undefined) throw new Error('Guild is undefined') if (this.guild === undefined) throw new Error('Guild is undefined')
const roles = Array.isArray(data.roles)
? data.roles?.map((role) => (role instanceof Role ? role.id : role))
: [data.roles instanceof Role ? data.roles.id : data.roles]
const res = await this.client.rest.patch(EMOJI(this.guild.id, this.id), { const res = await this.client.rest.patch(EMOJI(this.guild.id, this.id), {
...data, ...data,
roles: data.roles?.map((role) => role.id) roles
}) })
return new Emoji(this.client, res) return new Emoji(this.client, res)
} }
@ -79,5 +82,5 @@ export interface ModifyGuildEmojiParams {
/** Name of the emoji */ /** Name of the emoji */
name?: string name?: string
/** Roles to which this emoji will be whitelisted */ /** Roles to which this emoji will be whitelisted */
roles?: Role[] roles?: string | Role | (string | Role)[]
} }