How to use the disputils.multiple_choice.MultipleChoice function in disputils

To help you get started, we’ve selected a few disputils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LiBa001 / disputils / disputils / multiple_choice.py View on Github external
reaction, user = await self._client.wait_for('reaction_add', check=check, timeout=timeout)
        except asyncio.TimeoutError:
            self._choice = None
            return None, self.message

        if closable and reaction.emoji == self.close_emoji:
            self._choice = None
            return None, self.message

        index = self._emojis.index(reaction.emoji)
        self._choice = self.options[index]

        return self._choice, self.message


class BotMultipleChoice(MultipleChoice):
    def __init__(self, ctx: Context, options: list, title: str, description: str = "", **kwargs):
        super().__init__(ctx.bot, options, title, description, **kwargs)

        self._ctx = ctx

    async def run(self, users: List[User] = None, channel: TextChannel = None, **kwargs)\
            -> Tuple[Optional[str], Message]:

        if users is None:
            users = [self._ctx.author]

        if self.message is None and channel is None:
            channel = self._ctx.channel

        return await super().run(users, channel, **kwargs)

disputils

Some utilities for discord.py. Making Discord bot development easier.

MIT
Latest version published 4 years ago

Package Health Score

42 / 100
Full package analysis

Similar packages