本文整理汇总了Java中com.jagrosh.jdautilities.commandclient.CommandEvent.replyWarning方法的典型用法代码示例。如果您正苦于以下问题:Java CommandEvent.replyWarning方法的具体用法?Java CommandEvent.replyWarning怎么用?Java CommandEvent.replyWarning使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jagrosh.jdautilities.commandclient.CommandEvent
的用法示例。
在下文中一共展示了CommandEvent.replyWarning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
String prefix = event.getClient().getPrefix();
if(event.getArgs().isEmpty())
{
event.replyWarning("Please choose a subcommand:\n" +
"- `"+prefix+"bot status`: Sets the Online Status (OnlineStatus) of the bot.\n" +
"- `"+prefix+"bot game`: Sets the Game (Game.of) of the bot.\n" +
"- `"+prefix+"bot updategame`: Updates the default game.\n" +
"- `"+prefix+"bot optimize`: Optimizes the Bot's RAM usage. Use with caution.\n");
}
else if(!(event.getArgs().contains("status")) || !(event.getArgs().contains("game") || !(event.getArgs().contains("updategame"))) || !(event.getArgs().contains("optimize")))
{
event.replyWarning("Please choose a subcommand:\n" +
"- `"+prefix+"bot status`: Sets the Online Status (OnlineStatus) of the bot.\n" +
"- `"+prefix+"bot game`: Sets the Game (Game.of) of the bot.\n" +
"- `"+prefix+"bot updategame`: Updates the default game.\n" +
"- `"+prefix+"bot optimize`: Optimizes the Bot's RAM usage. Use with caution.\n");
}
}
示例2: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
int res = Constant.music.disconnectFromVoiceChat(event.getGuild().getAudioManager());
if (res == 0) {
event.replyWarning(event.getMember().getAsMention() + " I'm not even connected :joy:");
} else {
event.replySuccess("Disconnected");
}
}
示例3: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
String args = event.getArgs();
if(args.isEmpty())
{
event.replyWarning("Please specify a timezone!");
return;
}
try
{
ZoneId.of(args);
}
catch(ZoneRulesException e)
{
event.replyError("Please specify a valid timezone!");
return;
}
db.setTimezone(event.getAuthor(), args);
event.replySuccess("Successfully updated timezone!");
}
示例4: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
if (!event.getArgs().isEmpty()) {
if (event.getGuild().getAudioManager().isConnected()) {
String cc = "ytsearch:" + event.getArgs();
Constant.music.loadAndPlaySearch(event, waiter, cc);
} else {
event.replyWarning(event.getMember().getAsMention() + " I'm not even connected :joy:");
}
} else {
event.replyWarning(event.getMember().getAsMention() + " You need to specify an url");
}
}
示例5: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
if(event.getArgs().isEmpty())
event.replyError("Please include a text channel or NONE");
else if(event.getArgs().equalsIgnoreCase("none"))
{
db.setModlogChannel(event.getGuild(), null);
event.replySuccess("Modlogging disabled");
}
else
{
List<TextChannel> list = FinderUtil.findTextChannels(event.getArgs(), event.getGuild());
if(list.isEmpty())
event.replyWarning("No Text Channels found matching \""+event.getArgs()+"\"");
else if (list.size()>1)
event.replyWarning(FormatUtil.listOfTcChannels(list, event.getArgs()));
else
{
db.setModlogChannel(event.getGuild(), list.get(0));
event.replySuccess("Modlogging actions will be logged in "+list.get(0).getAsMention());
}
}
}
示例6: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
if(event.getArgs().isEmpty())
{
event.replyWarning("Specify a tag name!");
return;
}
String tag = db.getTagContent(event.getArgs().trim().toLowerCase());
if(tag==null)
event.replyError("No tag found with that name!");
else
{
if(db.isTagImported(event.getArgs().trim().toLowerCase(), event.getGuild().getIdLong()))
event.replyError("This tag is already imported!");
else
{
db.importTag(event.getArgs().trim().toLowerCase(), tag, db.getTagOwner(event.getArgs().trim().toLowerCase()), event.getGuild().getIdLong());
event.replySuccess("Successfully imported tag!");
}
}
}
示例7: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
int res = Constant.music.connectToVoiceChat(event.getGuild().getAudioManager(), event.getMember());
if (res == 0) {
event.replyWarning(event.getMember().getAsMention() + " Please connect in a voice channel first");
} else {
event.replySuccess("Connected");
}
}
示例8: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if(!Constants.canSendGiveaway(event.getTextChannel()))
{
event.replyError("I cannot start a giveaway here; please make sure I have the following permissions:\n\n"+Constants.PERMS);
return;
}
String[] parts = event.getArgs().split("\\s+",2);
boolean minutes;
if(parts[0].toLowerCase().endsWith("m")) {
parts[0] = parts[0].substring(0,parts[0].length()-1);
minutes = true;
} else if (parts[0].toLowerCase().endsWith("s")) {
parts[0] = parts[0].substring(0,parts[0].length()-1);
minutes = false;
} else
minutes = false;
try {
int value = (int)(Double.parseDouble(parts[0]) * (minutes ? 60 : 1) );
if(!Constants.validTime(value))
{
event.replyWarning("Time must be at least 10 seconds and can't be longer than a week!");
return;
}
try{ event.getMessage().delete().queue(); }catch(PermissionException ex){}
Instant now = Instant.now();
String item = parts.length==1 ? null : (parts[1].length()>Constants.PRIZE_MAX ? parts[1].substring(0,Constants.PRIZE_MAX) : parts[1]);
bot.startGiveaway(event.getTextChannel(), now, value, 1, item);
} catch(NumberFormatException e) {
event.replyWarning("Failed to parse "+(minutes ? "minutes" : "seconds")+" from `"+parts[0]+"`.");
}
}
示例9: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
if(event.getArgs().isEmpty())
{
event.replyWarning("Specify a new welcome message!");
return;
}
db.setWelcomeMessage(event.getGuild(), event.getArgs());
event.replySuccess("Welcome message configured.");
}
示例10: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
if(event.getArgs().isEmpty())
{
event.replyWarning("Specify a new leave message!");
return;
}
db.setLeaveMessage(event.getGuild(), event.getArgs());
event.replySuccess("leave message configured.");
}
示例11: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
EmbedBuilder builder = new EmbedBuilder();
String[] inputs = event.getArgs().split("\\s+", 2);
int num = 1;
String query;
if(inputs.length>1 && inputs[0].matches("\\d+"))
{
num = Integer.parseInt(inputs[0]);
query = inputs[1];
}
else
{
query = event.getArgs();
}
if(num<1 || num>10)
{
event.replyWarning("I can only get 1 to 10 results at once!");
return;
}
ArrayList<String> results = searcher.getGoogleData(query);
if(results==null)
{
event.replyWarning("An error ocurred when using Google Search. Ask the bot owner to see the console.");
}
else if(results.isEmpty())
{
event.replyWarning("Any results found for `"+query+"`!");
}
else
{
StringBuilder output = new StringBuilder("`"+query+"` \uD83D\uDD0E "+results.get(0));
if(num>1 && results.size()>1)
{
output.append("\n See also:");
for(int i=1; i<num && i<results.size(); i++)
{
output.append("\n<").append(results.get(i)).append(">");
}
}
builder.setAuthor(event.getAuthor().getName(), null, event.getAuthor().getEffectiveAvatarUrl());
builder.setDescription(output.toString());
builder.setColor(event.getMessage().getMember().getColor());
builder.setFooter("Results from Google Search API", null);
event.reply(builder.build());
}
}
示例12: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
final Member member;
if(event.getArgs().isEmpty())
member = event.getMember();
else
{
List<Member> members = FinderUtil.findMembers(event.getArgs(), event.getGuild());
if(members.size() < 1)
{
event.replyError("Could not find a user matching \""+event.getArgs()+"\"!");
return;
}
if(members.size() > 1)
{
event.replyError(FormatUtils.tooManyMembers(event.getArgs(),members));
return;
}
member = members.get(0);
}
event.replyWarning("Getting Ratings...", message -> {
pBuilder.clearItems();
pBuilder.setText((page, total) -> String.format("Ratings of **%s**#%s | Page %d/%d", member.getUser().getName(),
member.getUser().getDiscriminator(), page, total));
database.getRatingsTo(member.getUser()).forEach((l, s) -> {
User user = event.getJDA().getUserById(l);
if(user == null)
pBuilder.addItems("UNKNOWN (ID: "+l+") - "+s);
else
pBuilder.addItems("**"+user.getName()+"**#"+user.getDiscriminator()+" - "+s);
});
if(member.getColor() != null)
pBuilder.setColor(member.getColor());
pBuilder.build().display(message);
});
}
示例13: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
if(!(event.getClient().getOwnerId().equals(Const.ARTUTO_ID)))
{
event.replyError("This command is not available on a selfhosted instance!");
return;
}
if(event.getArgs().isEmpty())
{
event.replyWarning("Please specify the user ID and a donated amount!");
return;
}
String[] args;
String id;
String amount;
User user;
try
{
args = event.getArgs().split(" ", 2);
id = args[0];
amount = args[1];
}
catch(ArrayIndexOutOfBoundsException e)
{
event.replyWarning("Please specify the user ID and a donated amount!");
return;
}
List<Member> list = FinderUtil.findMembers(id, event.getGuild());
if(list.isEmpty())
{
event.getJDA().retrieveUserById(id).queue(s -> {
db.setDonation(s, amount);
event.replySuccess(String.format("Successfully added %#s to the donators list!", s));
}, e -> event.replyError("Invalid ID!"));
}
else if(list.size()>1)
event.replyWarning(FormatUtil.listOfMembers(list, id));
else
{
user = list.get(0).getUser();
db.setDonation(user, amount);
event.replySuccess(String.format("Successfully added %#s to the donators list!", user));
}
}
示例14: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
Member target;
EmbedBuilder builder = new EmbedBuilder();
if(event.getArgs().isEmpty())
{
target = event.getMessage().getMember();
}
else
{
List<Member> list = FinderUtil.findMembers(event.getArgs(), event.getGuild());
if(list.isEmpty())
{
event.replyWarning("I was not able to found a user with the provided arguments: '"+event.getArgs()+"'");
return;
}
else if(list.size()>1)
{
event.replyWarning(FormatUtil.listOfMembers(list, event.getArgs()));
return;
}
else
{
target = list.get(0);
}
}
String title = ":frame_photo: Avatar of **"+target.getUser().getName()+"**"+"#"+"**"+target.getUser().getDiscriminator()+"**";
try
{
builder.setImage(target.getUser().getEffectiveAvatarUrl());
builder.setColor(target.getColor());
event.getChannel().sendMessage(new MessageBuilder().append(title).setEmbed(builder.build()).build()).queue();
}
catch(Exception e)
{
event.replyError("An error happened when getting the avatar!");
}
}
示例15: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
if (event.isFromType(ChannelType.TEXT)) {
String id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
if (id != null) {
if (!event.getChannel().getId().equals(id)) {
return;
}
}
}
if (event.getGuild().getAudioManager().isConnected()) {
GuildMusicManager musicManager = Constant.music.getGuildAudioPlayer(event.getGuild());
if (musicManager.player.getPlayingTrack() != null) {
ArrayList<AudioTrack> queue = new ArrayList<>(musicManager.scheduler.getQueue());
String message = "";
EmbedBuilder builder = new EmbedBuilder();
builder.setTitle("Current queue:");
builder.setColor(event.getGuild().getSelfMember().getColor());
if (queue.size() > 4) {
message += "1.`" + musicManager.player.getPlayingTrack().getInfo().title + "`";
for (int i = 0; i < 4; i++) {
message += "\n" + (i + 2) + ".`" + queue.get(i).getInfo().title + "`";
}
message += "\n\nAnd `" + (queue.size() - 4) + "` more...";
builder.setDescription(message);
event.reply(builder.build());
} else if (queue.isEmpty()) {
event.replyWarning("The queue is empty");
} else if (queue.size() <= 4) {
message += "1.`" + musicManager.player.getPlayingTrack().getInfo().title + "`";
for (int i = 0; i < queue.size(); i++) {
message += "\n" + (i + 2) + ".`" + queue.get(i).getInfo().title + "`";
}
builder.setDescription(message);
builder.setFooter(event.getSelfMember().getNickname() != null ? event.getSelfMember().getNickname() : event.getSelfMember().getEffectiveName(), event.getGuild().getIconUrl());
event.reply(builder.build());
}
}
} else {
event.replyError(event.getMember().getAsMention() + " I'm not even connected :joy:");
}
}