当前位置: 首页>>代码示例>>Java>>正文


Java PrivateMessageReceivedEvent类代码示例

本文整理汇总了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);
                }

            }
        }
    }
}
 
开发者ID:IANetworks,项目名称:Ducky-Mc-Duckerson,代码行数:26,代码来源:EventListener.java

示例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());
}
 
开发者ID:BlackCraze,项目名称:GameResourceBot,代码行数:8,代码来源:MessageListener.java

示例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();
}
 
开发者ID:Frederikam,项目名称:GensokyoBot,代码行数:16,代码来源:EventListenerBoat.java

示例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;
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:33,代码来源:Listeners.java

示例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();
}
 
开发者ID:Scarsz,项目名称:DiscordSRV,代码行数:11,代码来源:DiscordAccountLinkListener.java

示例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());
}
 
开发者ID:BlackCraze,项目名称:GameResourceBot,代码行数:5,代码来源:MessageListener.java

示例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);
}
 
开发者ID:Tazzie02,项目名称:Tazbot,代码行数:5,代码来源:MessageLogger.java

示例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);
	}
}
 
开发者ID:Tazzie02,项目名称:Tazbot,代码行数:7,代码来源:Listeners.java

示例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();
}
 
开发者ID:Scarsz,项目名称:DiscordSRV,代码行数:7,代码来源:DiscordPrivateMessageReceivedEvent.java


注:本文中的net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。