本文整理汇总了Java中com.jagrosh.jdautilities.commandclient.CommandClientBuilder类的典型用法代码示例。如果您正苦于以下问题:Java CommandClientBuilder类的具体用法?Java CommandClientBuilder怎么用?Java CommandClientBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandClientBuilder类属于com.jagrosh.jdautilities.commandclient包,在下文中一共展示了CommandClientBuilder类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: ShardingManager
import com.jagrosh.jdautilities.commandclient.CommandClientBuilder; //导入依赖的package包/类
public ShardingManager(int numShards, boolean supportScript) throws Exception {
Config config = Config.getInstance();
shards = new JDA[numShards];
Bot bot = null;
CommandClient client = null;
if (!supportScript) {
bot = new Bot(new EventWaiter());
CommandClientBuilder commandClientBuilder = new CommandClientBuilder();
commandClientBuilder.setPrefix("~");
commandClientBuilder.setOwnerId(config.getConfig(Config.OWNER_ID));
commandClientBuilder.addCommands(new TestCommand(),
new PlayCommand(bot),
new PauseCommand(),
new RepeatCommand(),
new StopCommand(),
new ResumeCommand(),
new ListTracksCommand());
commandClientBuilder.setEmojis("\u2714", "\u2757", "\u274c");
client = commandClientBuilder.build();
}
for (int i = 0; i < numShards; i++){
shards[i] = new JDABuilder(AccountType.BOT)
.setToken(config.getConfig(Config.DISCORD_TOKEN))
.useSharding(i, numShards)
.buildBlocking();
if (!supportScript) {
EventWaiter waiter = new EventWaiter();
shards[i].addEventListener(waiter);
shards[i].addEventListener(client);
shards[i].addEventListener(bot);
}
System.out.println("Shard " + i + " built.");
}
}
开发者ID:JessWalters,项目名称:Vinny-Redux,代码行数:41,代码来源:ShardingManager.java
示例2: Bot
import com.jagrosh.jdautilities.commandclient.CommandClientBuilder; //导入依赖的package包/类
public Bot(Minecordbot minecordbot, EventWaiter waiter) {
this.mcb = minecordbot;
updatableMap = new HashMap<>();
eventWaiter = waiter;
cb = new CommandClientBuilder();
if (start()) {
initListeners();
initCommandClient();
}
}
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:11,代码来源:Bot.java
示例3: loadClientBuilder
import com.jagrosh.jdautilities.commandclient.CommandClientBuilder; //导入依赖的package包/类
private static void loadClientBuilder() {
Logger.info("Loading the command builder...");
//Creates JDA-Util's Command Builder so we can use it later.
clientBuilder = new CommandClientBuilder();
//Used for "ownerOnly" commands in commands.
clientBuilder.setOwnerId(Constants.OWNER_ID.get());
//Used for the prefix of the bot, so we have an easy life.
clientBuilder.setPrefix("^");
Logger.info("Adding commands...");
//Loads all of our commands into JDA-Util's command handler.
clientBuilder.addCommands(
//General
new PingCommand(),
new RulesCommand(),
new ApplyCommand(),
new RewardsCommand(),
new MentionCommand(),
new ServersCommand(),
new SeasonCommand(),
new SelfWarningsCommand(warningManager),
new ReportCommand(reportManager),
//Fun
new HecktownCommand(),
new MathCommand(),
new VideoCommand(),
new RandomSeasonCommand(),
new StatsCommand(hypixel),
new HypixelCommand(hypixel),
new MessageStatsCommand(messageFactory),
new MoneyCommand(sqlManager),
new GambleCommand(sqlManager),
new ShopCommand(sqlManager),
//Staff Tools
new WarnCommand(warningManager, messageFactory),
new EditWarningCommand(warningManager),
new DeleteWarnCommand(warningManager),
new WarningsCommand(warningManager),
new SpamCommand(),
new OgCommand(),
new FansCommand(),
new LockCommand(),
new UnlockCommand(),
new FanartCommand(),
new KickCommand(),
new BanCommand(),
new PardonCommand(),
new PromoteCommand(),
new DemoteCommand(),
new StaffManagementCommand(),
new HandleReportCommand(reportManager),
new LookupReportCommand(reportManager),
new EditReportCommand(reportManager),
//Bot Management
new RuntimeCommand(),
new ThemeCommand(themeManager),
new ThemeManagerCommand(themeManager),
new ShutdownCommand(),
new UpdateCommand(messageFactory),
new EvalCommand());
clientBuilder.setHelpFunction(C::showHelp);
}
开发者ID:WheezyGold7931,项目名称:happybot,代码行数:75,代码来源:Main.java
示例4: WrkBot
import com.jagrosh.jdautilities.commandclient.CommandClientBuilder; //导入依赖的package包/类
public WrkBot(Properties prop) {
Constant.music = new Music();
Constant.waiter = waiter = new EventWaiter();
wrkGame = new WrkGame();
client = new CommandClientBuilder();
client.useDefaultGame();
client.setOwnerId(Constant.ownerId);
client.setEmojis("✅", "⚠", "❌");
client.setPrefix(Constant.prefix);
// adds commands
client.addCommands(// command to show information about the bot
new AboutCommand(Color.GREEN, "a music bot with a lot more",
new String[]{"Pimped music bot", "Many cats", "Many dogs", "Game bot (see the help)", "And more..."},
new Permission[]{Permission.MANAGE_CHANNEL, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE, Permission.MESSAGE_MANAGE, Permission.MESSAGE_ADD_REACTION, Permission.VOICE_MOVE_OTHERS, Permission.VOICE_SPEAK}),
new BroadcastCommand(),
new CatCommand(),
new DisconnectCommand(),
new DogCommand(),
new GameBotCommand(),
new GuildlistCommand(waiter),
new HelloCommand(waiter),
new NowPlayingCommand(),
new PingCommand(),
new PlayCommand(),
new QueueCommand(),
new RestartCommand(),
new SearchCommand(waiter),
new SetAvatarCommand(),
new SetTextChannelCommand(),
new SetVoiceChannelCommand(),
new ShuffleCommand(),
new bot.commands.ShutdownCommand(),
new SummonCommand(),
new VolumeCommand());
try {
Constant.jda = new JDABuilder(AccountType.BOT)
// set the token
.setToken(prop.getProperty("token"))
// set the game for when the bot is loading
.setStatus(OnlineStatus.DO_NOT_DISTURB)
.setGame(Game.of("loading..."))
// add the listeners
.addEventListener(waiter)
.addEventListener(client.build())
.addEventListener(wrkGame)
// start it up!
.buildAsync();
} catch (LoginException | IllegalArgumentException | RateLimitedException ex) {
Logger.getLogger(WrkBot.class.getName()).log(Level.SEVERE, null, ex);
}
}
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:52,代码来源:WrkBot.java
示例5: Bot
import com.jagrosh.jdautilities.commandclient.CommandClientBuilder; //导入依赖的package包/类
private Bot() throws IOException, SQLException, JSONException,
LoginException, RateLimitedException, IllegalAccessException,
InstantiationException, ClassNotFoundException
{
Config config = new Config(Paths.get(System.getProperty("user.dir"),"config.json"));
database = new Database(
config.getDatabasePathname(),
config.getDatabaseUsername(),
config.getDatabasePassword(),
config.getWebhookId(),
config.getWebhookToken()
);
database.init();
// Event Waiter
EventWaiter waiter = new EventWaiter();
CommandClientBuilder builder = new CommandClientBuilder();
// No default help
builder.useHelpBuilder(false);
builder.addCommands(
new AboutCommand(database, Config.PERMISSIONS),
new FromCommand(database, waiter),
new HelpCommand(),
new LinkRoleCommand(database),
new PingCommand(),
new RankCommand(database),
new RateCommand(database),
new ToCommand(database, waiter),
new EvalCommand(database),
new ModeCommand(),
new ShutdownCommand(database)
);
builder.setPrefix(Config.PREFIX);
builder.setPlaying(Config.GAME);
builder.setServerInvite(Config.HUB_SERVER_INVITE);
builder.setOwnerId(config.getJagroshId()); // jagrosh
builder.setCoOwnerIds(config.getMonitorId()); // monitor
builder.setEmojis(Config.SUCCESS_EMOJI, Config.WARNING_EMOJI, Config.ERROR_EMOJI);
// Set Discord Bots Key
if(config.getDiscordBotsKey() != null)
builder.setDiscordBotsKey(config.getDiscordBotsKey());
// Set Carbonitex Key
if(config.getCarbonitexKey() != null)
builder.setCarbonitexKey(config.getCarbonitexKey());
// Set Discord Bots List Key
if(config.getDiscordBotsListKey() != null)
builder.setDiscordBotListKey(config.getDiscordBotsListKey());
new JDABuilder(AccountType.BOT)
.setToken(config.getToken())
.addEventListener(builder.build(), waiter, this)
.buildAsync();
}
开发者ID:TheMonitorLizard,项目名称:BalloonBoat,代码行数:65,代码来源:Bot.java
示例6: main
import com.jagrosh.jdautilities.commandclient.CommandClientBuilder; //导入依赖的package包/类
public static void main(String[] args) throws IOException, LoginException, IllegalArgumentException, RateLimitedException
{
// config.txt contains two lines
List<String> list = Files.readAllLines(Paths.get("config.txt"));
// the first is the bot token
String token = list.get(0);
// the second is the bot's owner's id
String ownerId = list.get(1);
// define an eventwaiter, dont forget to add this to the JDABuilder!
EventWaiter waiter = new EventWaiter();
// define a command client
CommandClientBuilder client = new CommandClientBuilder();
// The default is "Type !!help" (or whatver prefix you set)
client.useDefaultGame();
// sets the owner of the bot
client.setOwnerId(ownerId);
// sets emojis used throughout the bot on successes, warnings, and failures
client.setEmojis("\uD83D\uDE03", "\uD83D\uDE2E", "\uD83D\uDE26");
// sets the bot prefix
client.setPrefix("!!");
// adds commands
client.addCommands(
// command to show information about the bot
new AboutCommand(Color.BLUE, "an example bot",
new String[]{"Cool commands","Nice examples","Lots of fun!"},
new Permission[]{Permission.ADMINISTRATOR}),
// command to show a random cat
new CatCommand(),
// command to make a random choice
new ChooseCommand(),
// command to say hello
new HelloCommand(waiter),
// command to check bot latency
new PingCommand(),
// command to shut off the bot
new ShutdownCommand());
// start getting a bot account set up
new JDABuilder(AccountType.BOT)
// set the token
.setToken(token)
// set the game for when the bot is loading
.setStatus(OnlineStatus.DO_NOT_DISTURB)
.setGame(Game.of("loading..."))
// add the listeners
.addEventListener(waiter)
.addEventListener(client.build())
// start it up!
.buildAsync();
}
开发者ID:jagrosh,项目名称:ExampleBot,代码行数:68,代码来源:ExampleBot.java
示例7: getClientBuilder
import com.jagrosh.jdautilities.commandclient.CommandClientBuilder; //导入依赖的package包/类
/**
* An easy way to get our CommandClientBuilder instance!
*
* @return Returns the CommandClientBuilder Instance.
*/
@SuppressWarnings("unused")
public static CommandClientBuilder getClientBuilder() {
return clientBuilder;
}
开发者ID:WheezyGold7931,项目名称:happybot,代码行数:10,代码来源:Main.java
注:本文中的com.jagrosh.jdautilities.commandclient.CommandClientBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论