mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Help] Let owners set menu reaction timeout (#5205)
* initial help reaction timeout with min 15, max 300 * slight wording change * docs! * aaa * Suggestions from code review, thank Jack! Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
parent
6a8968e34d
commit
f8664a4e8a
@ -1190,6 +1190,34 @@ mean some pages will exceed this limit.
|
|||||||
**Arguments:**
|
**Arguments:**
|
||||||
- ``<limit>`` - The max amount of characters to show per page in the help message.
|
- ``<limit>`` - The max amount of characters to show per page in the help message.
|
||||||
|
|
||||||
|
.. _core-command-helpset-reacttimeout:
|
||||||
|
|
||||||
|
""""""""""""""""""""
|
||||||
|
helpset reacttimeout
|
||||||
|
""""""""""""""""""""
|
||||||
|
|
||||||
|
**Syntax**
|
||||||
|
|
||||||
|
.. code-block:: none
|
||||||
|
|
||||||
|
[p]helpset reacttimeout <seconds>
|
||||||
|
|
||||||
|
**Description**
|
||||||
|
|
||||||
|
Set the timeout for reactions, if menus are enabled.
|
||||||
|
|
||||||
|
The default is 30 seconds.
|
||||||
|
The timeout has to be between 15 and 300 seconds.
|
||||||
|
|
||||||
|
**Examples:**
|
||||||
|
- ``[p]helpset reacttimeout 30`` - The default timeout.
|
||||||
|
- ``[p]helpset reacttimeout 60`` - Timeout of 1 minute.
|
||||||
|
- ``[p]helpset reacttimeout 15`` - Minimum allowed timeout.
|
||||||
|
- ``[p]helpset reacttimeout 300`` - Max allowed timeout (5 mins).
|
||||||
|
|
||||||
|
**Arguments:**
|
||||||
|
- ``<seconds>`` - The timeout, in seconds, of the reactions.
|
||||||
|
|
||||||
.. _core-command-helpset-resetformatter:
|
.. _core-command-helpset-resetformatter:
|
||||||
|
|
||||||
""""""""""""""""""""""
|
""""""""""""""""""""""
|
||||||
|
|||||||
@ -115,6 +115,7 @@ class RedBase(
|
|||||||
help__verify_exists=False,
|
help__verify_exists=False,
|
||||||
help__tagline="",
|
help__tagline="",
|
||||||
help__use_tick=False,
|
help__use_tick=False,
|
||||||
|
help__react_timeout=30,
|
||||||
description="Red V3",
|
description="Red V3",
|
||||||
invite_public=False,
|
invite_public=False,
|
||||||
invite_perm=0,
|
invite_perm=0,
|
||||||
|
|||||||
@ -78,6 +78,7 @@ class HelpSettings:
|
|||||||
tagline: str = ""
|
tagline: str = ""
|
||||||
delete_delay: int = 0
|
delete_delay: int = 0
|
||||||
use_tick: bool = False
|
use_tick: bool = False
|
||||||
|
react_timeout: int = 30
|
||||||
|
|
||||||
# Contrib Note: This is intentional to not accept the bot object
|
# Contrib Note: This is intentional to not accept the bot object
|
||||||
# There are plans to allow guild and user specific help settings
|
# There are plans to allow guild and user specific help settings
|
||||||
@ -131,6 +132,7 @@ class HelpSettings:
|
|||||||
"\nHelp shows unusable commands when asked directly: {verify_exists}"
|
"\nHelp shows unusable commands when asked directly: {verify_exists}"
|
||||||
"\nDelete delay: {delete_delay}"
|
"\nDelete delay: {delete_delay}"
|
||||||
"\nReact with a checkmark when help is sent via DM: {use_tick}"
|
"\nReact with a checkmark when help is sent via DM: {use_tick}"
|
||||||
|
"\nReaction timeout (only used if menus are used): {react_timeout} seconds"
|
||||||
"{tagline_info}"
|
"{tagline_info}"
|
||||||
).format_map(data)
|
).format_map(data)
|
||||||
|
|
||||||
@ -857,7 +859,9 @@ class RedHelpFormatter(HelpFormatterABC):
|
|||||||
m = await (ctx.send(embed=pages[0]) if embed else ctx.send(pages[0]))
|
m = await (ctx.send(embed=pages[0]) if embed else ctx.send(pages[0]))
|
||||||
c = menus.DEFAULT_CONTROLS if len(pages) > 1 else {"\N{CROSS MARK}": menus.close_menu}
|
c = menus.DEFAULT_CONTROLS if len(pages) > 1 else {"\N{CROSS MARK}": menus.close_menu}
|
||||||
# Allow other things to happen during menu timeout/interaction.
|
# Allow other things to happen during menu timeout/interaction.
|
||||||
asyncio.create_task(menus.menu(ctx, pages, c, message=m))
|
asyncio.create_task(
|
||||||
|
menus.menu(ctx, pages, c, message=m, timeout=help_settings.react_timeout)
|
||||||
|
)
|
||||||
# menu needs reactions added manually since we fed it a message
|
# menu needs reactions added manually since we fed it a message
|
||||||
menus.start_adding_reactions(m, c.keys())
|
menus.start_adding_reactions(m, c.keys())
|
||||||
|
|
||||||
|
|||||||
@ -3340,6 +3340,32 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
else:
|
else:
|
||||||
await ctx.send(_("Done. The delete delay has been set to {} seconds.").format(seconds))
|
await ctx.send(_("Done. The delete delay has been set to {} seconds.").format(seconds))
|
||||||
|
|
||||||
|
@helpset.command(name="reacttimeout")
|
||||||
|
async def helpset_reacttimeout(self, ctx: commands.Context, seconds: int):
|
||||||
|
"""Set the timeout for reactions, if menus are enabled.
|
||||||
|
|
||||||
|
The default is 30 seconds.
|
||||||
|
The timeout has to be between 15 and 300 seconds.
|
||||||
|
|
||||||
|
**Examples:**
|
||||||
|
- `[p]helpset reacttimeout 30` - The default timeout.
|
||||||
|
- `[p]helpset reacttimeout 60` - Timeout of 1 minute.
|
||||||
|
- `[p]helpset reacttimeout 15` - Minimum allowed timeout.
|
||||||
|
- `[p]helpset reacttimeout 300` - Max allowed timeout (5 mins).
|
||||||
|
|
||||||
|
**Arguments:**
|
||||||
|
- `<seconds>` - The timeout, in seconds, of the reactions.
|
||||||
|
"""
|
||||||
|
if seconds < 15:
|
||||||
|
await ctx.send(_("You must give a value of at least 15 seconds!"))
|
||||||
|
return
|
||||||
|
if seconds > 300:
|
||||||
|
await ctx.send(_("The timeout cannot be greater than 5 minutes!"))
|
||||||
|
return
|
||||||
|
|
||||||
|
await ctx.bot._config.help.react_timeout.set(seconds)
|
||||||
|
await ctx.send(_("Done. The reaction timeout has been set to {} seconds.").format(seconds))
|
||||||
|
|
||||||
@helpset.command(name="tagline")
|
@helpset.command(name="tagline")
|
||||||
async def helpset_tagline(self, ctx: commands.Context, *, tagline: str = None):
|
async def helpset_tagline(self, ctx: commands.Context, *, tagline: str = None):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user