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


Java IChannel.sendMessage方法代码示例

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


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

示例1: sendMessage

import sx.blah.discord.handle.obj.IChannel; //导入方法依赖的package包/类
public static void sendMessage(IChannel channel, String message, EmbedObject object) {

        if (message.length() > 2000 || object.description.length() > 2000) {

            Utilities.sendMessage(channel, "I tried to send a message, but it was too long. " + message.length() + "/2000 chars! Embedded: " + object.description.length() + "/2000!");
            Discord4J.LOGGER.info(message);
            Discord4J.LOGGER.info(object.description);
            return;
        }

        try {
            channel.sendMessage(message, object, false);
            Thread.sleep(1000);
        } catch (RateLimitException | DiscordException | MissingPermissionsException | InterruptedException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:sokratis12GR,项目名称:ModFetcher,代码行数:18,代码来源:Utilities.java

示例2: sendMessage

import sx.blah.discord.handle.obj.IChannel; //导入方法依赖的package包/类
/**
 * Sends a text message
 *
 * @param channel text channel
 * @param message message
 */
public void sendMessage(IChannel channel, String message) {
    try {
        channel.sendMessage(message);
    } catch (DiscordException de) {
        System.out.println("RexCord: Error sending message. Got error:");
        de.printStackTrace();
    }
}
 
开发者ID:Pedro12909,项目名称:RexCord,代码行数:15,代码来源:RexCord.java

示例3: handle

import sx.blah.discord.handle.obj.IChannel; //导入方法依赖的package包/类
@Override
public void handle(MessageReceivedEvent event) {
    IMessage message = event.getMessage();
    String messageContent = message.getContent();
    IChannel channel = message.getChannel();
    if(channel.isPrivate() || messageContent.length() < 2 || messageContent.charAt(0) != commandCharacter) { return; }

    String commandString = messageContent.split(" ")[0].substring(1).toLowerCase();

    SagiriCommand pickedCommand = null;
    SagiriCommand pickedAlias = null;

    for(SagiriCommand command : commandsMap.keySet()) {
        if(pickedCommand == null || (command.getName().equals(commandString) && command.getPriority() > pickedCommand.getPriority())) {
            pickedCommand = command;
            if(command.getPriority() == CommandPriority.HIGHEST) break;
        }

        if(pickedAlias == null || (command.getAliases().contains(commandString) && command.getPriority() > pickedAlias.getPriority())) {
            pickedAlias = command;
        }
    }

    if(pickedCommand != null) executeCommand(event, pickedCommand);
    else if(pickedAlias != null) executeCommand(event, pickedCommand);
    else channel.sendMessage("Command not found.");
}
 
开发者ID:kazigk,项目名称:sagiri,代码行数:28,代码来源:CommandDispatcher.java

示例4: handle

import sx.blah.discord.handle.obj.IChannel; //导入方法依赖的package包/类
@Override
public boolean handle(MessageReceivedEvent event, String[] args) {
	IChannel channel = event.getChannel();

	String newsCount = "1";
	if(args.length > 1) {
		newsCount = args[1];
	}
	try {
		List<NewsItem> items = getLatestNews(newsCount);
		channel.sendMessage("Here are the latest news from the Dota2 world !!!");

		EmbedBuilder builder = new EmbedBuilder();
		builder.setLenient(true);
		builder.withColor(Color.GREEN);
		int num = 1;
		for(NewsItem item :items) {
			builder.appendField("**#" + Integer.toString(num++) + ".**" + item.getTitle() ,item.getContents(), false)
			.appendField(item.getAuthor(),item.getUrl()     , true);
		}
		channel.sendMessage(builder.build());


	} catch (Exception e) {
		LOGGER.info("Unable to retrieve steam news at this time");
		channel.sendMessage("Unable to retrieve steam news at this time. Try again later");
	}
	return true;
}
 
开发者ID:cool-mist,项目名称:DiscordConvenienceBot,代码行数:30,代码来源:News.java

示例5: handle

import sx.blah.discord.handle.obj.IChannel; //导入方法依赖的package包/类
@Override
public boolean handle(MessageReceivedEvent event, String[] args) {
	// TODO Provide win-rate stats per level
	IChannel channel = event.getChannel();
	
	if(args.length < 2) {
		channel.sendMessage("Missing hero name. Eg !stat anti mage");
		return true;
	}
	
	String heroName = args[1];
	for(int i=2; i<args.length; ++i) {
		heroName = heroName + " " + args[i];
	}
	
	Hero hero = library.getHero(heroName);
	
	if(hero == null) {
		channel.sendMessage("Hero " + heroName + " not found :( ");
		return true;
	}
	
	EmbedBuilder builder = new EmbedBuilder().setLenient(true);
	
	builder.withTitle(heroName).withColor(Color.RED);
	builder.withImage(SteamClient.openDotaBaseUrl + hero.getImg()); // Not working presently
	builder.appendField("Pro ", ""  + hero.getPro_win()*100/hero.getPro_pick(), true);
	
	builder.appendField("Crusader ",""+hero.getCrusader_win()*100/hero.getCrusader_pick(), true);
	builder.appendField("Archon "  ,""+hero.getArchon_win()*100/hero.getArchon_pick(), true);
	builder.appendField("Legend "  ,""+hero.getLegend_win()*100/hero.getLegend_pick(), true);
	builder.appendField("Ancient " ,""+hero.getAncient_win()*100/hero.getAncient_pick(), true);
	builder.appendField("Divine "  ,""+hero.getDivine_win()*100/hero.getDivine_pick(), true);
	channel.sendMessage(builder.build());
	
	return true;
}
 
开发者ID:cool-mist,项目名称:DiscordConvenienceBot,代码行数:38,代码来源:HeroStat.java

示例6: sendMessageToChannel

import sx.blah.discord.handle.obj.IChannel; //导入方法依赖的package包/类
private void sendMessageToChannel(IChannel channel, String message) {
  try {
    channel.sendMessage(message);
  } catch (Exception e) {
    log.warn("Failed to send message {} to {}", message, channel.getName(), e);
  }
}
 
开发者ID:sedmelluq,项目名称:lavaplayer,代码行数:8,代码来源:Main.java

示例7: msg

import sx.blah.discord.handle.obj.IChannel; //导入方法依赖的package包/类
/**
 * Sends a message to a channel
 *
 * @param channel The channel
 * @param message The message
 */
public static void msg(IChannel channel, String message)
{
	try
	{
		channel.sendMessage(message);
	}
	catch (Exception e)
	{
		Main.log.error(e);
	}
}
 
开发者ID:Vauff,项目名称:Maunz-Discord,代码行数:18,代码来源:Util.java

示例8: send

import sx.blah.discord.handle.obj.IChannel; //导入方法依赖的package包/类
@SuppressWarnings("null")
   public IMessage send(IChannel channel) {
	return channel.sendMessage(CommandContext.sanitize(channel, content), CommandContext.sanitize(channel, embed), tts);
}
 
开发者ID:tterrag1098,项目名称:MCBot,代码行数:5,代码来源:BakedMessage.java


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