-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for installation and interaction contexts #86
base: master
Are you sure you want to change the base?
Changes from 2 commits
52caca3
ceb30f8
cc2c67e
92186b4
4446edb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,13 @@ | |
import net.dv8tion.jda.api.entities.GuildVoiceState; | ||
import net.dv8tion.jda.api.entities.Member; | ||
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel; | ||
import net.dv8tion.jda.api.interactions.InteractionContextType; | ||
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions; | ||
import net.dv8tion.jda.api.interactions.commands.build.CommandData; | ||
import net.dv8tion.jda.api.interactions.commands.build.Commands; | ||
|
||
import java.util.Set; | ||
|
||
public abstract class MessageContextMenu extends ContextMenu | ||
{ | ||
/** | ||
|
@@ -174,7 +177,18 @@ public CommandData buildCommandData() | |
else | ||
data.setDefaultPermissions(DefaultMemberPermissions.enabledFor(this.userPermissions)); | ||
|
||
data.setGuildOnly(this.guildOnly); | ||
Set<InteractionContextType> contexts = getContexts(); | ||
|
||
// manually set to true | ||
if (this.guildOnly == null) { | ||
// do nothing!!! nothing!!!! | ||
} else if (this.guildOnly) { | ||
// remove bot dm from contexts | ||
contexts.remove(InteractionContextType.BOT_DM); | ||
} else if (!this.guildOnly) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See previous comment. |
||
contexts.add(InteractionContextType.BOT_DM); | ||
} | ||
data.setNSFW(this.nsfwOnly); | ||
|
||
return data; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,13 +23,17 @@ | |
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel; | ||
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent; | ||
import net.dv8tion.jda.api.interactions.DiscordLocale; | ||
import net.dv8tion.jda.api.interactions.IntegrationType; | ||
import net.dv8tion.jda.api.interactions.InteractionContextType; | ||
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions; | ||
import net.dv8tion.jda.api.interactions.commands.build.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
/** | ||
* <h2><b>Slash Commands In JDA-Chewtils</b></h2> | ||
|
@@ -470,7 +474,29 @@ public CommandData buildCommandData() | |
else | ||
data.setDefaultPermissions(DefaultMemberPermissions.enabledFor(this.getUserPermissions())); | ||
|
||
data.setGuildOnly(this.guildOnly); | ||
data.setNSFW(this.nsfwOnly); | ||
|
||
Set<InteractionContextType> contexts = getContexts(); | ||
|
||
// manually set to true | ||
if (this.guildOnly == null) { | ||
// do nothing!!! nothing!!!! | ||
} else if (this.guildOnly) { | ||
// remove bot dm from contexts | ||
contexts.remove(InteractionContextType.BOT_DM); | ||
} else if (!this.guildOnly) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See first comment. |
||
contexts.add(InteractionContextType.BOT_DM); | ||
} | ||
|
||
Set<IntegrationType> types = new HashSet<>(); | ||
if (contexts.contains(InteractionContextType.PRIVATE_CHANNEL)) { | ||
types.add(IntegrationType.USER_INSTALL); | ||
} else if (contexts.contains(InteractionContextType.BOT_DM) || contexts.contains(InteractionContextType.GUILD)) { | ||
types.add(IntegrationType.GUILD_INSTALL); | ||
} | ||
|
||
data.setIntegrationTypes(types); | ||
data.setContexts(contexts); | ||
|
||
return data; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,13 @@ | |
import net.dv8tion.jda.api.entities.GuildVoiceState; | ||
import net.dv8tion.jda.api.entities.Member; | ||
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel; | ||
import net.dv8tion.jda.api.interactions.InteractionContextType; | ||
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions; | ||
import net.dv8tion.jda.api.interactions.commands.build.CommandData; | ||
import net.dv8tion.jda.api.interactions.commands.build.Commands; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* <h2><b>User Context Menus In JDA-Chewtils</b></h2> | ||
* | ||
|
@@ -212,7 +215,18 @@ public CommandData buildCommandData() | |
else | ||
data.setDefaultPermissions(DefaultMemberPermissions.enabledFor(this.userPermissions)); | ||
|
||
data.setGuildOnly(this.guildOnly); | ||
Set<InteractionContextType> contexts = getContexts(); | ||
|
||
// manually set to true | ||
if (this.guildOnly == null) { | ||
// do nothing!!! nothing!!!! | ||
} else if (this.guildOnly) { | ||
// remove bot dm from contexts | ||
contexts.remove(InteractionContextType.BOT_DM); | ||
} else if (!this.guildOnly) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blablabla first comment. |
||
contexts.add(InteractionContextType.BOT_DM); | ||
} | ||
data.setNSFW(this.nsfwOnly); | ||
|
||
return data; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure a simple
} else {
should work here given you already check for null and if it is true. And since it's a boolean can there only be false be left by the logic.