From bda4d5037f2c069fc5dffe8b0df64fef307d509a Mon Sep 17 00:00:00 2001 From: freya02 <41875020+freya022@users.noreply.github.com> Date: Sat, 30 Mar 2024 00:01:23 +0100 Subject: [PATCH] Fix example --- src/examples/java/SlashBotExample.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/examples/java/SlashBotExample.java b/src/examples/java/SlashBotExample.java index 0b993c758c..49931641cf 100644 --- a/src/examples/java/SlashBotExample.java +++ b/src/examples/java/SlashBotExample.java @@ -23,6 +23,7 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; +import net.dv8tion.jda.api.interactions.InteractionContextType; import net.dv8tion.jda.api.interactions.InteractionHook; import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions; import net.dv8tion.jda.api.interactions.commands.OptionMapping; @@ -56,7 +57,7 @@ public static void main(String[] args) .addOptions(new OptionData(INTEGER, "del_days", "Delete messages from the past days.") // This is optional .setRequiredRange(0, 7)) // Only allow values between 0 and 7 (inclusive) .addOptions(new OptionData(STRING, "reason", "The ban reason to use (default: Banned by )")) // optional reason - .setGuildOnly(true) // This way the command can only be executed from a guild, and not the DMs + .setContexts(InteractionContextType.GUILD) // This way the command can only be executed from a guild, and not the DMs .setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.BAN_MEMBERS)) // Only members with the BAN_MEMBERS permission are going to see this command ); @@ -69,14 +70,14 @@ public static void main(String[] args) // Commands without any inputs commands.addCommands( Commands.slash("leave", "Make the bot leave the server") - .setGuildOnly(true) // this doesn't make sense in DMs + .setContexts(InteractionContextType.GUILD) // this doesn't make sense in DMs .setDefaultPermissions(DefaultMemberPermissions.DISABLED) // only admins should be able to use this command. ); commands.addCommands( Commands.slash("prune", "Prune messages from this channel") .addOption(INTEGER, "amount", "How many messages to prune (Default 100)") // simple optional argument - .setGuildOnly(true) + .setContexts(InteractionContextType.GUILD) .setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MESSAGE_MANAGE)) );