Skip to content

Commit cc56a7a

Browse files
committed
Make label/emoji button combinations nullable, improve docs
1 parent 4345628 commit cc56a7a

File tree

1 file changed

+25
-31
lines changed
  • src/main/kotlin/io/github/freya022/botcommands/api/components

1 file changed

+25
-31
lines changed

src/main/kotlin/io/github/freya022/botcommands/api/components/Buttons.kt

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ import javax.annotation.CheckReturnValue
154154
@RequiresComponents
155155
class Buttons internal constructor(componentController: ComponentController) : AbstractComponentFactory(componentController) {
156156
/**
157-
* Creates a button factory with the style and label provided.
157+
* Creates a button factory with the provided style and label.
158158
*
159159
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
160160
*
@@ -167,7 +167,7 @@ class Buttons internal constructor(componentController: ComponentController) : A
167167
ButtonFactory(componentController, style, label, null, disabled = false)
168168

169169
/**
170-
* Creates a button factory with the style and emoji provided.
170+
* Creates a button factory with the provided style and emoji.
171171
*
172172
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
173173
*
@@ -179,7 +179,7 @@ class Buttons internal constructor(componentController: ComponentController) : A
179179
ButtonFactory(componentController, style, null, emoji, disabled = false)
180180

181181
/**
182-
* Creates a button factory with the style, label and emoji provided.
182+
* Creates a button factory with the provided style, label and emoji.
183183
*
184184
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
185185
*
@@ -198,7 +198,7 @@ class Buttons internal constructor(componentController: ComponentController) : A
198198
*
199199
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
200200
*
201-
* @throws IllegalArgumentException If the label is null/blank and the emoji isn't set
201+
* @throws IllegalArgumentException If the label is null/blank, and the emoji isn't set
202202
*
203203
* @see Emojis
204204
* @see ButtonContent.withEmoji
@@ -208,7 +208,7 @@ class Buttons internal constructor(componentController: ComponentController) : A
208208
ButtonFactory(componentController, content.style, content.label, content.emoji, content.disabled)
209209

210210
/**
211-
* Creates a primary button factory with the label provided.
211+
* Creates a primary button factory with the provided label.
212212
*
213213
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
214214
*
@@ -221,7 +221,7 @@ class Buttons internal constructor(componentController: ComponentController) : A
221221
of(ButtonStyle.PRIMARY, label)
222222

223223
/**
224-
* Creates a primary button factory with the emoji provided.
224+
* Creates a primary button factory with the provided emoji.
225225
*
226226
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
227227
*
@@ -233,7 +233,7 @@ class Buttons internal constructor(componentController: ComponentController) : A
233233
of(ButtonStyle.PRIMARY, emoji)
234234

235235
/**
236-
* Creates a primary button factory with the emoji provided.
236+
* Creates a primary button factory with the provided emoji.
237237
*
238238
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
239239
*
@@ -243,11 +243,11 @@ class Buttons internal constructor(componentController: ComponentController) : A
243243
* @see ButtonFactory.withEmoji
244244
*/
245245
@CheckReturnValue
246-
fun primary(label: String, emoji: Emoji): ButtonFactory =
246+
fun primary(label: String?, emoji: Emoji?): ButtonFactory =
247247
of(ButtonStyle.PRIMARY, label, emoji)
248248

249249
/**
250-
* Creates a secondary button factory with the label provided.
250+
* Creates a secondary button factory with the provided label.
251251
*
252252
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
253253
*
@@ -260,7 +260,7 @@ class Buttons internal constructor(componentController: ComponentController) : A
260260
of(ButtonStyle.SECONDARY, label)
261261

262262
/**
263-
* Creates a secondary button factory with the emoji provided.
263+
* Creates a secondary button factory with the provided emoji.
264264
*
265265
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
266266
*
@@ -272,7 +272,7 @@ class Buttons internal constructor(componentController: ComponentController) : A
272272
of(ButtonStyle.SECONDARY, emoji)
273273

274274
/**
275-
* Creates a secondary button factory with the emoji provided.
275+
* Creates a secondary button factory with the provided emoji.
276276
*
277277
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
278278
*
@@ -282,11 +282,11 @@ class Buttons internal constructor(componentController: ComponentController) : A
282282
* @see ButtonFactory.withEmoji
283283
*/
284284
@CheckReturnValue
285-
fun secondary(label: String, emoji: Emoji): ButtonFactory =
285+
fun secondary(label: String?, emoji: Emoji?): ButtonFactory =
286286
of(ButtonStyle.SECONDARY, label, emoji)
287287

288288
/**
289-
* Creates a success button factory with the label provided.
289+
* Creates a success button factory with the provided label.
290290
*
291291
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
292292
*
@@ -299,7 +299,7 @@ class Buttons internal constructor(componentController: ComponentController) : A
299299
of(ButtonStyle.SUCCESS, label)
300300

301301
/**
302-
* Creates a success button factory with the emoji provided.
302+
* Creates a success button factory with the provided emoji.
303303
*
304304
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
305305
*
@@ -311,7 +311,7 @@ class Buttons internal constructor(componentController: ComponentController) : A
311311
of(ButtonStyle.SUCCESS, emoji)
312312

313313
/**
314-
* Creates a success button factory with the emoji provided.
314+
* Creates a success button factory with the provided emoji.
315315
*
316316
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
317317
*
@@ -321,11 +321,11 @@ class Buttons internal constructor(componentController: ComponentController) : A
321321
* @see ButtonFactory.withEmoji
322322
*/
323323
@CheckReturnValue
324-
fun success(label: String, emoji: Emoji): ButtonFactory =
324+
fun success(label: String?, emoji: Emoji?): ButtonFactory =
325325
of(ButtonStyle.SUCCESS, label, emoji)
326326

327327
/**
328-
* Creates a danger button factory with the label provided.
328+
* Creates a danger button factory with the provided label.
329329
*
330330
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
331331
*
@@ -338,7 +338,7 @@ class Buttons internal constructor(componentController: ComponentController) : A
338338
of(ButtonStyle.DANGER, label)
339339

340340
/**
341-
* Creates a danger button factory with the emoji provided.
341+
* Creates a danger button factory with the provided emoji.
342342
*
343343
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
344344
*
@@ -350,7 +350,7 @@ class Buttons internal constructor(componentController: ComponentController) : A
350350
of(ButtonStyle.DANGER, emoji)
351351

352352
/**
353-
* Creates a danger button factory with the emoji provided.
353+
* Creates a danger button factory with the provided emoji.
354354
*
355355
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
356356
*
@@ -360,13 +360,11 @@ class Buttons internal constructor(componentController: ComponentController) : A
360360
* @see ButtonFactory.withEmoji
361361
*/
362362
@CheckReturnValue
363-
fun danger(label: String, emoji: Emoji): ButtonFactory =
363+
fun danger(label: String?, emoji: Emoji?): ButtonFactory =
364364
of(ButtonStyle.DANGER, label, emoji)
365365

366366
/**
367-
* Creates a danger button factory with the label provided.
368-
*
369-
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
367+
* Creates a link button factory with the provided label.
370368
*
371369
* @throws IllegalArgumentException If the url/label is empty
372370
*/
@@ -375,9 +373,7 @@ class Buttons internal constructor(componentController: ComponentController) : A
375373
Button.link(url, label)
376374

377375
/**
378-
* Creates a danger button factory with the emoji provided.
379-
*
380-
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
376+
* Creates a link button factory with the provided emoji.
381377
*
382378
* @throws IllegalArgumentException If the url is empty
383379
*
@@ -388,15 +384,13 @@ class Buttons internal constructor(componentController: ComponentController) : A
388384
Button.link(url, emoji)
389385

390386
/**
391-
* Creates a danger button factory with the emoji provided.
392-
*
393-
* You can use [ButtonFactory.persistent] or [ButtonFactory.ephemeral] to then start building a button.
387+
* Creates a link button factory with the provided label and emoji.
394388
*
395389
* @throws IllegalArgumentException If the url/label is empty
396390
*
397391
* @see Emojis
398392
*/
399393
@CheckReturnValue
400-
fun link(url: String, label: String, emoji: Emoji): Button =
401-
Button.link(url, label).withEmoji(emoji)
394+
fun link(url: String, label: String?, emoji: Emoji?): Button =
395+
Button.of(ButtonStyle.LINK, url, label, emoji)
402396
}

0 commit comments

Comments
 (0)