Skip to content

Commit

Permalink
Add emojis endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
rigwild committed Jul 9, 2021
1 parent 29e65bf commit 31e687e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,19 @@ Here is the full list of available functions, check [`index.js`](./index.js).
- `api.pinnedMessages(channelId)`
- `api.addPin(channelId, messageId)`
- `api.deletePin(channelId, messageId)`
- `api.listEmojis(guildId)`
- `api.getEmoji(guildId, emojiId)`
- `api.createEmoji(guildId, name, image, roles)`
- `api.editEmoji(guildId, emojiId, name, roles)`
- `api.deleteEmoji(guildId, emojiId)`
- `api.changeNick(guildId, nick)`
- `api.leaveServer(guildId)`
- `api.getDMs()`
- `api.getUser(userId)`
- `api.getCurrentUser()`
- `api.editCurrentUser(username, avatar)`
- `api.listCurrentUserGuilds()`
- `api.listReactions(channelId, messageId, emojiUrl)`
- `api.addReaction(channelId, messageId, emojiUrl)`
- `api.deleteReaction(channelId, messageId, emojiUrl)`
- `api.typing(channelId)`
Expand Down
19 changes: 17 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,23 @@
addPin: (channelId, messageId) => apiCall(`/channels/${channelId}/pins/${messageId}`, null, 'PUT'),
deletePin: (channelId, messageId) => apiCall(`/channels/${channelId}/pins/${messageId}`, null, 'DELETE'),

listEmojis: guildId => apiCall(`/guilds/${guildId}/emojis`),
getEmoji: (guildId, emojiId) => apiCall(`/guilds/${guildId}/emojis/${emojiId}`),
createEmoji: (guildId, name, image, roles) => apiCall(`/guilds/${guildId}`, { name, image, roles }, 'POST'),
editEmoji: (guildId, emojiId, name, roles) => apiCall(`/guilds/${guildId}/${emojiId}`, { name, roles }, 'PATCH'),
deleteEmoji: (guildId, emojiId) => apiCall(`/guilds/${guildId}/${emojiId}`, null, 'DELETE'),

changeNick: (guildId, nick) => apiCall(`/guilds/${guildId}/members/@me/nick`, { nick }, 'PATCH'),
leaveServer: guildId => apiCall(`/users/@me/guilds/${guildId}`, null, 'DELETE'),

getDMs: () => apiCall(`/users/@me/channels`),
getUser: userId => apiCall(`/users/${userId}`),

getCurrentUser: () => apiCall('/users/@me'),
editCurrentUser: (username, avatar) => apiCall('/users/@me', { username, avatar }, 'PATCH'),
listCurrentUserGuilds: () => apiCall('/users/@me/guilds'),

listReactions: (channelId, messageId, emojiUrl) => apiCall(`/channels/${channelId}/messages/${messageId}/reactions/${emojiUrl}/@me`),
addReaction: (channelId, messageId, emojiUrl) => apiCall(`/channels/${channelId}/messages/${messageId}/reactions/${emojiUrl}/@me`, null, 'PUT'),
deleteReaction: (channelId, messageId, emojiUrl) => apiCall(`/channels/${channelId}/messages/${messageId}/reactions/${emojiUrl}/@me`, null, 'DELETE'),

Expand All @@ -78,11 +89,15 @@
var cid = '' // Current channel id

// Call this to update `cid` and `gid` to current channel and guild id
var id = () => {
var id = (log = true) => {
gid = window.location.href.split('/').slice(4)[0]
cid = window.location.href.split('/').slice(4)[1]
if (log) {
console.log(`\`gid\` was set to the guild id you are currently looking at (${gid})`)
console.log(`\`cid\` was set to the channel id you are currently looking at (${cid})`)
}
}
id()
id(false)

// Set your `Authorization` token here
var authHeader = ''
Expand Down

0 comments on commit 31e687e

Please sign in to comment.