-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
192 lines (161 loc) · 7.75 KB
/
index.html
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html>
<html>
<head>
<title>KordCommandApi</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/themes/prism-twilight.min.css" />
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/themes/prism-tomorrow.min.css" /> heller -->
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/themes/prism-twilight.min.css" /> dunkler -->
<style>
/* Override border properties for code blocks */
pre[class*="language-"] {
border: none !important;
padding: 13px !important;
margin: 0 !important;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/components/prism-clike.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/components/prism-kotlin.min.js"></script>
</head>
<body>
<div style="text-align: center; padding-bottom: 15px; padding-top: 10px;">
<a class="noblue" href="https://github.com/flerbuster" target="_blank">
<h1 style="display: inline; font-size: 125%; margin: 0;">Flerbuster/</h1>
</a>
<a class="noblue" href="https://github.com/flerbuster/KordCommandApi" target="_blank">
<h1 style="display: inline; font-size: 300%; margin: 0;">KordCommandApi</h1>
</a>
</div>
<div class="info">
<p>Die KordCommandApi ist eine leistungsstarke API für die Verwaltung von Befehlen in Kord.</p>
<p>Um die API zu nutzen, musst du zuerst die KordCommandApi-Bibliothek in dein Projekt einbinden.</p>
<p>Dann kannst du Befehle erstellen, bearbeiten und ausführen, um deine Discord-Bot-Funktionalität zu erweitern.</p>
<p>Weniger Informationen findest du in der offiziellen Dokumentation der <a target="_blank" href="https://github.com/flerbuster/KordCommandApi">KordCommandApi</a>.</p>
</div>
<div class="info">
<p>hier gehts zum <a href="https://github.com/flerbuster/KordCommandApi/releases/download/fler/KordCommandApi-0.1.8.7.jar">Download</a></p>
</div>
<p>You can create slash commands like this</p>
<div class="pre-container"><pre><code class="language-kotlin">val exampleCommand = slashCommand("examplecommand", "this is an example command", kord) {
}<button class="copy-button"/></code>
</pre></div>
<p>You can now add arguments and what passiert when command gets executed</p>
<div class="pre-container"><pre><code class="language-kotlin">val exampleCommand = slashCommand("examplecommand", "this is an example command", kord) {
argument<ArgumentType>("argument name", "argument description") {
required = true/false
}
or
basicArgument<BasicArgumentType>("argument name", "argument description") {
required = true/false
}
runs { interaction, options ->
val example = options.ArgumentType(e.g. strings)["argument name"]
interaction.respondPublic {
content = example
}
}
}<button class="copy-button"/></code></pre></div>
<div class="info">
<p>Argument Types can include String, Int, Number</p>
<p>Basic Argument Types include Boolean, User, Membner, Mentionable, Channel, Role, SubCommand, Group, Attachment, you can <strong>not</strong> add choices to these, as they are given by discord</p>
</div>
<div class="info">
<p><i><u>options</u></i> is always an instance of an subclass of <u>BaseOptions</u></p>
<p><strong>Abstract properties</strong></p>
<p> - strings: Map<String, String> </p>
<p> - integers: Map<String, Long></p>
<p> - numbers: Map<String, Double></p>
<p> - booleans: Map<String, Boolean></p>
<p> - users: Map<String, User></p>
<p> - members: Map<String, Member></p>
<p> - channels: Map<String, ResolvedChannel></p>
<p> - roles: Map<String, Role></p>
<p> - mentionables: Map<String, Entity></p>
<p> - attachments: Map<String, Attachment></p>
<p><strong>Abstract functions</strong></p>
<p> - inline fun <reified T> custom(stringFormat: StringFormat = Json): HashMap<String, T></p>
<p> - operator fun <T : Comparable<T>> get(at: String): T? </p>
<p> - operator fun get(at: String): Comparable<*>? </p>
</div>
<p>You can also add required choices for the user to arguments</p>
<div class="pre-container"><pre><code class="language-kotlin">argument<ArgumentType>("argument name", "argument description") {
required = true/false
choice("choice 1 (seen by user)", "choice1" (what gets passed to options, must be same type as argument))
}<button class="copy-button"/></code></pre></div>
<p>if you do not want to be stuck with the normal argument types, you can also do custom ones, they need to be Serializable</p>
<div class="pre-container"><pre>
<code class="language-kotlin">@Serializable
data class ExampleCustomClass(
stringValue: String,
integerValue: Int
)
....
customArgument<ExampleCustomClass>("argument name", "argument description") {
required = true/false
choice("choice 1 (seen by user)", ExampleCustomClass("value 1", 1))
choice("choice 2 (seen by user)", ExampleCustomClass("value 2", 2))
}<button class="copy-button"/></code></pre></div>
<p>you can then get the value the user chose at runtime</p>
<div class="pre-container"><pre><code class="language-kotlin"> runs { interaction, options ->
val example = options.custom<ExampleCustomClass>()["argument name"]
}</code><button class="copy-button"/></pre></div></div>
<p>This is an complete example</p>
<div class="pre-container"><pre><code class="language-kotlin">import dev.kord.core.Kord
import dev.kord.core.behavior.interaction.respondEphemeral
import dev.kord.core.behavior.interaction.respondPublic
import dev.kord.core.entity.User
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import kotlin.random.Random
@Serializable
data class Fler(val type: Int, val fler: String)
class ExceptionThatMightHappen : Exception("fler")
val flerCommand = slashCommand("fler", "fler", Bot.kord) {
val json = Json {
ignoreUnknownKeys = true
prettyPrint = true
prettyPrintIndent = " ".repeat(187)
}
basicArgument<User>("user", "user who gets flered") {
required = true
}
customArgument("fler", "type of fler") {
choice("fler1", Fler(1, "das ist hier ist fler 1"), json)
choice("fler2", Fler(2, "das ist hier ist fler 2"), json)
choice("fler3", Fler(3, "das ist hier ist fler 3"), json)
required = true
}
runs { interaction, options ->
val user = options.users["user"]!!
val fler = options.custom<Fler>(json)["fler"]!!
if (Random.nextBoolean()) throw ExceptionThatMightHappen()
interaction.respondPublic {
content = "hm ${user.mention} wurde mit $fler geflert"
}
}
catches<ExceptionThatMightHappen> { exception, interaction, command ->
interaction.respondEphemeral { content = "hm jop exception passiert" }
}
}
object Bot {
val kord = runBlocking { Kord("TOKEN") }
suspend fun run() {
flerCommand
kord.login()
}
}
suspend fun main() {
Bot.run()
}</code><button class="copy-button"/></button></pre></div>
<script src="script.js" type="module"></script>
<script>
// Apply syntax highlighting to all code blocks
Prism.highlightAll();
</script>
</body>
</html>