Exemple #1
0
 def set_message(self, msg: discord.Message) -> typing.Awaitable:
     """Edits state message to display voting and sends options to participants.
     """
     tasks = []
     self.state_msg = msg
     tasks.append(msg.edit(content=None, embed=self.results_embed()))
     return asyncio.gather(*tasks)
 def execute_qlx_command(self, user: discord.User, message: Message,
                         qlx_command: str):
     discord_interaction = DiscordInteractionChannel(user,
                                                     message,
                                                     loop=self.bot.loop)
     try:
         minqlx.COMMANDS.handle_input(discord_interaction, qlx_command,
                                      discord_interaction)
     except Exception as e:  # pylint: disable=broad-except
         send_message = message.edit(content=f"{e.__class__.__name__}: {e}")
         asyncio.run_coroutine_threadsafe(send_message, loop=self.bot.loop)
         minqlx.log_exception()
Exemple #3
0
    async def wait(self, message: discord.Message):
        content = message.content

        remaining_time = 20
        for time in [4, 5, 5, 2, 1, 1, 1]:
            await asyncio.sleep(time)
            remaining_time -= time
            asyncio.create_task(
                message.edit(content=content +
                             f" (`{remaining_time - 1}초` 남음)"))

        await asyncio.sleep(remaining_time)
Exemple #4
0
async def confirm_action(
    ctx: commands.Context,
    message: Union[str, discord.Embed, Tuple[str, discord.Embed],
                   List] = "Are you sure?",
    base_message: discord.Message = None,
    timeout: float = 60.0,
) -> tuple:
    """Checks if you're sure you want to continue.

    Arguments:
        ctx {commands.Context} -- Information about where the command was run.

    Keyword Arguments:
        message {str} -- What it asks you about. (default: {"Are you sure?"})
        base_message {commands.Message} -- The message to use. (default: {None})
        timeout {float} -- How long to wait until canceling. (default: {60.0})

    Returns:
        (bool, commands.Message) -- The result and the message used to ask confirmation.
    """
    embed = None
    if isinstance(message, (list, tuple)):
        embed = message[1]
        message = message[0]

    if base_message is not None:
        confirm = base_message.edit(content=message, embed=embed)
    else:
        try:
            confirm = await ctx.send(content=message, embed=embed)
        except discord.HTTPException:
            return (False, confirm)

    reaction = await wait_for_reactions(ctx, confirm, (emojis.yes, emojis.no))

    if reaction is not None and reaction.emoji == emojis.yes:
        return (True, confirm)

    return (False, confirm)
Exemple #5
0
 def set_message(self, msg: discord.Message) -> Awaitable:
     """Edit state message to show actual information
     """
     return msg.edit(content=self.title, embed=None)
Exemple #6
0
 def _safe_edit(self, message: discord.Message, *args,
                **kwargs) -> discord.Message:
     return message.edit(*args, **kwargs)
Exemple #7
0
 def set_message(self, msg: discord.Message) -> typing.Awaitable:
     text = self.title + '\n' + '**{}** vs. **{}**'.format(
         self.author.display_name, self.subject.display_name)
     return msg.edit(content=text, embed=None)
Exemple #8
0
 def set_message(self, msg: discord.Message) -> typing.Awaitable:
     content = self.title + ' - {}wieszamy'.format(
         'nie ' if self.hang is False else '')
     return msg.edit(content=content, embed=None)