Skip to content

Commit 955f0be

Browse files
committed
feat: more duration parameters for timeout and giveaway
1 parent 54c9dfb commit 955f0be

File tree

2 files changed

+91
-13
lines changed

2 files changed

+91
-13
lines changed

src/commands/giveaway.ts

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,29 @@ export const data = new SlashCommandBuilder()
1919
.setDescription("The sacred relic to be bestowed")
2020
.setRequired(true),
2121
)
22+
.addIntegerOption((option) =>
23+
option
24+
.setName("days")
25+
.setDescription("Duration of the gathering in days")
26+
.setRequired(false)
27+
.setMinValue(0)
28+
.setMaxValue(7),
29+
)
30+
.addIntegerOption((option) =>
31+
option
32+
.setName("hours")
33+
.setDescription("Duration of the gathering in hours")
34+
.setRequired(false)
35+
.setMinValue(0)
36+
.setMaxValue(168),
37+
)
2238
.addIntegerOption((option) =>
2339
option
2440
.setName("minutes")
2541
.setDescription("Duration of the gathering in minutes")
26-
.setRequired(true)
27-
.setMinValue(1)
28-
.setMaxValue(1440),
42+
.setRequired(false)
43+
.setMinValue(0)
44+
.setMaxValue(10080),
2945
)
3046
.addIntegerOption((option) =>
3147
option
@@ -41,9 +57,24 @@ export async function execute(
4157
executor: GuildMember,
4258
): Promise<void> {
4359
const prize = interaction.options.getString("prize")!;
44-
const durationMinutes = interaction.options.getInteger("minutes")!;
60+
61+
const days = interaction.options.getInteger("days") ?? 0;
62+
const hours = interaction.options.getInteger("hours") ?? 0;
63+
const minutes = interaction.options.getInteger("minutes") ?? 0;
64+
65+
const totalMinutes = days * 24 * 60 + hours * 60 + minutes;
66+
67+
if (totalMinutes < 1) {
68+
await interaction.reply({
69+
content:
70+
"**THOU MUST DECLARE A DURATION!** Provide at least 1 minute (days/hours/minutes).",
71+
flags: MessageFlags.Ephemeral,
72+
});
73+
return;
74+
}
75+
4576
const winnerCount = interaction.options.getInteger("winners") || 1;
46-
const durationMs = durationMinutes * 60 * 1000;
77+
const durationMs = totalMinutes * 60 * 1000;
4778
const endTime = new Date(Date.now() + durationMs);
4879

4980
const joinButton = new ButtonBuilder()

src/commands/timeout.ts

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,29 @@ export const data = new SlashCommandBuilder()
1616
.setDescription("The transgressor to be silenced")
1717
.setRequired(true),
1818
)
19+
.addIntegerOption((option) =>
20+
option
21+
.setName("days")
22+
.setDescription("Days of silence")
23+
.setRequired(false)
24+
.setMinValue(0)
25+
.setMaxValue(28),
26+
)
27+
.addIntegerOption((option) =>
28+
option
29+
.setName("hours")
30+
.setDescription("Hours of silence")
31+
.setRequired(false)
32+
.setMinValue(0)
33+
.setMaxValue(23),
34+
)
1935
.addIntegerOption((option) =>
2036
option
2137
.setName("minutes")
22-
.setDescription("Duration of silence in minutes")
23-
.setRequired(true)
24-
.setMinValue(1)
25-
.setMaxValue(40320),
38+
.setDescription("Minutes of silence")
39+
.setRequired(false)
40+
.setMinValue(0)
41+
.setMaxValue(59),
2642
)
2743
.addStringOption((option) =>
2844
option
@@ -36,7 +52,12 @@ export async function execute(
3652
executor: GuildMember,
3753
): Promise<void> {
3854
const targetUser = interaction.options.getUser("user")!;
39-
const duration = interaction.options.getInteger("minutes")!;
55+
const days = interaction.options.getInteger("days") ?? 0;
56+
const hours = interaction.options.getInteger("hours") ?? 0;
57+
const minutes = interaction.options.getInteger("minutes") ?? 0;
58+
59+
const totalMinutes = days * 24 * 60 + hours * 60 + minutes;
60+
4061
const reason =
4162
interaction.options.getString("reason") || "Violation of sacred Alteruism";
4263

@@ -58,7 +79,25 @@ export async function execute(
5879
}
5980

6081
try {
61-
await targetMember.timeout(duration * 60 * 1000, reason);
82+
if (totalMinutes <= 0) {
83+
await interaction.reply({
84+
content:
85+
"**THOU MUST DECREE A DURATION! Provide at least 1 minute (days/hours/minutes).**",
86+
flags: MessageFlags.Ephemeral,
87+
});
88+
return;
89+
}
90+
91+
if (totalMinutes > 40320) {
92+
await interaction.reply({
93+
content:
94+
"**THE DECREE EXCEEDS THE DIVINE LIMIT!** Maximum silence is **40320 minutes (28 days)**.",
95+
flags: MessageFlags.Ephemeral,
96+
});
97+
return;
98+
}
99+
100+
await targetMember.timeout(totalMinutes * 60 * 1000, reason);
62101

63102
const entryId = await ModerationLogger.addEntry({
64103
type: "timeout",
@@ -68,9 +107,17 @@ export async function execute(
68107
moderatorTag: executor.user.tag,
69108
reason: reason,
70109
guildId: interaction.guild.id,
71-
duration: duration,
110+
duration: totalMinutes,
72111
});
73112

113+
const durationParts: string[] = [];
114+
if (days) durationParts.push(`${days} day${days === 1 ? "" : "s"}`);
115+
if (hours) durationParts.push(`${hours} hour${hours === 1 ? "" : "s"}`);
116+
if (minutes)
117+
durationParts.push(`${minutes} minute${minutes === 1 ? "" : "s"}`);
118+
const durationDisplay =
119+
durationParts.join(", ") || `${totalMinutes} minutes`;
120+
74121
const embed = new EmbedBuilder()
75122
.setColor("#FFD700")
76123
.setTitle("🤐 DIVINE SILENCE IMPOSED")
@@ -86,7 +133,7 @@ export async function execute(
86133
{ name: "ACTION ID", value: `${entryId}`, inline: true },
87134
{
88135
name: "DURATION OF REFLECTION",
89-
value: `${duration} minutes`,
136+
value: `${durationDisplay} (${totalMinutes} minutes)`,
90137
inline: true,
91138
},
92139
{ name: "REASON FOR SILENCE", value: reason, inline: false },

0 commit comments

Comments
 (0)