mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 17:18:37 +01:00
Add support for role arguments in slash commands
This commit is contained in:
parent
2a1957229f
commit
ba5a8becfc
@ -4,22 +4,10 @@ package net.essentialsx.api.v2.services.discord;
|
|||||||
* Represents an argument type to be shown on the Discord client.
|
* Represents an argument type to be shown on the Discord client.
|
||||||
*/
|
*/
|
||||||
public enum InteractionCommandArgumentType {
|
public enum InteractionCommandArgumentType {
|
||||||
STRING(3),
|
STRING,
|
||||||
INTEGER(4),
|
INTEGER,
|
||||||
BOOLEAN(5),
|
BOOLEAN,
|
||||||
USER(6),
|
USER,
|
||||||
CHANNEL(7);
|
CHANNEL,
|
||||||
|
ROLE,
|
||||||
private final int id;
|
|
||||||
InteractionCommandArgumentType(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the internal Discord ID for this argument type.
|
|
||||||
* @return the internal Discord ID.
|
|
||||||
*/
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,13 @@ public interface InteractionEvent {
|
|||||||
*/
|
*/
|
||||||
InteractionChannel getChannelArgument(String key);
|
InteractionChannel getChannelArgument(String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to get the role representation of the argument by the given key or null if none by that key is present.
|
||||||
|
* @param key The key of the argument to lookup.
|
||||||
|
* @return the role value or null
|
||||||
|
*/
|
||||||
|
InteractionRole getRoleArgument(String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the channel ID where this interaction occurred.
|
* Gets the channel ID where this interaction occurred.
|
||||||
* @return the channel ID.
|
* @return the channel ID.
|
||||||
|
@ -9,6 +9,7 @@ import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
|||||||
import net.essentialsx.api.v2.services.discord.InteractionChannel;
|
import net.essentialsx.api.v2.services.discord.InteractionChannel;
|
||||||
import net.essentialsx.api.v2.services.discord.InteractionEvent;
|
import net.essentialsx.api.v2.services.discord.InteractionEvent;
|
||||||
import net.essentialsx.api.v2.services.discord.InteractionMember;
|
import net.essentialsx.api.v2.services.discord.InteractionMember;
|
||||||
|
import net.essentialsx.api.v2.services.discord.InteractionRole;
|
||||||
import net.essentialsx.discord.EssentialsDiscord;
|
import net.essentialsx.discord.EssentialsDiscord;
|
||||||
import net.essentialsx.discord.util.DiscordUtil;
|
import net.essentialsx.discord.util.DiscordUtil;
|
||||||
|
|
||||||
@ -79,6 +80,12 @@ public class InteractionEventImpl implements InteractionEvent {
|
|||||||
return mapping == null ? null : new InteractionChannelImpl(mapping.getAsGuildChannel());
|
return mapping == null ? null : new InteractionChannelImpl(mapping.getAsGuildChannel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InteractionRole getRoleArgument(String key) {
|
||||||
|
final OptionMapping mapping = event.getOption(key);
|
||||||
|
return mapping == null ? null : new InteractionRoleImpl(mapping.getAsRole());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChannelId() {
|
public String getChannelId() {
|
||||||
return event.getChannel().getId();
|
return event.getChannel().getId();
|
||||||
|
Loading…
Reference in New Issue
Block a user