本文整理匯總了Java中net.dv8tion.jda.core.entities.Message.getRawContent方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.getRawContent方法的具體用法?Java Message.getRawContent怎麽用?Java Message.getRawContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.dv8tion.jda.core.entities.Message
的用法示例。
在下文中一共展示了Message.getRawContent方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onMessageReceived
import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void onMessageReceived(MessageReceivedEvent event) {
if (event.getAuthor().isBot())
return;
Message message = event.getMessage();
String content = message.getRawContent();
String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
try {
for (IFunction f : commands) {
if ((commandNParameters[0].equals(prefix + f.command)))
f.doYaThing(message);
}
} catch (Exception e) {
System.out.println(e.getMessage());
log.log("ERROR: " + e.getCause() + " " + e.getMessage());
}
}
示例2: doYaThing
import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
String content = message.getRawContent();
MessageChannel channel = message.getChannel();
String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
try {
if (commandNParameters.length > 1) {
for (Submission s : RedditHandler.getPosts(commandNParameters[1], 2)) {
channel.sendMessage("https://www.reddit.com" + s.getPermalink()).complete();
}
} else
channel.sendMessage("```" + prefix + usage + "```").complete();
} catch (Exception e) {
System.out.println(e.getMessage());
channel.sendMessage("```" + e.getMessage() + "```").complete();
log.log("ERROR: " + e.getCause() + " " + e.getMessage());
}
}
示例3: doYaThing
import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
String content = message.getRawContent();
MessageChannel channel = message.getChannel();
String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
try {
if (commandNParameters.length > 1) {
message.delete().complete();
String whatToSay = DodoStringHandler.glueStringsBackTogether(commandNParameters, " ", 1);
channel.sendMessage(whatToSay.substring(0, 1).toUpperCase() + whatToSay.substring(1) + ".").complete();
} else {
channel.sendMessage(getUsage()).complete();
}
} catch (Exception e) {
System.out.println(e.getMessage());
log.log("ERROR: " + e.getCause() + " " + e.getMessage());
}
}
示例4: doYaThing
import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
TextChannel channel = message.getTextChannel();
String content = message.getRawContent();
List<Member> members = message.getGuild().getMembers();
try {
ArrayList<Stats> statsOfMembers = getMembers(members);
statsOfMembers.sort(new StatsComparator());
int i = 0;
for (Stats s : statsOfMembers) {
if (i > 5)
break;
for (Member m : members) {
if (m.getUser().getId().equals(s.getPresona())) {
channel.sendMessage("User: " + m.getUser().getName() + " Score: " + s.getNumOfMessages()).queue();
}
}
i++;
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: handle
import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void handle(Message message, Event event, String[] args) throws Throwable {
if (args.length == 1) {
printUsage(kyoko, kyoko.getI18n().getLanguage(message.getGuild()), message.getTextChannel());
return;
}
String msg = message.getRawContent();
String mention = kyoko.getJda().getSelfUser().getAsMention();
if (msg.startsWith(mention)) {
msg = msg.substring(mention.length()).trim().substring(args[0].length());
} else {
msg = msg.substring(kyoko.getSettings().getPrefix().length() + args[0].length());
}
if (msg.trim().isEmpty()) {
printUsage(kyoko, kyoko.getI18n().getLanguage(message.getGuild()), message.getTextChannel());
return;
}
message.getTextChannel().sendMessage(msg).queue();
}
示例6: onMessageReceived
import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void onMessageReceived(MessageReceivedEvent event) {
if (event.getAuthor().isBot())
return;
Message message = event.getMessage();
String content = message.getRawContent();
User author = message.getAuthor();
try {
Stats temp = Stats.GetStats(author);
if (temp != null) {
temp.increase();
}
if (content.equals("Bot.stats(false);") && temp != null) {
stats.remove(temp);
message.addReaction("\u2705").complete();
}
if (message.getRawContent().equals("Bot.stats(true);") && temp == null) {
stats.add(new Stats(author));
message.addReaction("\u2705").complete();
message.getTextChannel().sendMessage("Use `" + prefix + "stats` to check your stats").complete();
}
if (RandomGen.rndNm(10) == 3) {
FileHandler.writeToFile(stats);
}
} catch (Exception e) {
System.out.println(e.getMessage());
log.log("ERROR: " + e.getCause() + " " + e.getMessage());
}
}
示例7: doYaThing
import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
String content = message.getRawContent();
MessageChannel channel = message.getChannel();
String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
try {
if (commandNParameters.length > 2) {
String quote = DodoStringHandler.glueStringsBackTogether(commandNParameters, " ", 2);
quote = quote.replace("\"", "");
Quote temp = new Quote(commandNParameters[1], quote);
quotes.add(temp);
FileHandler.writeToFile(quotes);
channel.sendMessage(temp.toString()).complete();
} else if (commandNParameters.length == 2) {
Random rnd = new Random();
ArrayList<Quote> tempQuotes = new ArrayList<>();
for (Quote q : quotes) {
System.out.println(q.getWho());
if (q.getWho().toLowerCase().equals(commandNParameters[1].toLowerCase())) {
tempQuotes.add(q);
}
}
if (tempQuotes.size() > 0)
channel.sendMessage(tempQuotes.get(rnd.nextInt(tempQuotes.size())).toString()).complete();
else
channel.sendMessage("No quotes from " + commandNParameters[1] + "!").complete();
} else {
channel.sendMessage("```" + prefix + usage + "```").complete();
}
} catch (Exception e) {
System.out.println(e.getMessage());
log.log("ERROR: " + e.getCause() + " " + e.getMessage());
}
}
示例8: doYaThing
import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
User author = message.getAuthor();
String content = message.getRawContent();
MessageChannel channel = message.getChannel();
String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
BankAccount temp = new BankAccount("temp");
boolean exists = false;
for (BankAccount b : bankAccounts) {
if (b.getID().equals(author.getId())) {
exists = true;
temp = b;
}
}
try {
if (commandNParameters.length < 2)
channel.sendMessage("```" + prefix + usage + "```").complete();
else if (exists && temp.getBalance() >= Double.parseDouble(commandNParameters[1])) {
if (Double.parseDouble(commandNParameters[1]) > -1)
SlotMashina.slotMashinas(Double.parseDouble(commandNParameters[1]), channel, temp);
else
channel.sendMessage("Can't slot that!").complete();
} else {
if (!exists) {
channel.sendMessage("You have to register! Use `" + prefix + "bank register`").complete();
} else channel.sendMessage("You are too poor!").complete();
}
} catch (Exception e) {
System.out.println(e.getMessage());
log.log("ERROR: " + e.getCause() + " " + e.getMessage());
}
}
示例9: doYaThing
import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
String content = message.getRawContent();
MessageChannel channel = message.getChannel();
String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
try {
if (commandNParameters.length > 1)
channel.sendMessage("http://lmgtfy.com/?q=" + URLEncoder.encode(DodoStringHandler.glueStringsBackTogether(commandNParameters, " ", 1), "UTF-8")).complete();
else
channel.sendMessage(getUsage()).complete();
} catch (Exception e) {
System.out.println(e.getMessage());
log.log("ERROR: " + e.getCause() + " " + e.getMessage());
}
}
示例10: onMessageReceived
import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void onMessageReceived(MessageReceivedEvent event)
{
if (NapBot.terminationReason != null || event.getAuthor().getIdLong() == event.getAuthor().getJDA().getSelfUser().getIdLong())
{
// don't respond to messages if the bot is shutting down, or if the messages are coming the bot itself
return;
}
try
{
if (event.isFromType(ChannelType.PRIVATE))
{
log.info("PRIVATE/{}: {}", event.getAuthor().getName(), event.getMessage().getRawContent());
event.getChannel().sendMessage("I haven't been programmed to respond to private messages O_O").complete();
}
else if (event.isFromType(ChannelType.TEXT))
{
Message message = event.getMessage();
User author = event.getAuthor();
TextChannel channel = event.getTextChannel();
String content = message.getRawContent();
if (content.startsWith(NapBot.CONFIGURATION.messagePrefix) && content.length() > NapBot.CONFIGURATION.messagePrefix.length())
{
log.info("PUBLIC/{}/{}/{}: {}", author.getName(), channel.getGuild().getName(), channel.getName(), content);
ArrayList<String> split = new ArrayList<String>(Arrays.asList(content.substring(NapBot.CONFIGURATION.messagePrefix.length()).split(" ")));
String command = split.remove(0);
ICommand icommand = commands.get(command.toLowerCase(Locale.ENGLISH));
if (icommand == null)
{
channel.sendMessage("I don't know what you mean by `" + content + "`. If you're not sure what you're doing, try typing `" + NapBot.CONFIGURATION.messagePrefix + "help`.").complete();
return;
}
if (!icommand.hasPermission(author))
{
channel.sendMessage("You don't have permission to execute that command").complete();
return;
}
if (!icommand.execute(author, channel, command, split, message))
{
channel.sendMessage("I don't know what you mean by `" + content + "`. If you're not sure what you're doing, try typing `" + NapBot.CONFIGURATION.messagePrefix + "help`.").complete();
return;
}
}
}
}
catch (Throwable t)
{
event.getChannel().sendMessage("An internal error occurred and I wasn't able to process that command. Please ask <@147356941860077568> to investigate").complete();
t.printStackTrace();
}
}