From 547cc63c4f43c6e9425d009da407863affc6ab18 Mon Sep 17 00:00:00 2001 From: Chew Date: Mon, 1 Nov 2021 15:29:55 -0500 Subject: [PATCH] Allow longs for setting IDs --- .../command/CommandClientBuilder.java | 51 ++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/command/src/main/java/com/jagrosh/jdautilities/command/CommandClientBuilder.java b/command/src/main/java/com/jagrosh/jdautilities/command/CommandClientBuilder.java index a4e9e403..16395e56 100644 --- a/command/src/main/java/com/jagrosh/jdautilities/command/CommandClientBuilder.java +++ b/command/src/main/java/com/jagrosh/jdautilities/command/CommandClientBuilder.java @@ -16,6 +16,7 @@ package com.jagrosh.jdautilities.command; import java.util.ArrayList; +import java.util.Arrays; import java.util.LinkedList; import java.util.function.Consumer; @@ -100,7 +101,23 @@ public CommandClientBuilder setOwnerId(String ownerId) this.ownerId = ownerId; return this; } - + + /** + * Sets the owner for the bot. + *
Make sure to verify that the ID provided is ISnowflake compatible when setting this. + * If it is not, this will warn the developer. + * + * @param ownerId + * The ID of the owner. + * + * @return This builder + */ + public CommandClientBuilder setOwnerId(long ownerId) + { + this.ownerId = String.valueOf(ownerId); + return this; + } + /** * Sets the one or more CoOwners of the bot. *
Make sure to verify that all of the IDs provided are ISnowflake compatible when setting this. @@ -116,7 +133,23 @@ public CommandClientBuilder setCoOwnerIds(String... coOwnerIds) this.coOwnerIds = coOwnerIds; return this; } - + + /** + * Sets the one or more CoOwners of the bot. + *
Make sure to verify that all of the IDs provided are ISnowflake compatible when setting this. + * If it is not, this will warn the developer which ones are not. + * + * @param coOwnerIds + * The ID(s) of the CoOwners + * + * @return This builder + */ + public CommandClientBuilder setCoOwnerIds(long... coOwnerIds) + { + this.coOwnerIds = Arrays.stream(coOwnerIds).mapToObj(String::valueOf).toArray(String[]::new); + return this; + } + /** * Sets the bot's prefix. *
If set null, empty, or not set at all, the bot will use a mention {@literal @Botname} as a prefix. @@ -395,6 +428,20 @@ public CommandClientBuilder forceGuildOnly(String guildId) return this; } + /** + * Forces Guild Only for SlashCommands. + * This is the same as setting this.guildOnly = true and this.guildId = your value for every command. + * Setting this to null disables the feature, but it is off by default. + * + * @param guildId the guild ID. + * @return This Builder + */ + public CommandClientBuilder forceGuildOnly(long guildId) + { + this.forcedGuildId = String.valueOf(guildId); + return this; + } + /** * Whether or not to manually upsert slash commands. * This is designed if you want to handle upserting, instead of doing it every boot.