Skip to content

Commit 36d8565

Browse files
authored
Merge pull request #39 from abalabahaha/dev
feat(Application): Support application emojis (abalabahaha#1559)
2 parents 2bb2568 + ae295d0 commit 36d8565

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

index.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,15 @@ declare namespace Eris {
711711
image: string;
712712
roles?: string[];
713713
}
714+
interface EditApplicationEmojiOptions {
715+
name: string;
716+
}
717+
interface ApplicationEmojiOptions extends EditApplicationEmojiOptions {
718+
image: string;
719+
}
720+
interface ApplicationEmojis {
721+
items: Emoji[];
722+
}
714723
interface PartialEmoji {
715724
id: string | null;
716725
name: string;
@@ -2188,6 +2197,7 @@ declare namespace Eris {
21882197
reason?: string
21892198
): Promise<Webhook>;
21902199
createCommand<T extends ApplicationCommandTypes>(command: ApplicationCommandCreateOptions<false, T>): Promise<ApplicationCommand<false, T>>;
2200+
createEmoji(options: ApplicationEmojiOptions): Promise<Emoji>;
21912201
createGroupChannel(userIDs: string[]): Promise<GroupChannel>;
21922202
createGuild(name: string, options?: CreateGuildOptions): Promise<Guild>;
21932203
createGuildCommand<T extends ApplicationCommandTypes>(guildID: string, command: ApplicationCommandCreateOptions<true, T>): Promise<ApplicationCommand<true, T>>;
@@ -2211,6 +2221,7 @@ declare namespace Eris {
22112221
deleteChannel(channelID: string, reason?: string): Promise<void>;
22122222
deleteChannelPermission(channelID: string, overwriteID: string, reason?: string): Promise<void>;
22132223
deleteCommand(commandID: string): Promise<void>;
2224+
deleteEmoji(emojiID: string): Promise<void>;
22142225
deleteGuild(guildID: string): Promise<void>;
22152226
deleteGuildCommand(guildID: string, commandID: string): Promise<void>;
22162227
deleteGuildDiscoverySubcategory(guildID: string, categoryID: string, reason?: string): Promise<void>;
@@ -2246,6 +2257,7 @@ declare namespace Eris {
22462257
editChannelPosition(channelID: string, position: number, options?: EditChannelPositionOptions): Promise<void>;
22472258
editChannelPositions(guildID: string, channelPositions: ChannelPosition[]): Promise<void>;
22482259
editCommand<T extends ApplicationCommandTypes>(commandID: string, command: ApplicationCommandEditOptions<false, T>): Promise<ApplicationCommand<false, T>>;
2260+
editEmoji(emojiID: string, options: EditApplicationEmojiOptions): Promise<Emoji>;
22492261
editCommandPermissions(guildID: string, commandID: string, permissions: ApplicationCommandPermissions[], reason?: string): Promise<GuildApplicationCommandPermissions>;
22502262
editGuild(guildID: string, options: GuildOptions, reason?: string): Promise<Guild>;
22512263
editGuildCommand<T extends ApplicationCommandTypes>(guildID: string, commandID: string, command: ApplicationCommandEditOptions<true, T>): Promise<ApplicationCommand<true, T>>;
@@ -2311,6 +2323,8 @@ declare namespace Eris {
23112323
getCommands(): Promise<ApplicationCommand<false>[]>;
23122324
getDiscoveryCategories(): Promise<DiscoveryCategory[]>;
23132325
getDMChannel(userID: string): Promise<DMChannel>;
2326+
getEmoji(emojiID: string): Promise<Emoji>;
2327+
getEmojis(): Promise<ApplicationEmojis>;
23142328
getEmojiGuild(emojiID: string): Promise<Guild>;
23152329
getGateway(): Promise<{ url: string }>;
23162330
getGuildAuditLog(guildID: string, options?: GetGuildAuditLogOptions): Promise<GuildAuditLog>;

lib/Client.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,17 @@ class Client extends EventEmitter {
683683
return this.requestHandler.request("POST", Endpoints.COMMANDS(this.application.id), true, command).then((command) => new ApplicationCommand(command, this));
684684
}
685685

686+
/**
687+
* Create an emoji for this application
688+
* @arg {Object} options Emoji options
689+
* @arg {String} options.image The base 64 encoded string
690+
* @arg {String} options.name The name of emoji
691+
* @returns {Promise<Object>} An emoji object
692+
*/
693+
createEmoji(options) {
694+
return this.requestHandler.request("POST", Endpoints.APPLICATION_EMOJIS(this.application.id), true, options);
695+
}
696+
686697
/**
687698
* Create a group channel with other users
688699
* @arg {Object} options The options for the group channel
@@ -1237,6 +1248,15 @@ class Client extends EventEmitter {
12371248
return this.requestHandler.request("DELETE", Endpoints.COMMAND(this.application.id, commandID), true);
12381249
}
12391250

1251+
/**
1252+
* Delete an emoji for this application
1253+
* @arg {String} emojiID The id of the emoji
1254+
* @returns {Promise}
1255+
*/
1256+
deleteEmoji(emojiID) {
1257+
return this.requestHandler.request("DELETE", Endpoints.APPLICATION_EMOJI(this.application.id, emojiID), true);
1258+
}
1259+
12401260
/**
12411261
* Delete a guild (bot user must be owner)
12421262
* @arg {String} guildID The ID of the guild
@@ -1681,6 +1701,16 @@ class Client extends EventEmitter {
16811701
return this.requestHandler.request("PATCH", Endpoints.COMMAND(this.application.id, commandID), true, command).then((command) => new ApplicationCommand(command, this));
16821702
}
16831703

1704+
/**
1705+
* Edit an existing emoji for this application
1706+
* @arg {Object} options Emoji options
1707+
* @arg {String} options.name The name of emoji
1708+
* @returns {Promise<Object>} An emoji object
1709+
*/
1710+
editEmoji(emojiID, options) {
1711+
return this.requestHandler.request("PATCH", Endpoints.APPLICATION_EMOJI(this.application.id, emojiID), true, options);
1712+
}
1713+
16841714
/**
16851715
* Edits command permissions for a specific command in a guild.
16861716
* Note: You can only add up to 10 permission overwrites for a command.
@@ -2603,6 +2633,39 @@ class Client extends EventEmitter {
26032633
}).then((dmChannel) => new DMChannel(dmChannel, this));
26042634
}
26052635

2636+
/**
2637+
* Get an emoji for this application
2638+
* @arg {String} emojiID The ID of the emoji
2639+
* @returns {Promise<Object>} Resolves with an emoji object
2640+
*/
2641+
getEmoji(emojiID) {
2642+
return this.requestHandler.request("GET", Endpoints.APPLICATION_EMOJI(this.application.id, emojiID), true).then((emoji) => {
2643+
if (emoji.user) {
2644+
emoji.user = this.users.update(emoji.user, this);
2645+
}
2646+
2647+
return emoji;
2648+
});
2649+
}
2650+
2651+
/**
2652+
* Get the emojis for this application
2653+
* @returns {Promise<Object>} Resolves with an object that contains a property "items" which is an array of emoji objects
2654+
*/
2655+
getEmojis() {
2656+
return this.requestHandler.request("GET", Endpoints.APPLICATION_EMOJIS(this.application.id), true).then((data) => {
2657+
data.items = data.items.map((emoji) => {
2658+
if (emoji.user) {
2659+
emoji.user = this.users.update(emoji.user, this);
2660+
}
2661+
2662+
return emoji;
2663+
});
2664+
2665+
return data;
2666+
});
2667+
}
2668+
26062669
/**
26072670
* Get a guild from the guild's emoji ID
26082671
* @arg {String} emojiID The ID of the emoji

lib/rest/Endpoints.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)