本文整理汇总了Java中com.jagrosh.jdautilities.commandclient.CommandEvent.replyInDM方法的典型用法代码示例。如果您正苦于以下问题:Java CommandEvent.replyInDM方法的具体用法?Java CommandEvent.replyInDM怎么用?Java CommandEvent.replyInDM使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jagrosh.jdautilities.commandclient.CommandEvent
的用法示例。
在下文中一共展示了CommandEvent.replyInDM方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent e) {
e.reply("Providing Memes in DM's");
try {
ResultSet resultSet = warningManager.fetchWarnings(e.getEvent().getAuthor().getId());
StringBuilder builder = new StringBuilder();
User targetM = e.getEvent().getAuthor();
builder.append(targetM.getName()).append("'s Warnings\n");
while (resultSet.next()) {
Member staffMem = C.getGuild().getMemberById(resultSet.getString("staffid"));
if (staffMem != null) {
builder.append("#").append(resultSet.getString("id")).append(" ").append(C.bold(staffMem.getUser().getName() + "#" + staffMem.getUser().getDiscriminator())).append(" - ").append(C.bold(resultSet.getString("reason"))).append("\n");
}
}
e.replyInDM(builder.toString());
} catch (SQLException e1) {
e.replyError("Oof Error: " + e1.getMessage());
}
}
示例2: replyWithHelpManualEntryIfAvailable
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
private void replyWithHelpManualEntryIfAvailable(CommandEvent commandEvent, Config config, String language,
String replyIn,
Map<String, String> helpTopicTexts) {
if (helpTopicTexts == null) {
commandEvent.replyInDM(helpText);
} else {
final String text = helpTopicTexts.get(language);
if (text == null) {
commandEvent.replyInDM(helpText);
} else {
if (!StringUtils.isEmpty(replyIn) && (replyIn.equalsIgnoreCase("dm"))) {
commandEvent.replyInDM(text);
} else {
replyBasedOnConfigAndRemoveAfter(config, commandEvent, text,
BotServerMain.timeToRemoveFeedbackInSeconds * 3);
}
}
}
}
示例3: replyError
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
public void replyError(Config config, CommandEvent commandEvent, Throwable throwable, LocaleService localeService) {
if (config != null && config.getReplyInDmWhenPossible()) {
commandEvent.replyInDM(throwable.getMessage());
commandEvent.reactError();
} else {
commandEvent.reactError();
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(null, null, null);
embedBuilder.setTitle(null);
embedBuilder.setDescription(throwable.getMessage());
final String msgRemoveText = localeService.getMessageFor(LocaleService.ERROR_KEEP_CHAT_CLEAN,
localeService.getLocaleForUser(commandEvent.getAuthor()),
String.valueOf(BotServerMain.timeToRemoveFeedbackInSeconds));
embedBuilder.setFooter(msgRemoveText, null);
final MessageEmbed messageEmbed = embedBuilder.build();
replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent, messageEmbed,
BotServerMain.timeToRemoveFeedbackInSeconds, TimeUnit.SECONDS);
}
}
示例4: reply
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
public void reply(Config config, CommandEvent commandEvent, String message, int numberOfSecondsBeforeRemove,
LocaleService localeService) {
Validate.isTrue(numberOfSecondsBeforeRemove > 5);
if (config != null && config.getReplyInDmWhenPossible()) {
commandEvent.replyInDM(message);
commandEvent.reactSuccess();
} else {
commandEvent.reactSuccess();
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(null, null, null);
embedBuilder.setTitle(null);
embedBuilder.setDescription(message);
commandEvent.reply(embedBuilder.build());
}
}
示例5: reply
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
public void reply(Config config, CommandEvent commandEvent, String message) {
if (config != null && config.getReplyInDmWhenPossible()) {
commandEvent.replyInDM(message);
commandEvent.reactSuccess();
handleOriginMessage(commandEvent);
} else {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(null, null, null);
embedBuilder.setTitle(null);
embedBuilder.setDescription(message);
final MessageEmbed messageEmbed = embedBuilder.build();
replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent, messageEmbed,
BotServerMain.timeToRemoveFeedbackInSeconds, TimeUnit.SECONDS);
}
}
示例6: replyAndKeep
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
public void replyAndKeep(Config config, CommandEvent commandEvent, String message) {
if (config != null && config.getReplyInDmWhenPossible()) {
commandEvent.replyInDM(message);
commandEvent.reactSuccess();
handleOriginMessage(commandEvent);
} else {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(null, null, null);
embedBuilder.setTitle(null);
embedBuilder.setDescription(message);
final MessageEmbed messageEmbed = embedBuilder.build();
replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent,
messageEmbed, BotServerMain.timeToRemoveFeedbackInSeconds * 3, TimeUnit.SECONDS);
}
}
示例7: reply
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
public void reply(Config config, CommandEvent commandEvent, String message, int numberOfSecondsBeforeRemove,
LocaleService localeService) {
// Give the caller some slack but not much
Validate.isTrue(numberOfSecondsBeforeRemove > 5);
if (config != null && config.getReplyInDmWhenPossible()) {
commandEvent.replyInDM(message);
commandEvent.reactSuccess();
} else {
commandEvent.reactSuccess();
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(null, null, null);
embedBuilder.setTitle(null);
embedBuilder.setDescription(message);
final String msgRemoveText = localeService.getMessageFor(LocaleService.KEEP_CHAT_CLEAN,
localeService.getLocaleForUser(commandEvent.getAuthor()), "" +
numberOfSecondsBeforeRemove);
embedBuilder.setFooter(msgRemoveText, null);
sendMessageThenDeleteAfterXSeconds(commandEvent, embedBuilder.build(),
numberOfSecondsBeforeRemove, TimeUnit.SECONDS);
}
}
示例8: replyError
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
public void replyError(Config config, CommandEvent commandEvent, Throwable throwable, LocaleService localeService) {
if (config != null && config.getReplyInDmWhenPossible()) {
commandEvent.replyInDM(throwable.getMessage());
commandEvent.reactError();
handleOriginMessage(commandEvent);
} else {
commandEvent.reactError();
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(null, null, null);
embedBuilder.setTitle(null);
embedBuilder.setDescription(throwable.getMessage());
final String msgRemoveText = localeService.getMessageFor(LocaleService.ERROR_KEEP_CHAT_CLEAN,
localeService.getLocaleForUser(commandEvent.getAuthor()),
String.valueOf(BotServerMain.timeToRemoveFeedbackInSeconds));
embedBuilder.setFooter(msgRemoveText, null);
final MessageEmbed messageEmbed = embedBuilder.build();
replyThenDeleteFeedbackAndOriginMessageAfterXTime(commandEvent, messageEmbed,
BotServerMain.timeToRemoveFeedbackInSeconds, TimeUnit.SECONDS);
}
}
示例9: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
if(event.getArgs().isEmpty())
{
event.replyError("Please provide me a valid OnlineStatus!");
return;
}
if(event.getArgs().equals("help"))
{
event.replyInDM("Help for subcommand `bot status`\n"
+ "Valid options: `ONLINE`, `DO_NOT_DISTURB`, `INVISIBLE`, `AWAY`");
event.reactSuccess();
return;
}
try
{
String status = event.getArgs();
event.getJDA().getPresence().setStatus(OnlineStatus.valueOf(status));
event.replySuccess("Changed status to "+event.getJDA().getPresence().getStatus()+" without error!");
}
catch(Exception e)
{
event.replyError("Error when changing the status! Check the Bot console for more information.");
e.printStackTrace();
}
}
示例10: doCommand
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
public void doCommand(CommandEvent event) {
String arg = event.getArgs();
arg = arg.replaceAll("```js", "");
arg = arg.replaceAll("```", "");
if (event.getArgs().isEmpty()) {
event.replyInDM(event.getClient().getError() + " please provide something to evaluate");
return;
}
ScriptEngine scriptEngine = new ScriptEngineManager().getEngineByName("Nashorn");
scriptEngine.put("mcb", mcb);
scriptEngine.put("event", event);
scriptEngine.put("jda", event.getJDA());
scriptEngine.put("guild", event.getGuild());
scriptEngine.put("cfgMngr", mcb.getMcbConfigsManager());
scriptEngine.put("channel", event.getTextChannel());
scriptEngine.put("server", Bukkit.getServer());
StringBuilder builder = new StringBuilder();
try {
builder.append("**Result**: ").append(scriptEngine.eval(arg.trim()));
respond(builder.toString(), event).queue();
} catch (Exception e1) {
builder = new StringBuilder();
builder.append("**Error**: ").append(e1.getClass().getSimpleName()).append("\n");
builder.append("**Cause**: \n").append(e1.getCause().toString());
respond(builder.toString(), event).queue();
}
}
示例11: executeWithConfig
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
final String language;
if (config == null) {
language = LocaleService.DEFAULT.getLanguage();
} else {
language = config.getLocale().getLanguage();
}
final String[] args = commandEvent.getArgs().replaceAll("\\s{1,3}", " ").split(" ");
// If bad arguments
if (args.length < 1 || args.length > 2) {
commandEvent.replyInDM(helpText);
} else { // If user wants full manual (=ALL)
final String replyIn = args.length > 1 ? args[1] : null;
if ("ALL".equalsIgnoreCase(args[0])) {
for (String key : helpTopicsMap.keySet()) {
replyWithHelpManualEntryIfAvailable(commandEvent, config, language, replyIn, helpTopicsMap.get(key));
}
} else { // Reply with user's requested help topic
final Map<String, String> helpTopicTexts = helpTopicsMap.get(args[0]);
replyWithHelpManualEntryIfAvailable(commandEvent, config, language, replyIn, helpTopicTexts);
}
}
removeOriginMessageIfConfigSaysSo(config, commandEvent);
}
示例12: getFeedbackStrategyIfPossible
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
private Config.FeedbackStrategy getFeedbackStrategyIfPossible(CommandEvent event, String enumValue) {
Config.FeedbackStrategy valueToSet = null;
if (enumValue != null) {
try {
valueToSet = Config.FeedbackStrategy.valueOf(enumValue.toUpperCase());
} catch (Throwable t) {
event.replyInDM("Bad value of " + Config.FeedbackStrategy.class.getSimpleName() + ". Available values: " +
StringUtils.join(Config.FeedbackStrategy.values(), ", "));
event.reactError();
return null;
}
}
return valueToSet;
}
示例13: replyError
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
public void replyError(Config config, CommandEvent commandEvent, Throwable throwable, LocaleService localeService) {
if (config != null && config.getReplyInDmWhenPossible()) {
commandEvent.replyInDM(throwable.getMessage());
commandEvent.reactError();
} else {
commandEvent.reactError();
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(null, null, null);
embedBuilder.setTitle(null);
embedBuilder.setDescription(throwable.getMessage());
final MessageEmbed messageEmbed = embedBuilder.build();
commandEvent.reply(messageEmbed);
}
}
示例14: replyMap
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
public void replyMap(Config config, CommandEvent commandEvent, MessageEmbed message) {
if (config != null && config.getReplyInDmWhenPossible()) {
commandEvent.replyInDM(message);
commandEvent.reactSuccess();
handleOriginMessage(commandEvent);
} else {
commandEvent.getChannel().sendMessage(message).queue(m -> {
m.delete().queueAfter(BotServerMain.timeToRemoveFeedbackInSeconds * 4, TimeUnit.SECONDS);
});
commandEvent.getChannel().deleteMessageById(commandEvent.getMessage().getId()).queueAfter(
BotServerMain.timeToRemoveFeedbackInSeconds, TimeUnit.SECONDS
);
}
}
示例15: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
if(jagrosh == null)
jagrosh = event.getJDA().retrieveUserById(event.getClient().getOwnerId()).complete();
if(monitor == null)
monitor = event.getJDA().retrieveUserById(event.getClient().getCoOwnerIds()[0]).complete();
String prefix = event.getClient().getPrefix();
List<Command> commands = event.getClient().getCommands();
StringBuilder sb = new StringBuilder();
sb.append(Bot.Config.BOT_EMOJI).append(" **__BalloonBoat Commands__**").append("\n\n");
commands.stream().filter(command -> !command.isOwnerCommand()).forEach(command -> {
appendCommand(sb, prefix, command);
});
sb.append("\n");
if(event.isOwner() || event.isCoOwner())
{
sb.append(Bot.Config.SUCCESS_EMOJI).append(" **__Developer Commands__**").append("\n\n");
commands.stream().filter(Command::isOwnerCommand).forEach(command -> {
appendCommand(sb, prefix, command);
});
sb.append("\n");
}
sb.append("If you require additional help contact **")
.append(jagrosh.getName()).append("**#").append(jagrosh.getDiscriminator())
.append(" or **")
.append(monitor.getName()).append("**#").append(monitor.getDiscriminator());
if(event.getClient().getServerInvite() != null)
{
sb.append(", or join my support server: ").append(event.getClient().getServerInvite());
}
if(event.isFromType(ChannelType.TEXT))
event.reactSuccess();
event.replyInDM(sb.toString());
}