Skip to content

Commit

Permalink
Merge pull request #347 from ZiomaleQ/main
Browse files Browse the repository at this point in the history
Support 'raw' emojis
  • Loading branch information
Helloyunho authored May 17, 2023
2 parents f8f6a47 + d75c52f commit daca400
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/managers/messageReactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ export class MessageReactionsManager extends BaseManager<

/** Remove a specific Emoji from Reactions */
async removeEmoji(emoji: Emoji | string): Promise<MessageReactionsManager> {
emoji =
emoji instanceof String && emoji[0] === '<' ? emoji.substring(1) : emoji
emoji =
emoji instanceof String && emoji[emoji.length - 1] === '>'
? emoji.substring(0, emoji.length - 2)
: emoji
const val = encodeURIComponent(
(typeof emoji === 'object' ? emoji.id ?? emoji.name : emoji) as string
)
Expand All @@ -96,6 +102,13 @@ export class MessageReactionsManager extends BaseManager<
emoji: Emoji | string,
user: User | string
): Promise<MessageReactionsManager> {
emoji =
emoji instanceof String && emoji[0] === '<' ? emoji.substring(1) : emoji
emoji =
emoji instanceof String && emoji[emoji.length - 1] === '>'
? emoji.substring(0, emoji.length - 2)
: emoji

const val = encodeURIComponent(
(typeof emoji === 'object' ? emoji.id ?? emoji.name : emoji) as string
)
Expand Down
14 changes: 14 additions & 0 deletions src/structures/textChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ export class TextChannel extends Channel {
const findEmoji = await this.client.emojis.get(emoji)
if (findEmoji !== undefined) emoji = `${findEmoji.name}:${findEmoji.id}`
else throw new Error(`Emoji not found: ${emoji}`)
} else {
// strip out the <>
emoji = emoji[0] === '<' ? emoji.substring(1) : emoji
emoji =
emoji[emoji.length - 1] === '>'
? emoji.substring(0, emoji.length - 2)
: emoji
}
}
if (message instanceof Message) message = message.id
Expand All @@ -116,6 +123,13 @@ export class TextChannel extends Channel {
const findEmoji = await this.client.emojis.get(emoji)
if (findEmoji !== undefined) emoji = `${findEmoji.name}:${findEmoji.id}`
else throw new Error(`Emoji not found: ${emoji}`)
} else {
// strip out the <>
emoji = emoji[0] === '<' ? emoji.substring(1) : emoji
emoji =
emoji[emoji.length - 1] === '>'
? emoji.substring(0, emoji.length - 2)
: emoji
}
}
if (message instanceof Message) message = message.id
Expand Down

0 comments on commit daca400

Please sign in to comment.