本文整理汇总了Java中com.jagrosh.jdautilities.commandclient.CommandClientBuilder.setPrefix方法的典型用法代码示例。如果您正苦于以下问题:Java CommandClientBuilder.setPrefix方法的具体用法?Java CommandClientBuilder.setPrefix怎么用?Java CommandClientBuilder.setPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jagrosh.jdautilities.commandclient.CommandClientBuilder
的用法示例。
在下文中一共展示了CommandClientBuilder.setPrefix方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.");
}
}
示例2: 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);
}
示例3: 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);
}
}
示例4: 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();
}
示例5: 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();
}