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


Java IChannel类代码示例

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


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

示例1: sendConnectionErrorMessage

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
public static void sendConnectionErrorMessage(IDiscordClient client, IChannel channel, String command, @Nullable String message, @NotNull HttpStatusException httpe) throws RateLimitException, DiscordException, MissingPermissionsException {
    @NotNull String problem = message != null ? message + "\n" : "";
    if (httpe.getStatusCode() == HttpStatus.SC_SERVICE_UNAVAILABLE) {
        problem += "Service unavailable, please try again latter.";
    } else if (httpe.getStatusCode() == HttpStatus.SC_FORBIDDEN) {
        problem += "Acess dennied.";
    } else if (httpe.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
        problem += "Not Found";
    } else {
        problem += httpe.getStatusCode() + SPACE + httpe.getMessage();
    }

    new MessageBuilder(client)
            .appendContent("Error during HTTP Connection ", MessageBuilder.Styles.BOLD)
            .appendContent("\n")
            .appendContent(EventManager.MAIN_COMMAND_NAME, MessageBuilder.Styles.BOLD)
            .appendContent(SPACE)
            .appendContent(command, MessageBuilder.Styles.BOLD)
            .appendContent("\n")
            .appendContent(problem, MessageBuilder.Styles.BOLD)
            .withChannel(channel)
            .send();
}
 
开发者ID:ViniciusArnhold,项目名称:ProjectAltaria,代码行数:24,代码来源:EventUtils.java

示例2: showHelpIfPresent

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
public boolean showHelpIfPresent(IDiscordClient client, IChannel channnel, @NotNull CommandLine cmd) throws RateLimitException, DiscordException, MissingPermissionsException {
    if (cmd.hasOption("h") || cmd.hasOption("help") || cmd.hasOption("showHelp")) {
        @NotNull StringWriter writter = new StringWriter(200);
        @NotNull PrintWriter pw = new PrintWriter(writter);
        new HelpFormatter()
                .printHelp(pw, 200,
                        EventManager.MAIN_COMMAND_NAME + "  " + this.mainCommand,
                        this.commandInfo,
                        this.options,
                        3,
                        5,
                        null,
                        true);
        new MessageBuilder(client)
                .withChannel(channnel)
                .withQuote(writter.toString())
                .send();
        return true;
    }
    return false;
}
 
开发者ID:ViniciusArnhold,项目名称:ProjectAltaria,代码行数:22,代码来源:Commands.java

示例3: executeMessage

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
private void executeMessage(String clientId, String channelId, String content, EmbedObject embedObject) {
    clientRegistry.getClients().entrySet().stream()
        .filter(entry -> matchesClient(clientId, entry))
        .forEach(entry -> {
            IChannel channel = entry.getValue().getChannelByID(snowflake(channelId));
            if (channel != null) {
                if (content != null && content.length() > Message.MAX_MESSAGE_LENGTH) {
                    answerToChannel(channel, content, false).get();
                    if (embedObject != null) {
                        sendMessage(channel, null, embedObject);
                    }
                } else {
                    sendMessage(channel, content, embedObject);
                }
            } else {
                log.warn("Did not found a channel with id {} in bot {}", channelId, clientId);
            }
        });
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:20,代码来源:SubscriberService.java

示例4: process

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
private int process(List<GameServer> servers, Function<GameServer, Result<?>> action, IChannel channel) {
    RequestBuffer.RequestFuture<IMessage> status = null;
    int processed = 0;
    StringBuilder builder = new StringBuilder();
    for (GameServer target : servers) {
        Result<?> result = action.apply(target);
        if (result.isSuccessful()) {
            processed++;
        }
        String toAppend = resultLine(target, result);
        if (status == null || builder.length() + toAppend.length() > Message.MAX_MESSAGE_LENGTH) {
            status = answerToChannel(channel, toAppend);
            builder.setLength(0);
            builder.append(toAppend);
        } else {
            IMessage newStatus = status.get();
            builder.append(toAppend);
            status = RequestBuffer.request(() -> (IMessage) newStatus.edit(builder.toString()));
        }
    }
    return processed;
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:23,代码来源:GameServers.java

示例5: action

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
public static void action(final Predicate<Channel> filter, final Consumer<IChannel> a) {
	EEWBot.instance.getChannels().entrySet()
			.forEach(entry -> {
				final IGuild guild = EEWBot.instance.getClient().getGuildByID(entry.getKey());
				if (guild!=null)
					entry.getValue().stream().filter(filter)
							.forEach(channel -> {
								final IChannel dc = guild.getChannelByID(channel.id);
								if (dc!=null)
									try {
										a.accept(dc);
									} catch (final MissingPermissionsException ex) {
										Log.logger.warn("権限がありません: "+guild.getName()+" #"+dc.getName());
									}
							});
			});
}
 
开发者ID:Team-Fruit,项目名称:EEWBot,代码行数:18,代码来源:EEWEventListener.java

示例6: checkAndGetBet

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
public static Integer checkAndGetBet(IChannel channel, IUser user, String betStr, int maxValue) throws IllegalCmdArgumentException {
	Integer bet = CastUtils.asPositiveInt(betStr);
	if(bet == null) {
		throw new IllegalCmdArgumentException(String.format("`%s` is not a valid amount for coins.", betStr));
	}

	if(Database.getDBUser(channel.getGuild(), user).getCoins() < bet) {
		BotUtils.sendMessage(TextUtils.notEnoughCoins(user), channel);
		return null;
	}

	if(bet > maxValue) {
		BotUtils.sendMessage(String.format(Emoji.BANK + " Sorry, you can't bet more than **%s**.",
				FormatUtils.formatCoins(maxValue)), channel);
		return null;
	}

	return bet;
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:20,代码来源:Utils.java

示例7: isLimited

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
public boolean isLimited(IChannel channel, IUser user) {
	guildsLimitedMap.putIfAbsent(channel.getGuild().getLongID(), new LimitedGuild());

	LimitedGuild limitedGuild = guildsLimitedMap.get(channel.getGuild().getLongID());
	limitedGuild.addUserIfAbsent(user);

	LimitedUser limitedUser = limitedGuild.getUser(user);
	limitedUser.increment();

	// The user has not exceeded the limit yet, he is not limited
	if(limitedUser.getCount() <= max) {
		limitedGuild.scheduledDeletion(scheduledExecutor, user, cooldown);
		return false;
	}

	// The user has exceeded the limit, he's warned and limited
	if(limitedUser.getCount() == max + 1) {
		limitedGuild.scheduledDeletion(scheduledExecutor, user, cooldown);
		this.warn(channel, user);
		return true;
	}

	// The user has already exceeded the limit, he will be unlimited when the deletion task will be done
	return true;
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:26,代码来源:RateLimiter.java

示例8: subscribeAnnouncer

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
private String subscribeAnnouncer(IUser author, String announcer, IChannel channel) {
    if (!announcer.isEmpty()) {
        Publisher publisher = findOrCreatePublisher(announcer);
        List<ChannelSubscription> matching = publisher.getChannelSubscriptions().stream()
            .filter(s -> s.getChannel().getId().equals(channel.getID())).collect(Collectors.toList());
        if (matching.isEmpty()) {
            ChannelSubscription subscription = new ChannelSubscription();
            subscription.setChannel(cacheService.getOrCreateChannel(channel));
            subscription.setEnabled(true);
            subscription.setMode(Subscription.Mode.ALWAYS);
            publisher.getChannelSubscriptions().add(subscription);
            publisherRepository.save(publisher);
            log.debug("Subscribing channel {} ({}) to announcer {}", channel.getName(), channel.getID(), announcer);
            if (channel.isPrivate()) {
                return ":satellite: I'll PM you about **" + announcer + "**";
            } else {
                return String.format("Subscription of %s to **%s** successful", channel.mention(), announcer);
            }
        } else {
            return "The channel is already receiving announcements about **" + announcer + "**";
        }
    } else {
        log.debug("Attempted to subscribe announcer: {}", author);
    }
    return null;
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:27,代码来源:AnnouncePresenter.java

示例9: onAttack

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
public void onAttack(IChannel channel, Player attacker, MoveSet moveSet, Player defender){
	synchronized(this.attacks){
		if(this.attacks.containsKey(attacker)){
			this.sendMessage(attacker.mention()+" you've already sent your attack!");
			return;
		}
		this.attacks.put(attacker, new IAttack(attacker, moveSet, defender));
		if(!channel.getID().equals(this.channel.getID())){
			this.sendMessage(attacker.mention()+" sent in their attack from another channel!");
		} else {
			this.sendMessage(attacker.mention()+" submitted their attack");
		}
		Move move = moveSet.getMove();
		attacker.lastMove = moveSet;
		attacker.lastTarget = move.has(Move.Flags.UNTARGETABLE) ? null : defender;
		if(!move.has(Move.Flags.UNTARGETABLE))
			defender.lastAttacker = attacker; //free-for-all may make it weird, but it's intentional
		if(this.attacks.size() == this.participants.size()){
			this.timer.cancel();
			this.onTurn();
		}
	}
}
 
开发者ID:Coolway99,项目名称:Discord-Pokebot,代码行数:24,代码来源:Battle.java

示例10: onJoinBattle

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
public static void onJoinBattle(IChannel channel, IUser user, IUser host){
       PreBattle pre = preBattles.get(host);
       if(pre == null){
           Pokebot.sendMessage(channel, user.mention()+" there is no battle pending for that person!");
           return;
       }
       if(!pre.channel.getID().equals(channel.getID())){
           Pokebot.sendMessage(channel, " you must do this in the same channel the battle is being hosted in!");
           return;
	}
	List<Player> list = preBattles.get(host).participants;
	Player player = PlayerHandler.getPlayer(user);
	if(!list.contains(player)){
		list.add(player);
		inPreBattle.add(user);
	}
	Pokebot.sendMessage(channel, user.mention()+" joined the battle hosted by "+host.mention());
}
 
开发者ID:Coolway99,项目名称:Discord-Pokebot,代码行数:19,代码来源:BattleManager.java

示例11: send

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
/**
 * Buffers and sends a message in a channel
 *
 * @param content Message content
 * @param channel The channel to send in
 */
public static void send(String content, IChannel channel) {
    RequestBuffer.request(() -> {
        try {
            String cnt = "\u200b" + content;
            if (cnt.length() > 2000) {
                cnt = cnt.substring(0, 1999);
            }
            new MessageBuilder(Launcher.getInstance().getClient()).withChannel(channel)
                    .appendContent(cnt).build();
        } catch (DiscordException | MissingPermissionsException e) {
            String desc = "";
            if (channel.isPrivate()) {
                desc += "DM To " +
                        ((IPrivateChannel) channel).getRecipient().getName()
                        + '#' + ((IPrivateChannel) channel).getRecipient().getDiscriminator()
                        + " (ID: " + ((IPrivateChannel) channel).getRecipient().getID();
            } else {
                desc += channel + " (Guild: " + channel.getGuild().getName() + ')';
            }
            Launcher.getInstance().getLogger().error(
                    MessageFormatter.format("Could not send message! Channel: {}", desc).getMessage(), e);
        }
    });
}
 
开发者ID:ArsenArsen,项目名称:ABot,代码行数:31,代码来源:Messages.java

示例12: sendException

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
/**
 * Sends an exception into a channel
 *
 * @param msg     Message to prepend
 * @param thrown  The exception
 * @param channel The channel to send to
 */
public static void sendException(String msg, Throwable thrown, IChannel channel) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    thrown.printStackTrace(pw);
    pw.close();
    String x = sw.toString();
    if (channel == null) {
        try {
            channel = Launcher.getInstance().getClient()
                    .getOrCreatePMChannel(Launcher.getInstance().getClient().getUserByID(ABot.ROOT_ID));
        } catch (DiscordException | RateLimitException e) {
            e.printStackTrace();
            return;
        }
    }
    msg = msg + " " + x;
    send(msg, channel);
    Launcher.getInstance().getLogger().error(msg);
    try {
        sw.close();
    } catch (IOException ignored) {
    }
}
 
开发者ID:ArsenArsen,项目名称:ABot,代码行数:31,代码来源:Messages.java

示例13: runBefore

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
@Override
public BeforeResult runBefore(IChannel channel, Player attacker, Player defender){
	if(this.getAccuracy() < 0 || willHit(this, attacker, defender, true)){
		switch(defender.getModifiedAbility()){
			case BIG_PECKS:{
				if(this.stat == Stats.DEFENSE && this.change < 0 && attacker != defender){ //TODO does not negate guard swap
					Pokebot.sendMessage(channel, defender.mention()+"'s ability prevents lowering it's defense");
					return BeforeResult.STOP;
				}
				break;
			}
			case CLEAR_BODY:{
				if(this.change < 0 && attacker != defender){
					Pokebot.sendMessage(channel, defender.mention()+"'s ability prevents lowering it's stats!");
				}
				break;
			}
			default:
				break;
		}
		StatHandler.changeStat(channel, defender, this.stat, this.change);
	} else {
		missMessage(channel, attacker);
	}
	return BeforeResult.STOP;
}
 
开发者ID:Coolway99,项目名称:Discord-Pokebot,代码行数:27,代码来源:StatusChange.java

示例14: getWrongArgumentsMessage

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
public static MetadataMessageBuilder getWrongArgumentsMessage(IChannel channel, Command cmd, String cmdUsed,
															  CommandData commandData) {
	if (cmd.hidden)
		return null;

	MetadataMessageBuilder builder = Bot.getNewBuilder(channel);
	builder.withContent("Incorrect number of arguments. Use `help " + cmdUsed + "` for details.\n");
	builder.appendContent("Acceptable parameter types:");
	Map<String, String> tmp = new LinkedHashMap<>();
	cmd.getCommandHelp(tmp, commandData);
	for (String s : tmp.keySet()) {
		builder.appendContent("\n`" + cmdUsed + " " + s + "`");
	}
	withAutoDeleteMessage(builder, Math.max(60, Bot.AUTO_DELETE_TIME));
	return builder;
}
 
开发者ID:chrislo27,项目名称:Baristron,代码行数:17,代码来源:CommandResponse.java

示例15: dispatch

import sx.blah.discord.handle.obj.IChannel; //导入依赖的package包/类
@Override
public void dispatch(String[] args, IUser sender, IChannel channel) {
    if (args.length > 0) {
        String nick = "";
        for (String s : args) {
            nick += s + ' ';
        }
        nick = nick.trim();
        String finalNick = nick;
        RequestBuffer.request(() -> {
            try {
                channel.getGuild().setUserNickname(Launcher.getInstance().getClient().getOurUser(), finalNick);
            } catch (MissingPermissionsException | DiscordException e) {
                Messages.sendException("Could not edit my own nickname :'(", e, channel);
            }
        });
    } else Messages.send("You need to provide a nickname!", channel);
}
 
开发者ID:ArsenArsen,项目名称:ABot,代码行数:19,代码来源:Nickname.java


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