Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 'raw' emojis #347

Merged
merged 5 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -89,6 +89,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 @@ -112,6 +119,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