This commit is contained in:
parent
92a0c23b49
commit
7abdcd4d95
@ -26,18 +26,21 @@ public abstract class BatCommand {
|
|||||||
/**
|
/**
|
||||||
* The info of this command.
|
* The info of this command.
|
||||||
*/
|
*/
|
||||||
@NonNull private final InternalCommandInfo info;
|
@NonNull
|
||||||
|
private final InternalCommandInfo info;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The feature this command belongs to.
|
* The feature this command belongs to.
|
||||||
*/
|
*/
|
||||||
@Setter private Feature feature;
|
@Setter
|
||||||
|
private Feature feature;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The snowflake of this command, set when
|
* The snowflake of this command, set when
|
||||||
* this command is registered with Discord.
|
* this command is registered with Discord.
|
||||||
*/
|
*/
|
||||||
@Setter private long snowflake;
|
@Setter
|
||||||
|
private long snowflake;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The sub commands of this command, if any.
|
* The sub commands of this command, if any.
|
||||||
@ -47,27 +50,28 @@ public abstract class BatCommand {
|
|||||||
/**
|
/**
|
||||||
* The internal data for this command.
|
* The internal data for this command.
|
||||||
*/
|
*/
|
||||||
@Setter(AccessLevel.PRIVATE) private CommandDataImpl commandData;
|
@Setter(AccessLevel.PRIVATE)
|
||||||
|
private CommandDataImpl commandData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The internal subcommand data for this command.
|
* The internal subcommand data for this command.
|
||||||
*/
|
*/
|
||||||
@Setter(AccessLevel.PRIVATE) private SubcommandData subcommandData;
|
@Setter(AccessLevel.PRIVATE)
|
||||||
|
private SubcommandData subcommandData;
|
||||||
|
|
||||||
public BatCommand() {
|
public BatCommand() {
|
||||||
if (!getClass().isAnnotationPresent(CommandInfo.class)) {
|
if (!getClass().isAnnotationPresent(CommandInfo.class)) {
|
||||||
throw new IllegalStateException("Missing @CommandInfo annotation in " + getClass().getSimpleName());
|
throw new IllegalStateException("Missing @CommandInfo annotation in " + getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
info = new InternalCommandInfo(getClass().getAnnotation(CommandInfo.class));
|
info = new InternalCommandInfo(getClass().getAnnotation(CommandInfo.class));
|
||||||
|
|
||||||
List<IntegrationType> integrationTypes = new ArrayList<>(Collections.singletonList(IntegrationType.GUILD_INSTALL));
|
|
||||||
if (info.isUserInstall()) {
|
|
||||||
integrationTypes.add(IntegrationType.USER_INSTALL);
|
|
||||||
}
|
|
||||||
System.out.println(integrationTypes);
|
|
||||||
commandData = new CommandDataImpl(info.getName(), info.getDescription())
|
commandData = new CommandDataImpl(info.getName(), info.getDescription())
|
||||||
.setIntegrationTypes(integrationTypes)
|
.setIntegrationTypes(info.isUserInstall() ?
|
||||||
.setGuildOnly(info.isGuildOnly());
|
EnumSet.of(IntegrationType.USER_INSTALL) :
|
||||||
|
EnumSet.of(IntegrationType.GUILD_INSTALL)
|
||||||
|
).setContexts(info.isGuildOnly() ?
|
||||||
|
EnumSet.of(InteractionContextType.GUILD) :
|
||||||
|
EnumSet.of(InteractionContextType.GUILD, InteractionContextType.BOT_DM, InteractionContextType.PRIVATE_CHANNEL)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,7 +83,8 @@ public abstract class BatCommand {
|
|||||||
* @param member the member who executed the command, null if not a guild
|
* @param member the member who executed the command, null if not a guild
|
||||||
* @param event the event that invoked this command
|
* @param event the event that invoked this command
|
||||||
*/
|
*/
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) { }
|
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction event) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the given sub commands.
|
* Register the given sub commands.
|
||||||
|
Loading…
Reference in New Issue
Block a user