Exemplo n.º 1
0
async def type_message(destination: discord.abc.Messageable, content: str,
                       **kwargs) -> discord.Message:
    """Simulate typing and sending a message to a destination.
        Will send a typing indicator, wait a variable amount of time based on the length
        of the text (to simulate typing speed), then send the message.
        """
    content = common_filters.filter_urls(content)
    try:
        async with destination.typing():
            await asyncio.sleep(max(0.25, min(2.5, len(content) * 0.01)))
            return await destination.send(content=content, **kwargs)
    except discord.HTTPException:
        pass
Exemplo n.º 2
0
async def type_message(destination: discord.abc.Messageable, content: str,
                       **kwargs) -> discord.Message:
    """Simulate typing and sending a message to a destination.

    Will send a typing indicator, wait a variable amount of time based on the length
    of the text (to simulate typing speed), then send the message.
    """
    content = common_filters.filter_mass_mentions(content)
    content = common_filters.filter_urls(content)
    content = common_filters.filter_various_mentions(content)
    try:
        async with destination.typing():
            await asyncio.sleep(len(content) * 0.01)
            return await destination.send(content=content, **kwargs)
    except discord.HTTPException:
        pass  # Not allowed to send messages to this destination (or, sending the message failed)