-
-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PrimaryEntryPointInteractionEvent
- Loading branch information
Showing
5 changed files
with
164 additions
and
8 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
...ava/net/dv8tion/jda/api/events/interaction/command/PrimaryEntryPointInteractionEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.dv8tion.jda.api.events.interaction.command; | ||
|
||
import net.dv8tion.jda.api.JDA; | ||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; | ||
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion; | ||
import net.dv8tion.jda.api.interactions.commands.PrimaryEntryPointInteraction; | ||
import net.dv8tion.jda.api.interactions.commands.build.EntryPointCommandData; | ||
import net.dv8tion.jda.api.requests.restaction.GlobalCommandListUpdateAction; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Indicates that an activity entry point was used in a {@link MessageChannel}. | ||
* <br>This interaction requires <a href="https://discord.com/developers/docs/activities/overview" target="_blank">activities</a> to be enabled, | ||
* and an {@link GlobalCommandListUpdateAction#setEntryPointCommand(EntryPointCommandData) entry point} | ||
* with its {@link EntryPointCommandData#setHandler(EntryPointCommandData.Handler) handler} | ||
* set to {@link EntryPointCommandData.Handler#APP_HANDLER APP_HANDLER} to be configured. | ||
* | ||
* <p><b>Requirements</b><br> | ||
* To receive these events, you must unset the <b>Interactions Endpoint URL</b> in your application dashboard. | ||
* You can simply remove the URL for this endpoint in your settings at the <a href="https://discord.com/developers/applications" target="_blank">Discord Developers Portal</a>. | ||
* | ||
* @see PrimaryEntryPointInteraction | ||
*/ | ||
public class PrimaryEntryPointInteractionEvent extends GenericCommandInteractionEvent implements PrimaryEntryPointInteraction | ||
{ | ||
private final PrimaryEntryPointInteraction interaction; | ||
|
||
public PrimaryEntryPointInteractionEvent(@Nonnull JDA api, long responseNumber, @Nonnull PrimaryEntryPointInteraction interaction) | ||
{ | ||
super(api, responseNumber, interaction); | ||
this.interaction = interaction; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public PrimaryEntryPointInteraction getInteraction() | ||
{ | ||
return interaction; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public MessageChannelUnion getChannel() | ||
{ | ||
return interaction.getChannel(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/net/dv8tion/jda/api/interactions/commands/PrimaryEntryPointInteraction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.dv8tion.jda.api.interactions.commands; | ||
|
||
import net.dv8tion.jda.api.entities.channel.unions.GuildMessageChannelUnion; | ||
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion; | ||
import net.dv8tion.jda.api.interactions.commands.build.EntryPointCommandData; | ||
import net.dv8tion.jda.api.requests.restaction.GlobalCommandListUpdateAction; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Interaction to launch your app's activity. | ||
* | ||
* <p><b>Note:</b> This interaction requires <a href="https://discord.com/developers/docs/activities/overview" target="_blank">activities</a> to be enabled, | ||
* and an {@link GlobalCommandListUpdateAction#setEntryPointCommand(EntryPointCommandData) entry point} | ||
* with its {@link EntryPointCommandData#setHandler(EntryPointCommandData.Handler) handler} | ||
* set to {@link EntryPointCommandData.Handler#APP_HANDLER APP_HANDLER} to be configured. | ||
*/ | ||
public interface PrimaryEntryPointInteraction extends CommandInteraction | ||
{ | ||
/** | ||
* The respective {@link MessageChannelUnion} for this interaction. | ||
* | ||
* @return The {@link MessageChannelUnion} | ||
*/ | ||
@Nonnull | ||
@Override | ||
MessageChannelUnion getChannel(); | ||
|
||
@Nonnull | ||
@Override | ||
default GuildMessageChannelUnion getGuildChannel() | ||
{ | ||
return (GuildMessageChannelUnion) CommandInteraction.super.getGuildChannel(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
.../java/net/dv8tion/jda/internal/interactions/command/PrimaryEntryPointInteractionImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.dv8tion.jda.internal.interactions.command; | ||
|
||
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion; | ||
import net.dv8tion.jda.api.interactions.commands.PrimaryEntryPointInteraction; | ||
import net.dv8tion.jda.api.utils.data.DataObject; | ||
import net.dv8tion.jda.internal.JDAImpl; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class PrimaryEntryPointInteractionImpl extends CommandInteractionImpl implements PrimaryEntryPointInteraction | ||
{ | ||
public PrimaryEntryPointInteractionImpl(JDAImpl jda, DataObject data) | ||
{ | ||
super(jda, data); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
@SuppressWarnings("ConstantConditions") | ||
public MessageChannelUnion getChannel() | ||
{ | ||
return (MessageChannelUnion) super.getChannel(); | ||
} | ||
} |