-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6881029
commit 7960888
Showing
21 changed files
with
981 additions
and
119 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -10,5 +10,5 @@ repositories { | |
} | ||
|
||
dependencies { | ||
compile 'net.dv8tion:JDA:3.5.1_348' | ||
compile 'net.dv8tion:JDA:3.6.0_354' | ||
} |
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
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
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
115 changes: 115 additions & 0 deletions
115
src/main/java/fr/neutronstars/nbot/command/CommandArgs.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,115 @@ | ||
package fr.neutronstars.nbot.command; | ||
|
||
import fr.neutronstars.nbot.entity.*; | ||
import fr.neutronstars.nbot.entity.Channel; | ||
import fr.neutronstars.nbot.entity.Guild; | ||
import fr.neutronstars.nbot.entity.Message; | ||
import fr.neutronstars.nbot.entity.User; | ||
import net.dv8tion.jda.core.JDA; | ||
import net.dv8tion.jda.core.entities.*; | ||
|
||
public class CommandArgs | ||
{ | ||
private final JDA jda; | ||
private final String commandToString; | ||
private final String[] args; | ||
private final Message message; | ||
private final Guild guild; | ||
private final Channel channel; | ||
private final User user; | ||
private final CommandSender commandSender; | ||
private final SimpleCommand simpleCommand; | ||
private final Category category; | ||
private final Member member; | ||
private final PrivateChannel privateChannel; | ||
private final TextChannel textChannel; | ||
private final SelfUser selfUser; | ||
|
||
protected CommandArgs(JDA jda, String commandToString, String[] args, Message message, Guild guild, Channel channel, User user, CommandSender commandSender, SimpleCommand simpleCommand, Category category, Member member, PrivateChannel privateChannel, TextChannel textChannel, SelfUser selfUser) | ||
{ | ||
this.jda = jda; | ||
this.commandToString = commandToString; | ||
this.args = args; | ||
this.message = message; | ||
this.guild = guild; | ||
this.channel = channel; | ||
this.user = user; | ||
this.commandSender = commandSender; | ||
this.simpleCommand = simpleCommand; | ||
this.category = category; | ||
this.member = member; | ||
this.privateChannel = privateChannel; | ||
this.textChannel = textChannel; | ||
this.selfUser = selfUser; | ||
} | ||
|
||
public JDA getJda() | ||
{ | ||
return jda; | ||
} | ||
|
||
public User getUser() | ||
{ | ||
return user; | ||
} | ||
|
||
public TextChannel getTextChannel() | ||
{ | ||
return textChannel; | ||
} | ||
|
||
public String[] getArgs() | ||
{ | ||
return args; | ||
} | ||
|
||
public String getCommand() | ||
{ | ||
return commandToString; | ||
} | ||
|
||
public SimpleCommand getSimpleCommand() | ||
{ | ||
return simpleCommand; | ||
} | ||
|
||
public SelfUser getSelfUser() | ||
{ | ||
return selfUser; | ||
} | ||
|
||
public PrivateChannel getPrivateChannel() | ||
{ | ||
return privateChannel; | ||
} | ||
|
||
public Member getMember() | ||
{ | ||
return member; | ||
} | ||
|
||
public Guild getGuild() | ||
{ | ||
return guild; | ||
} | ||
|
||
public CommandSender getCommandSender() | ||
{ | ||
return commandSender; | ||
} | ||
|
||
public Channel getChannel() | ||
{ | ||
return channel; | ||
} | ||
|
||
public Category getCategory() | ||
{ | ||
return category; | ||
} | ||
|
||
public Message getMessage() | ||
{ | ||
return message; | ||
} | ||
} |
114 changes: 114 additions & 0 deletions
114
src/main/java/fr/neutronstars/nbot/command/CommandBuilder.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,114 @@ | ||
package fr.neutronstars.nbot.command; | ||
|
||
import fr.neutronstars.nbot.plugin.NBotPlugin; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
public class CommandBuilder | ||
{ | ||
private final String name, description; | ||
private final List<Long> guilds = new ArrayList<>(); | ||
private final List<String> aliases = new ArrayList<>(); | ||
private final Command.ExecutorType executor; | ||
private final boolean toPrivate, privateOnly; | ||
|
||
private int power; | ||
private Consumer<CommandArgs> consumer; | ||
|
||
public CommandBuilder(String name, String description) | ||
{ | ||
this(name, description, 0); | ||
} | ||
|
||
public CommandBuilder(String name, String description, int power) | ||
{ | ||
this(name, description, 0, Command.ExecutorType.USER, false, false); | ||
} | ||
|
||
public CommandBuilder(String name, String description, boolean toPrivate, boolean privateOnly) | ||
{ | ||
this(name, description, 0, toPrivate, privateOnly); | ||
} | ||
|
||
public CommandBuilder(String name, String description, int power, boolean toPrivate, boolean privateOnly) | ||
{ | ||
this(name, description, 0, Command.ExecutorType.USER, toPrivate, privateOnly); | ||
} | ||
|
||
public CommandBuilder(String name, String description, int power, Command.ExecutorType executor, boolean toPrivate, boolean privateOnly) | ||
{ | ||
this.name = name; | ||
this.description = description; | ||
this.power = power; | ||
this.executor = executor; | ||
this.toPrivate = toPrivate; | ||
this.privateOnly = privateOnly; | ||
} | ||
|
||
public String getName() | ||
{ | ||
return name; | ||
} | ||
|
||
public String getDescription() | ||
{ | ||
return description; | ||
} | ||
|
||
public Command.ExecutorType getExecutor() | ||
{ | ||
return executor; | ||
} | ||
|
||
public int getPower() | ||
{ | ||
return power; | ||
} | ||
|
||
public List<Long> getGuilds() | ||
{ | ||
return guilds; | ||
} | ||
|
||
public List<String> getAliases() | ||
{ | ||
return aliases; | ||
} | ||
|
||
public CommandBuilder addGuild(long guildId) | ||
{ | ||
guilds.add(guildId); | ||
return this; | ||
} | ||
|
||
public boolean isToPrivate() | ||
{ | ||
return toPrivate; | ||
} | ||
|
||
public boolean isPrivateOnly() | ||
{ | ||
return privateOnly; | ||
} | ||
|
||
public CommandBuilder setExecutor(Consumer<CommandArgs> consumer) | ||
{ | ||
this.consumer = consumer; | ||
return this; | ||
} | ||
|
||
protected void execute(CommandArgs args) | ||
{ | ||
if(consumer != null) consumer.accept(args); | ||
} | ||
|
||
public void register(NBotPlugin plugin) | ||
{ | ||
if(plugin == null) | ||
CommandManager.registerCommand(this, null); | ||
else | ||
plugin.registerCommand(this); | ||
} | ||
} |
Oops, something went wrong.