-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTextBan.kt
More file actions
77 lines (72 loc) · 3.16 KB
/
TextBan.kt
File metadata and controls
77 lines (72 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package dev.freya02.botcommands.bot.readme
import dev.freya02.botcommands.jda.ktx.coroutines.await
import dev.freya02.botcommands.jda.ktx.messages.deleteDelayed
import io.github.freya022.botcommands.api.commands.annotations.Command
import io.github.freya022.botcommands.api.commands.text.BaseCommandEvent
import io.github.freya022.botcommands.api.commands.text.annotations.JDATextCommandVariation
import io.github.freya022.botcommands.api.commands.text.annotations.TextCommandData
import io.github.freya022.botcommands.api.commands.text.annotations.TextOption
import net.dv8tion.jda.api.entities.User
import java.util.concurrent.TimeUnit
import kotlin.time.Duration.Companion.seconds
@Command
class TextBan {
// Applies to all variations with this path
@TextCommandData(path = ["ban"], description = "Bans an user")
// Applies to this variation
@JDATextCommandVariation(path = ["ban"], description = "Bans the mentioned user")
suspend fun onTextBan(
event: BaseCommandEvent,
@TextOption user: User,
@TextOption(example = "2") timeframe: Long,
@TextOption unit: TimeUnit, // A resolver is used here
@TextOption(example = "Get banned") reason: String = "No reason supplied" // Optional
) {
// ...
event.reply("${user.asMention} has been banned")
.deleteDelayed(5.seconds)
.await()
}
@JDATextCommandVariation(path = ["ban"], description = "Bans an user by its name")
suspend fun onTextBanByName(
event: BaseCommandEvent,
@TextOption(example = "freya02") name: String,
@TextOption(example = "2") timeframe: Long,
@TextOption unit: TimeUnit, // A resolver is used here
@TextOption(example = "Get banned") reason: String = "No reason supplied" // Optional
) {
// ...
event.reply("$name has been banned")
.deleteDelayed(5.seconds)
.await()
}
// Applies to all variations with this path
@TextCommandData(path = ["ban", "temp"], description = "Temporarily bans an user")
// Applies to this variation
@JDATextCommandVariation(path = ["ban", "temp"], description = "Temporarily bans the mentioned user")
suspend fun onTextBanTemp(
event: BaseCommandEvent,
@TextOption user: User,
@TextOption(example = "2") timeframe: Long,
@TextOption unit: TimeUnit, // A resolver is used here
@TextOption(example = "Get banned") reason: String = "No reason supplied" // Optional
) {
// ...
event.reply("${user.asMention} has been banned")
.deleteDelayed(5.seconds)
.await()
}
@JDATextCommandVariation(path = ["ban", "temp"], description = "Temporarily bans an user by name")
suspend fun onTextBanTempByName(
event: BaseCommandEvent,
@TextOption(example = "freya02") name: String,
@TextOption(example = "2") timeframe: Long,
@TextOption unit: TimeUnit, // A resolver is used here
@TextOption(example = "Get banned") reason: String = "No reason supplied" // Optional
) {
// ...
event.reply("$name has been banned")
.deleteDelayed(5.seconds)
.await()
}
}