Skip to content

Commit

Permalink
fix(commands): if canUseInDms is false, then set InteractionContextTy…
Browse files Browse the repository at this point in the history
…pe.GUILD
  • Loading branch information
seailz committed Apr 18, 2024
1 parent e867d5a commit 98592f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/com/seailz/discordjar/command/Command.java
Expand Up @@ -2,6 +2,7 @@

import com.seailz.discordjar.command.annotation.Locale;
import com.seailz.discordjar.core.Compilerable;
import com.seailz.discordjar.model.interaction.Interaction;
import com.seailz.discordjar.model.interaction.InteractionContextType;
import com.seailz.discordjar.utils.flag.BitwiseUtil;
import com.seailz.discordjar.utils.permission.Permission;
Expand Down Expand Up @@ -80,8 +81,11 @@ public JSONObject compile() {

JSONArray contextsJson = new JSONArray();
contexts.forEach((context) -> contextsJson.put(context.getCode()));
if (!canUseInDms) {
contextsJson.clear();
contextsJson.put(InteractionContextType.GUILD.getCode());
}
obj.put("contexts", contextsJson);

return obj;
}

Expand Down
Expand Up @@ -48,6 +48,8 @@

/**
* Contexts where this command can be used. Default is all contexts.
* <br>Using this in conjunction with {@link #canUseInDms()} may not work, as then canUseInDms is set to true,
* contexts is automatically cleared and set to ONLY InteractionContextType.GUILD. Please only use this option.
*/
InteractionContextType[] contexts() default {InteractionContextType.BOT_DM, InteractionContextType.GUILD, InteractionContextType.PRIVATE_CHANNEL};

Expand Down

0 comments on commit 98592f6

Please sign in to comment.