ci: add Emoji#id check
This commit is contained in:
		
							parent
							
								
									73e9ba9a25
								
							
						
					
					
						commit
						a69988b653
					
				
					 2 changed files with 7 additions and 5 deletions
				
			
		|  | @ -7,8 +7,8 @@ import { Role } from './role.ts' | ||||||
| import { User } from './user.ts' | import { User } from './user.ts' | ||||||
| 
 | 
 | ||||||
| export class Emoji extends Base { | export class Emoji extends Base { | ||||||
|   id: string |   id: string | null | ||||||
|   name: string |   name: string | null | ||||||
|   roles?: string[] |   roles?: string[] | ||||||
|   user?: User |   user?: User | ||||||
|   guild?: Guild |   guild?: Guild | ||||||
|  | @ -41,8 +41,9 @@ export class Emoji extends Base { | ||||||
| 
 | 
 | ||||||
|   /** Modify the given emoji. Requires the MANAGE_EMOJIS permission. Returns the updated emoji object on success. Fires a Guild Emojis Update Gateway event. */ |   /** Modify the given emoji. Requires the MANAGE_EMOJIS permission. Returns the updated emoji object on success. Fires a Guild Emojis Update Gateway event. */ | ||||||
|   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.guild === undefined) throw new Error('Guild is undefined') |     if (this.guild === undefined) throw new Error('Guild is undefined') | ||||||
|     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: data.roles?.map((role) => role.id) | ||||||
|     }) |     }) | ||||||
|  | @ -51,6 +52,7 @@ export class Emoji extends Base { | ||||||
| 
 | 
 | ||||||
|   /** Delete the given emoji. Requires the MANAGE_EMOJIS permission. Returns `true` on success. Fires a Guild Emojis Update Gateway event. */ |   /** Delete the given emoji. Requires the MANAGE_EMOJIS permission. Returns `true` on success. Fires a Guild Emojis Update Gateway event. */ | ||||||
|   async delete(): Promise<boolean> { |   async delete(): Promise<boolean> { | ||||||
|  |     if (this.id === null) return false; | ||||||
|     if (this.guild === undefined) return false |     if (this.guild === undefined) return false | ||||||
|     await this.client.rest.delete(EMOJI(this.guild.id, this.id)) |     await this.client.rest.delete(EMOJI(this.guild.id, this.id)) | ||||||
|     return true |     return true | ||||||
|  |  | ||||||
|  | @ -1,8 +1,8 @@ | ||||||
| import { UserPayload } from './user.ts' | import { UserPayload } from './user.ts' | ||||||
| 
 | 
 | ||||||
| export interface EmojiPayload { | export interface EmojiPayload { | ||||||
|   id: string |   id: string | null | ||||||
|   name: string |   name: string | null | ||||||
|   roles?: string[] |   roles?: string[] | ||||||
|   user?: UserPayload |   user?: UserPayload | ||||||
|   require_colons?: boolean |   require_colons?: boolean | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue