mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
* Uses classmethods to create predicates * Classmethods allow using a combination of different parameters to describe context * Some predicates assign a captured `result` to the predicate object on success * Added `ReactionPredicate` equivalent to `MessagePredicate` * Added `utils.menus.start_adding_reactions`, a non-blocking method for adding reactions asynchronously * Added documentation * Uses these new utils throughout the core bot Happened to also find some bugs in places, and places where we were waiting for events without catching `asyncio.TimeoutError` Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
import asyncio
|
|
|
|
from redbot.core import commands
|
|
from redbot.core.utils.predicates import MessagePredicate
|
|
|
|
__all__ = ["do_install_agreement"]
|
|
|
|
REPO_INSTALL_MSG = (
|
|
"You're about to add a 3rd party repository. The creator of Red"
|
|
" and its community have no responsibility for any potential "
|
|
"damage that the content of 3rd party repositories might cause."
|
|
"\n\nBy typing '**I agree**' you declare that you have read and"
|
|
" fully understand the above message. This message won't be "
|
|
"shown again until the next reboot.\n\nYou have **30** seconds"
|
|
" to reply to this message."
|
|
)
|
|
|
|
|
|
async def do_install_agreement(ctx: commands.Context):
|
|
downloader = ctx.cog
|
|
if downloader is None or downloader.already_agreed:
|
|
return True
|
|
|
|
await ctx.send(REPO_INSTALL_MSG)
|
|
|
|
try:
|
|
await ctx.bot.wait_for(
|
|
"message", check=MessagePredicate.lower_equal_to("i agree", ctx), timeout=30
|
|
)
|
|
except asyncio.TimeoutError:
|
|
await ctx.send("Your response has timed out, please try again.")
|
|
return False
|
|
|
|
downloader.already_agreed = True
|
|
return True
|