|
7 | 7 | Annotated,
|
8 | 8 | Any,
|
9 | 9 | AsyncIterator,
|
| 10 | + Literal, |
10 | 11 | NamedTuple,
|
11 | 12 | Optional,
|
12 | 13 | Union,
|
|
26 | 27 | from libs.utils.pages import SimplePages
|
27 | 28 | from libs.utils.pages.paginator import RoboPages
|
28 | 29 | from libs.utils.prefix import get_prefix
|
| 30 | +from libs.utils.time import FriendlyTimeResult, UserFriendlyTime |
29 | 31 |
|
30 | 32 | if TYPE_CHECKING:
|
31 | 33 | from cogs.tickets import Tickets
|
| 34 | + |
32 | 35 | from rodhaj import Rodhaj
|
33 | 36 |
|
34 | 37 |
|
@@ -669,6 +672,37 @@ async def config_options(self, ctx: GuildContext, sort: bool) -> None:
|
669 | 672 | pages = ConfigPages(guild_settings.to_dict(), ctx=ctx, sort=sort)
|
670 | 673 | await pages.start()
|
671 | 674 |
|
| 675 | + @check_permissions(manage_guild=True) |
| 676 | + @commands.guild_only() |
| 677 | + @config.command(name="set-age") |
| 678 | + async def config_set_age( |
| 679 | + self, |
| 680 | + ctx: GuildContext, |
| 681 | + type: Literal["guild", "account"], |
| 682 | + *, |
| 683 | + duration: Annotated[ |
| 684 | + FriendlyTimeResult, UserFriendlyTime(commands.clean_content, default="…") |
| 685 | + ], |
| 686 | + ) -> None: |
| 687 | + """Sets an minium duration for age-related options |
| 688 | +
|
| 689 | + This command handles all age-related options. This means you can use this |
| 690 | + to set the minimum age required to use Rodhaj |
| 691 | + """ |
| 692 | + if type in "guild": |
| 693 | + clause = "SET guild_age = $2" |
| 694 | + else: |
| 695 | + clause = "SET account_age = $2" |
| 696 | + |
| 697 | + query = f""" |
| 698 | + UPDATE guild_config |
| 699 | + {clause} |
| 700 | + WHERE id = $1; |
| 701 | + """ |
| 702 | + await self.bot.pool.execute(query, ctx.guild.id, duration.td) |
| 703 | + self.get_guild_settings.cache_invalidate(ctx.guild.id) |
| 704 | + await ctx.send(f"Set `{type}_age` to `{duration.td}`") |
| 705 | + |
672 | 706 | @check_permissions(manage_guild=True)
|
673 | 707 | @commands.guild_only()
|
674 | 708 | @config.command(name="set")
|
|
0 commit comments