From 0c3a4471f8a97cf05d1531a27470400d24057edc Mon Sep 17 00:00:00 2001 From: RyGuy Date: Wed, 29 Mar 2023 22:06:10 -0400 Subject: [PATCH 1/2] add description option to start command --- .../java/com/jagrosh/giveawaybot/commands/StartCmd.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/jagrosh/giveawaybot/commands/StartCmd.java b/src/main/java/com/jagrosh/giveawaybot/commands/StartCmd.java index 25ef6644..b830f8bf 100644 --- a/src/main/java/com/jagrosh/giveawaybot/commands/StartCmd.java +++ b/src/main/java/com/jagrosh/giveawaybot/commands/StartCmd.java @@ -43,7 +43,8 @@ public StartCmd(GiveawayBot bot) .setDescription("starts a giveaway") .addOptions(new ApplicationCommandOption(ApplicationCommandOption.Type.STRING, "duration", "duration of the giveaway", true), new ApplicationCommandOption(ApplicationCommandOption.Type.INTEGER, "winners", "number of winners", true, 1, 50, false), - new ApplicationCommandOption(ApplicationCommandOption.Type.STRING, "prize", "the prize being given away", true)) + new ApplicationCommandOption(ApplicationCommandOption.Type.STRING, "prize", "the prize being given away", true), + new ApplicationCommandOption(ApplicationCommandOption.Type.STRING, "description", "a description of your giveaway", false)) .setDmPermission(false) .setDefaultPermissions(Permission.MANAGE_GUILD) .build(); @@ -61,7 +62,8 @@ public InteractionResponse gbExecute(Interaction interaction) throws GiveawayExc Giveaway g = bot.getGiveawayManager().constructGiveaway(interaction.getUser(), interaction.getCommandData().getOptionByName("duration").getStringValue(), interaction.getCommandData().getOptionByName("winners").getIntValue() + "", - interaction.getCommandData().getOptionByName("prize").getStringValue(), null, pl, interaction.getEffectiveLocale()); + interaction.getCommandData().getOptionByName("prize").getStringValue(), + interaction.getCommandData().getOptionByName("description").getStringValue(), pl, interaction.getEffectiveLocale()); // attempt giveaway creation long id = bot.getGiveawayManager().sendGiveaway(g, interaction.getGuildId(), interaction.getChannelId()); From a8b9014fd85ecf3000fcfc11e1fbcb43b5479530 Mon Sep 17 00:00:00 2001 From: RyGuy Date: Wed, 29 Mar 2023 22:10:07 -0400 Subject: [PATCH 2/2] handle null value properly, not sure if this is necessary --- src/main/java/com/jagrosh/giveawaybot/commands/StartCmd.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/jagrosh/giveawaybot/commands/StartCmd.java b/src/main/java/com/jagrosh/giveawaybot/commands/StartCmd.java index b830f8bf..1fbad890 100644 --- a/src/main/java/com/jagrosh/giveawaybot/commands/StartCmd.java +++ b/src/main/java/com/jagrosh/giveawaybot/commands/StartCmd.java @@ -63,7 +63,9 @@ public InteractionResponse gbExecute(Interaction interaction) throws GiveawayExc interaction.getCommandData().getOptionByName("duration").getStringValue(), interaction.getCommandData().getOptionByName("winners").getIntValue() + "", interaction.getCommandData().getOptionByName("prize").getStringValue(), - interaction.getCommandData().getOptionByName("description").getStringValue(), pl, interaction.getEffectiveLocale()); + interaction.getCommandData().getOptionByName("description") == null ? null : + interaction.getCommandData().getOptionByName("description").getStringValue(), + pl, interaction.getEffectiveLocale()); // attempt giveaway creation long id = bot.getGiveawayManager().sendGiveaway(g, interaction.getGuildId(), interaction.getChannelId());