本文整理汇总了Java中net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent类的典型用法代码示例。如果您正苦于以下问题:Java PrivateMessageReceivedEvent类的具体用法?Java PrivateMessageReceivedEvent怎么用?Java PrivateMessageReceivedEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PrivateMessageReceivedEvent类属于net.dv8tion.jda.core.events.message.priv包,在下文中一共展示了PrivateMessageReceivedEvent类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPrivateMessageReceived
import net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent; //导入依赖的package包/类
@Override
public void onPrivateMessageReceived(PrivateMessageReceivedEvent event) {
//Member author = event.getMember(); //User who sent message, member of guild
User author = event.getAuthor();
MessageChannel channel = event.getChannel();
Message message = event.getMessage(); //Message recieved
String msg = message.getContentDisplay().trim().toLowerCase(); // String readable content of message
//Guild guild = event.getGuild(); //Get info about the server this message is recieved on
//Long guildID = guild.getIdLong(); //guild unique id
if (msg.length() > 0) {
if (privCmdList.isEmpty()) {
channel.sendMessage(i18n.localize(dbMan, channel, "error.commandlist_not_initiated")).queue();
} else {
for (String commandName : privCmdList.keySet()) {
if (msg.startsWith(commandName)) {
Integer cmdCount = commandName.length();
String parameters = msg.substring(cmdCount);
privCmdList.get(commandName).execute(author, channel, message, parameters, privCmdList);
}
}
}
}
}
示例2: onPrivateMessageReceived
import net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent; //导入依赖的package包/类
@Override
public void onPrivateMessageReceived(PrivateMessageReceivedEvent event) {
if (isFromMyself(event)) {
return; // cancel on own messages
}
handleMessage(event.getMessage());
}
示例3: onPrivateMessageReceived
import net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent; //导入依赖的package包/类
@Override
public void onPrivateMessageReceived(PrivateMessageReceivedEvent event) {
if (event.getAuthor() == lastUserToReceiveHelp) {
//Ignore, they just got help! Stops any bot chain reactions
return;
}
if (event.getAuthor().equals(event.getJDA().getSelfUser())) {
//Don't reply to ourselves
return;
}
event.getChannel().sendMessage(HelpCommand.getHelpMessage(event.getJDA())).queue();
lastUserToReceiveHelp = event.getAuthor();
}
示例4: onPrivateMessageReceived
import net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent; //导入依赖的package包/类
@Override
public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) {
if (!Bot.isReady)
return;
if (e.getAuthor().equals(e.getJDA().getSelfUser())) {
return;
}
EmbedBuilder em = new EmbedBuilder();
Command c;
if((c = CommandHandler.getCommand(e.getMessage().getContent().toLowerCase())) == null) {
em.setTitle("Invalid command", null)
.setColor(Color.RED)
.setDescription(e.getMessage().getContent() + " is not a valid command");
e.getChannel().sendMessage(em.build()).queue();
return;
}
em.setTitle(e.getMessage().getContent(), null)
.setColor(Color.CYAN)
.addField("Primary Command", c.getDefaultCommand(), true);
String[] aliases = c.getAliases();
if(aliases.length > 0) {
em.addField("Aliases",
Arrays.toString(aliases).substring(1, Arrays.toString(aliases).length() - 1) + "\n", true);
}
em.addField("Permissions", c.getPermission().toString(), true)
.addField("Description", c.getDescription(), false)
.addField("Example", c.getDefaultCommand() + " "
+ c.getExample().replaceAll("\n", "\n" + c.getDefaultCommand() + " "), false);
e.getChannel().sendMessage(em.build()).queue();
return;
}
示例5: onPrivateMessageReceived
import net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent; //导入依赖的package包/类
@Override
public void onPrivateMessageReceived(PrivateMessageReceivedEvent event) {
// don't process messages sent by the bot
if (event.getAuthor().getId().equals(event.getJDA().getSelfUser().getId())) return;
DiscordSRV.api.callEvent(new DiscordPrivateMessageReceivedEvent(event));
String reply = DiscordSRV.getPlugin().getAccountLinkManager().process(event.getMessage().getRawContent(), event.getAuthor().getId());
if (reply != null) event.getChannel().sendMessage(reply).queue();
}
示例6: isFromMyself
import net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent; //导入依赖的package包/类
private boolean isFromMyself(PrivateMessageReceivedEvent event) {
SelfUser selfUser = event.getJDA().getSelfUser();
return event.getAuthor().getId().equals(selfUser.getId());
}
示例7: receivePrivateMessage
import net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent; //导入依赖的package包/类
public static void receivePrivateMessage(PrivateMessageReceivedEvent e) {
String s = getDate() + " FROM PRIVATE " + JDAUtil.userToString(e.getAuthor()) + " CHANNEL ID " + e.getChannel().getId() + ": " + stripNewLine(e.getMessage());
writeLog(s);
}
示例8: onPrivateMessageReceived
import net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent; //导入依赖的package包/类
@Override
public void onPrivateMessageReceived(PrivateMessageReceivedEvent e) {
if (!e.getAuthor().getId().equals(e.getJDA().getSelfUser().getId())) {
MessageLogger.receivePrivateMessage(e);
}
}
示例9: DiscordPrivateMessageReceivedEvent
import net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent; //导入依赖的package包/类
public DiscordPrivateMessageReceivedEvent(PrivateMessageReceivedEvent jdaEvent) {
super(jdaEvent.getJDA(), jdaEvent);
this.author = jdaEvent.getAuthor();
this.channel = jdaEvent.getChannel();
this.message = jdaEvent.getMessage();
}