Skip to content

Commit 9a16965

Browse files
committed
merge
1 parent 66669a6 commit 9a16965

File tree

2 files changed

+376
-14
lines changed

2 files changed

+376
-14
lines changed

bot/cogs/config.py

+34
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Annotated,
88
Any,
99
AsyncIterator,
10+
Literal,
1011
NamedTuple,
1112
Optional,
1213
Union,
@@ -26,9 +27,11 @@
2627
from libs.utils.pages import SimplePages
2728
from libs.utils.pages.paginator import RoboPages
2829
from libs.utils.prefix import get_prefix
30+
from libs.utils.time import FriendlyTimeResult, UserFriendlyTime
2931

3032
if TYPE_CHECKING:
3133
from cogs.tickets import Tickets
34+
3235
from rodhaj import Rodhaj
3336

3437

@@ -669,6 +672,37 @@ async def config_options(self, ctx: GuildContext, sort: bool) -> None:
669672
pages = ConfigPages(guild_settings.to_dict(), ctx=ctx, sort=sort)
670673
await pages.start()
671674

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+
672706
@check_permissions(manage_guild=True)
673707
@commands.guild_only()
674708
@config.command(name="set")

0 commit comments

Comments
 (0)