本文整理汇总了Java中sx.blah.discord.util.MessageBuilder.appendContent方法的典型用法代码示例。如果您正苦于以下问题:Java MessageBuilder.appendContent方法的具体用法?Java MessageBuilder.appendContent怎么用?Java MessageBuilder.appendContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sx.blah.discord.util.MessageBuilder
的用法示例。
在下文中一共展示了MessageBuilder.appendContent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import sx.blah.discord.util.MessageBuilder; //导入方法依赖的package包/类
@Override
public MessageBuilder execute(CommandData<Baristron> commandData) {
if (commandData.getArgs().size() < 1) {
return CommandResponse.getWrongArgumentsMessage(commandData.getChannel(), this, commandData.getCmdUsed(),
commandData);
} else {
MessageBuilder builder = Bot.getNewBuilder(commandData.getChannel());
IUser u = Utils.findFirstUser(commandData.getBot().client, commandData.getArgs().get(0),
commandData.getChannel().getGuild());
if (u != null) {
builder.appendContent(
"The name of the commandData.getUser() with ID " + commandData.getArgs().get(0) + " is " +
u.getName() + "#" + u.getDiscriminator());
Bot.sendMessage(builder);
}
return CommandResponse.withAutoDeleteMessage(Bot.getNewBuilder(commandData.getChannel())
.withContent("Couldn't find the commandData.getUser() " + commandData.getArgs().get(0)),
Bot.AUTO_DELETE_TIME);
}
}
示例2: execute
import sx.blah.discord.util.MessageBuilder; //导入方法依赖的package包/类
@Override
public MessageBuilder execute(CommandData<Baristron> commandData) {
MessageBuilder builder = Bot.getNewBuilder(commandData.getChannel());
builder.appendContent(commandData.getUser().mention() + " __What does this bot do?__\n");
builder.appendContent(
"It is a utility bot, written in Java and Kotlin using Discord4J that has a ton of miscellaneous " +
"features.\n");
builder.appendContent("Have a look at the list of commands with `" +
commandData.getBot().getPrefixForGuild(commandData.getChannel().getGuild()) + "commands`!\n");
builder.appendContent("To use a command, prepend your command with `" +
commandData.getBot().getPrefixForGuild(commandData.getChannel().getGuild()) +
"`. You can also use commands inside a message using `" +
commandData.getBot().getEmbeddedPrefixForGuild(commandData.getChannel().getGuild()) +
"`. (Example: `something something I suppose " +
commandData.getBot().getEmbeddedPrefixForGuild(commandData.getChannel().getGuild()) +
"hello` will do the hello command)\n");
builder.appendContent("You can also talk to the bot by mentioning and asking it something.\n");
builder.appendContent(
"\nIf you set up the mod role through the serversettings command, you will automatically be granted " +
"moderator permissions for the bot.\n");
builder.appendContent("If you want to change the prefixes, use the `" +
commandData.getBot().getPrefixForGuild(commandData.getChannel().getGuild()) +
"changeprefix` command, as a moderator.\n");
builder.appendContent("\nIt is made and maintained by chrislo27.\n");
builder.appendContent("The source code is available under the GNU General Public License, at <https://github" +
".com/chrislo27/Baristron>.\n");
builder.appendContent(
"\nI want to say a special thank-you to Chorus, ahemtoday, bluemurderguitarbunny, Toastsoat, and " +
"aaron5015 for helping test the goat battle feature. Thank you.\n");
Bot.sendMessage(builder);
return null;
}
示例3: execute
import sx.blah.discord.util.MessageBuilder; //导入方法依赖的package包/类
@Override
public MessageBuilder execute(CommandData<Baristron> commandData) {
if (commandData.getArgs().size() < 2)
return CommandResponse.withAutoDeleteMessage(Bot.getNewBuilder(commandData.getChannel())
.withContent("Requires from/to arguments! %roll <from> <to>"), Bot.AUTO_DELETE_TIME);
try {
double from = Double.parseDouble(commandData.getArgs().get(0));
double to = Double.parseDouble(commandData.getArgs().get(1));
boolean useInts = Math.floor(from) == from && Math.floor(to) == to;
int useDecFormatting = commandData.getArgs().size() >= 3
? Math.min(32, Integer.parseInt(commandData.getArgs().get(2)))
: -1;
double chosen = Utils.lerp(from, to, Utils.random.nextDouble());
MessageBuilder b = Bot.getNewBuilder(commandData.getChannel());
b.appendContent(commandData.getUser().mention() + "\nRolling between **");
if (useInts) {
b.appendContent(((long) Math.floor(from)) + "** and **" + ((long) Math.floor(to)) + "**...\n\n**" +
Math.round(chosen) + "**");
} else {
b.appendContent(from + "** and **" + to + "**...\n\n**" +
(useDecFormatting >= 0 ? String.format("%." + useDecFormatting + "f", chosen) : chosen) +
"**");
}
Bot.sendMessage(b);
} catch (NumberFormatException e) {
return Bot.getNewBuilder(commandData.getChannel()).withContent("Couldn't parse numbers!");
}
return null;
}
示例4: handle
import sx.blah.discord.util.MessageBuilder; //导入方法依赖的package包/类
@Override
public void handle(MessageReceivedEvent event) {
if(event.getMessage().getContent().startsWith(Karren.bot.getGuildManager().getCommandPrefix(event.getGuild()) + "stats")){
MessageBuilder msg = new MessageBuilder(event.getClient());
msg.withChannel(event.getChannel());
msg.withContent("**Karren-sama Stats**");
msg.appendContent("```Bot Uptime: " + KarrenUtil.calcAway(Karren.startTime));
msg.appendContent("\n-------------Build Info-------------");
msg.appendContent("\nBot Version: " + Karren.botVersion);
msg.appendContent("\nCommit ID: " + Karren.jarProps.getProperty("git.commit.id"));
msg.appendContent("\nCommit Time: " + Karren.jarProps.getProperty("git.commit.time"));
msg.appendContent("\nCommit Message: " + Karren.jarProps.getProperty("git.commit.message.full"));
msg.appendContent("\nBuild Branch: " + Karren.jarProps.getProperty("git.branch"));
msg.appendContent("\n-------------Bot Status-------------");
msg.appendContent("\nConnected Guilds: " + Karren.bot.getClient().getGuilds().size());
msg.appendContent("\nConnected Shards: " + Karren.bot.getClient().getShardCount());
msg.appendContent("\nConnected Voice Channels: " + Karren.bot.getClient().getConnectedVoiceChannels().size());
msg.appendContent("\nInteraction System Tags: " + Karren.bot.getGuildManager().getTagHandlers().size());
msg.appendContent("\nTotal Users Visable: " + Karren.bot.getClient().getUsers().size());
msg.appendContent("\nWatchdog Interventions: " + Karren.watchdog.watchdogInterventions);
msg.appendContent("\n-------------Cache Status-------------");
msg.appendContent("\nCached Reminders: " + Karren.bot.getSql().getDbReminderCache().size());
msg.appendContent("\nCached Users: " + Karren.bot.getSql().getDbUserCache().size());
msg.appendContent("\nCached Guild Users: " + Karren.bot.getSql().getDbGuildUserCache().size());
msg.appendContent("\nCached Guilds: " + Karren.bot.getSql().getDbGuildCache().size());
msg.appendContent("\nCached Word Counts: " + Karren.bot.getSql().getDbWordcountCache().size());
msg.appendContent("```");
msg.send();
}
}
示例5: execute
import sx.blah.discord.util.MessageBuilder; //导入方法依赖的package包/类
@Override
public MessageBuilder execute(CommandData<Baristron> commandData) {
if (commandData.getArgs().size() < 1) {
return CommandResponse.withAutoDeleteMessage(
Bot.getNewBuilder(commandData.getChannel()).withContent("You need to play your hand!"),
Bot.AUTO_DELETE_TIME);
} else {
int pchoice = 0;
int mychoice = (int) (Math.random() * 3);
switch (commandData.getArgs().get(0).toLowerCase()) {
case "rock":
case "r":
pchoice = 0;
break;
case "paper":
case "p":
pchoice = 1;
break;
case "scissors":
case "s":
pchoice = 2;
break;
default:
return Bot.getNewBuilder(commandData.getChannel())
.withContent("You can't play that! *what a cheater*");
}
MessageBuilder builder = Bot.getNewBuilder(commandData.getChannel());
builder.appendContent(commandData.getUser().mention() + " I chose __" +
(mychoice == 0 ? "rock" : (mychoice == 1 ? "paper" : "scissors")));
builder.appendContent(
"__, you chose __" + (pchoice == 0 ? "rock" : (pchoice == 1 ? "paper" : "scissors")) + "__. ");
if (mychoice == pchoice) {
builder.appendContent("It's a tie!");
} else {
if (mychoice == 0) {
if (pchoice == 1) {
builder.appendContent("You win!");
} else {
builder.appendContent("I win!");
}
} else if (mychoice == 1) {
if (pchoice == 2) {
builder.appendContent("You win!");
} else {
builder.appendContent("I win!");
}
} else {
if (pchoice == 0) {
builder.appendContent("You win!");
} else {
builder.appendContent("I win!");
}
}
}
Bot.sendMessage(builder);
}
return null;
}
示例6: appendGoatFull
import sx.blah.discord.util.MessageBuilder; //导入方法依赖的package包/类
public void appendGoatFull(MessageBuilder builder) {
if (System.currentTimeMillis() < timeUntilNextFeed) {
float seconds = ((timeUntilNextFeed - System.currentTimeMillis()) / 1000f);
builder.appendContent("**Your goat is full, you must wait " + Utils.formatTime(seconds) + ".**");
}
}