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


Java MessageReceivedEvent.getMessage方法代码示例

本文整理汇总了Java中sx.blah.discord.handle.impl.events.MessageReceivedEvent.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java MessageReceivedEvent.getMessage方法的具体用法?Java MessageReceivedEvent.getMessage怎么用?Java MessageReceivedEvent.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sx.blah.discord.handle.impl.events.MessageReceivedEvent的用法示例。


在下文中一共展示了MessageReceivedEvent.getMessage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMessageReceived

import sx.blah.discord.handle.impl.events.MessageReceivedEvent; //导入方法依赖的package包/类
@EventSubscriber
public void onMessageReceived(MessageReceivedEvent event) {
    if (discordService.isOwnUser(event.getMessage().getAuthor())) {
        return;
    }
    IMessage m = event.getMessage();
    String content = m.getContent();
    Optional<Command> match = commandList.stream().filter(c -> c.matches(content)).findFirst();
    if (match.isPresent()) {
        Command command = match.get();
        CompletableFuture.runAsync(() -> tryExecute(event, command), taskExecutor)
            .exceptionally(t -> {
                log.warn("Something happened while trying to execute command", t);
                return null;
            });
    }
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:18,代码来源:CommandService.java

示例2: onMessageReceivedEvent

import sx.blah.discord.handle.impl.events.MessageReceivedEvent; //导入方法依赖的package包/类
@EventSubscriber
public void onMessageReceivedEvent(MessageReceivedEvent event) {
    IMessage m = event.getMessage();
    ChannelConfig cc = wrapper.getChannel(m.getChannel().getID());

    // Don't listen to this event if the channel is not configured, or
    // we are not listening to the channel
    if(cc == null || !cc.isDiscordListen()) {
        return;
    }

    // Not listening to our messages
    if(m.getAuthor().getID().equals(wrapper.getClient().getOurUser().getID())) {
        return;
    }

    // Send message to Minecraft
    String msgLog = cc.getPrefix() + m.getAuthor().getName() + ": " + m.getContent();
    plugin.getServer().broadcastMessage(msgLog);
}
 
开发者ID:jkcgs,项目名称:DiscordChat,代码行数:21,代码来源:DiscordListener.java

示例3: onMessageReceived

import sx.blah.discord.handle.impl.events.MessageReceivedEvent; //导入方法依赖的package包/类
@EventSubscriber
public void onMessageReceived(MessageReceivedEvent event) {
    IMessage m = event.getMessage();
    if (!discordService.isOwnUser(m.getAuthor())) {
        for (Publisher publisher : publisherRepository.findByChannelId(event.getMessage().getChannel().getID())) {
            // check if this user can trigger the publish event in this channel
            if (permissionService.canPerform("support.publish", m.getAuthor(), m.getChannel())) {
                publishSupportEvent(m, publisher.getId());
            }
        }
    }
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:13,代码来源:SupportPresenter.java

示例4: onMessageReceived

import sx.blah.discord.handle.impl.events.MessageReceivedEvent; //导入方法依赖的package包/类
@EventSubscriber
public void onMessageReceived(MessageReceivedEvent event) {
  IMessage message = event.getMessage();

  String[] command = message.getContent().split(" ", 2);
  IGuild guild = message.getGuild();

  if (guild != null) {
    if ("~play".equals(command[0]) && command.length == 2) {
      loadAndPlay(message.getChannel(), command[1]);
    } else if ("~skip".equals(command[0])) {
      skipTrack(message.getChannel());
    }
  }
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:16,代码来源:Main.java

示例5: handle

import sx.blah.discord.handle.impl.events.MessageReceivedEvent; //导入方法依赖的package包/类
@Override
public void handle(MessageReceivedEvent event) {
	if (finished || !ready)
		return;

	final IMessage messageObj = event.getMessage();
	final IChannel channel = messageObj.getChannel();
	String message = messageObj.getContent();
	final IUser author = messageObj.getAuthor();

	if (!channel.isPrivate())
		return;

	boolean matchAny = false;
	for (IPrivateChannel ch : privateChannels) {
		if (channel.equals(ch)) {
			matchAny = true;
			break;
		}
	}
	if (!matchAny)
		return;

	final int index = author.equals(battlers[0].owner) ? 0 : (author.equals(battlers[1].owner) ? 1 : -1);

	if (index == -1)
		return;

	if (message.length() == 1) {
		char c = Character.toLowerCase(message.charAt(0));

		if (c == 'r') {
			// resign

			finished = true;
			client.getDispatcher().unregisterListener(this);

			for (IPrivateChannel pc : privateChannels) {
				Bot.sendMessage(Bot.getNewBuilder(pc).withContent(
						"**" + author.getName() + "**#" + author.getDiscriminator() +
								" __resigned__ from the battle."));
			}

			Userdata.addLong("goatBattlesLost_" + author.getID(), 1, 0);
			Userdata.addLong("goatBattlesWon_" + battlers[index].opponent.owner.getID(), 1, 0);
			Userdata.instance().save();

			return;
		} else if (selection[index] == 0 && c >= '1' &&
				c <= Integer.toString(battlers[index].moves.length).charAt(0)) {
			selection[index] = c - '1' + 1;
			final int moveIndex = selection[index] - 1;

			final Move m = battlers[index].moves[moveIndex];

			boolean noPPRemaining = true;
			for (int pp : battlers[index].pp) {
				if (pp > 0) {
					noPPRemaining = false;
					break;
				}
			}

			if (!noPPRemaining && battlers[index].pp[moveIndex] == 0) {
				Bot.sendMessage(
						Bot.getNewBuilder(privateChannels[index]).withContent("That move is **out of PP**."));
				selection[index] = 0;
			}
		}
	}

	if (selection[0] != 0 && selection[1] != 0) {
		executeTurn(event);
	}
}
 
开发者ID:chrislo27,项目名称:Baristron,代码行数:76,代码来源:Battle.java

示例6: handle

import sx.blah.discord.handle.impl.events.MessageReceivedEvent; //导入方法依赖的package包/类
@Override
public void handle(MessageReceivedEvent event) {
	if (expired || !isConnected)
		return;

	final IMessage message = event.getMessage();
	String content = message.getContent();
	final IChannel channel = message.getChannel();
	final IUser author = message.getAuthor();
	final char zeroWidth = '\u200B';

	if (!channel.equals(first) && !channel.equals(other))
		return;

	if (!content.startsWith(CALL_PREFIX) ||
			(content.length() <= CALL_PREFIX.length() && message.getAttachments().size() == 0))
		return;

	if (Userdata.getPermissions(author.getID()).ordinal() < Permission.NORMAL.ordinal())
		return;

	content = (content.length() == CALL_PREFIX.length() && message.getAttachments().size() > 0
			? (content + ".")
			: content).substring(CALL_PREFIX.length()).trim();

	MessageTokenizer tokenizer = new MessageTokenizer(event.getClient(), content);
	while (tokenizer.hasNextMention()) {
		MessageTokenizer.MentionToken token = tokenizer.nextMention();

		String replacement = token.getMentionObject().getID();

		if (token.getMentionObject() instanceof IUser) {
			replacement = "@" + zeroWidth + ((IUser) token.getMentionObject()).getDisplayName(message.getGuild());
		} else if (token.getMentionObject() instanceof IChannel) {
			replacement = "#" + zeroWidth + ((IChannel) token.getMentionObject()).getName();
		} else if (token.getMentionObject() instanceof IRole) {
			replacement = "@" + zeroWidth + ((IRole) token.getMentionObject()).getName();
		}

		content = content.replace(token.getContent(), replacement);
	}

	if (content.length() > 512)
		return;

	content = content.replace("@here", "@" + zeroWidth + "here").replace("@everyone", "@" + zeroWidth +
			"everyone");

	final IChannel receiving = channel.equals(first) ? other : first;

	MetadataMessageBuilder builder = Bot.getNewBuilder(receiving);

	builder.appendContent(":telephone: **" + author.getDisplayName(event.getMessage().getGuild()) + "**#" +
			author.getDiscriminator() + (author.isBot() ? " **[BOT]**" : "") + ": " + content);

	for (IMessage.Attachment a : message.getAttachments()) {
		builder.appendContent("\n" + a.getUrl());
	}

	Bot.sendMessage(builder);

}
 
开发者ID:chrislo27,项目名称:Baristron,代码行数:63,代码来源:Connection.java


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