Example #1
0
    def _payload_has_duckpond_emoji(self, emoji: discord.PartialEmoji) -> bool:
        """Test if the RawReactionActionEvent payload contains a duckpond emoji."""
        if emoji.is_unicode_emoji():
            # For unicode PartialEmojis, the `name` attribute is just the string
            # representation of the emoji. This is what the helper method
            # expects, as unicode emojis show up as just a `str` instance when
            # inspecting the reactions attached to a message.
            emoji = emoji.name

        return self._is_duck_emoji(emoji)
Example #2
0
    async def on_control_reaction_add(self, _, message: discord.Message,
                                      emoji: discord.PartialEmoji):
        if not message.embeds or message.author != self.bot.me or not emoji.is_unicode_emoji(
        ):
            return

        emoji = emoji.name
        embed = message.embeds[0]

        if 'MC Bot Help page' in embed.author.name:
            await self.switch_help_page(emoji, message)
Example #3
0
def dumbEmojiFromPartial(e : PartialEmoji) -> dumbEmoji:
    """Construct a new dumbEmoji object from a given discord.PartialEmoji.

    :return: A dumbEmoji representing e
    :rtype: dumbEmoji
    """
    if type(e) == dumbEmoji:
        return e
    if e.is_unicode_emoji():
        return dumbEmoji(unicode=e.name)
    else:
        return dumbEmoji(id=e.id)
Example #4
0
def get_proficiency_by_emoji(emoji: PartialEmoji):
    global proficiency_emojis
    if proficiency_emojis is None:
        proficiency_emojis = {
            0: '1️⃣',
            1: '2️⃣',
            2: '3️⃣',
            3: '4️⃣'
        }

    if emoji.is_unicode_emoji():
        for key in proficiency_emojis:
            if proficiency_emojis[key] == emoji.name:
                return key
    return None
Example #5
0
def is_emoji_equal(
    partial_emoji: discord.PartialEmoji,
    emoji: Union[str, discord.Emoji, discord.PartialEmoji],
):
    """
    Utility to compare a partial emoji with any other kind of emoji
    """
    if isinstance(emoji, discord.PartialEmoji):
        return partial_emoji == emoji

    if isinstance(emoji, discord.Emoji):
        if partial_emoji.is_unicode_emoji():
            return False

        return emoji.id == partial_emoji.id

    return str(partial_emoji) == emoji
Example #6
0
    def fromPartial(cls,
                    e: PartialEmoji,
                    rejectInvalid: bool = False) -> BasedEmoji:
        """Construct a new BasedEmoji object from a given discord.PartialEmoji.

        :param bool rejectInvalid: When true, an exception is guaranteed to raise if an invalid emoji is requested,
                                    regardless of raiseUnknownEmojis (Default False)
        :raise exceptions.UnrecognisedCustomEmoji: When rejectInvalid=True is present in kwargs, and a custom emoji
                                                    is given that does not exist or the client cannot access.
        :return: A BasedEmoji representing e
        :rtype: BasedEmoji
        """
        if isinstance(e, BasedEmoji):
            return e
        if e.is_unicode_emoji():
            return BasedEmoji(unicode=e.name, rejectInvalid=rejectInvalid)
        else:
            return BasedEmoji(id=e.id, rejectInvalid=rejectInvalid)