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


Java RateLimitException类代码示例

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


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

示例1: sendConnectionErrorMessage

import sx.blah.discord.util.RateLimitException; //导入依赖的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.util.RateLimitException; //导入依赖的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: sendHelloWorld

import sx.blah.discord.util.RateLimitException; //导入依赖的package包/类
private void sendHelloWorld(@NotNull MessageReceivedEvent event, boolean isMention, @Nullable String[] to) throws DiscordException, MissingPermissionsException, RateLimitException {
    @NotNull StringBuilder builder = new StringBuilder(40);
    if (isMention) {
        if (to == null) {
            builder.append(event.getMessage().getAuthor().mention())
                    .append(" ")
                    .append("Hello!");
        } else {
            builder.append("Hello");
            for (String str : to) {
                builder.append(" ")
                        .append(str);
            }
            builder.append("!");
        }
    } else {
        builder.append("Hello World!");
    }
    new MessageBuilder(event.getClient())
            .withChannel(event.getMessage().getChannel())
            .withContent(builder.toString())
            .send();
}
 
开发者ID:ViniciusArnhold,项目名称:ProjectAltaria,代码行数:24,代码来源:SimpleCommandHandler.java

示例4: handle

import sx.blah.discord.util.RateLimitException; //导入依赖的package包/类
@Override
public boolean handle(@NotNull MessageReceivedEvent event, String command, @NotNull String matchedText) throws
        RateLimitException, DiscordException, MissingPermissionsException {

    if (HELLO_COMMAND.mainCommand().equalsIgnoreCase(command)) {
        try {
            CommandLine cmd = HELLO_COMMAND.parse(matchedText);

            if (HELLO_COMMAND.showHelpIfPresent(event.getClient(), event.getMessage().getChannel(), cmd)) {
                return true;
            }

            boolean isMention = cmd.hasOption("m");
            String[] to = cmd.getOptionValues("m");

            sendHelloWorld(event, isMention, to);

        } catch (ParseException e) {
            logger.info("Parsing failed", e);
            EventUtils.sendIncorrectUsageMessage(event.getClient(), event.getMessage().getChannel(), HELLO_COMMAND.mainCommand(), e.getMessage());
        }
        return true;
    }
    return false;
}
 
开发者ID:ViniciusArnhold,项目名称:ProjectAltaria,代码行数:26,代码来源:SimpleCommandHandler.java

示例5: handle

import sx.blah.discord.util.RateLimitException; //导入依赖的package包/类
/**
 * Called when the event is sent.
 *
 * @param event The event object.
 */
@Override
public void handle(@NotNull final MessageReceivedEvent event) {
    if (!isPingCommand(event)) {
        return;
    }
    logger.traceEntry("Received ping command.");

    try {
        MessageUtils.getDefaultRequestBuilder(event.getMessage())
                    .doAction(Actions.ofSuccess(() -> MessageUtils.getMessageBuilder(event.getMessage())
                        .appendContent("Pong!")
                        .appendContent(System.lineSeparator())
                        .appendContent("Last reponse time in: ")
                        .appendContent(TimeUtils.formatToString(event.getMessage().getShard().getResponseTime(), TimeUnit.MILLISECONDS))
                        .send()))
                    .andThen(Actions.ofSuccess(event.getMessage()::delete))
                    .execute();

    } catch (@NotNull RateLimitException | MissingPermissionsException | DiscordException e) {
        logger.error(e);
    }
}
 
开发者ID:ViniciusArnhold,项目名称:ProjectAltaria,代码行数:28,代码来源:PingCommand.java

示例6: invokeMethod

import sx.blah.discord.util.RateLimitException; //导入依赖的package包/类
/**
 * Invokes the method of the command.
 *
 * @param command The command.
 * @param event The event.
 * @param parameters The parameters for the method.
 */
private void invokeMethod(SimpleCommand command, MessageReceivedEvent event, Object[] parameters) {
    Method method = command.getMethod();
    Object reply = null;
    try {
        method.setAccessible(true);
        reply = method.invoke(command.getExecutor(), parameters);
    } catch (IllegalAccessException | InvocationTargetException e) {
        Discord4J.LOGGER.warn("Cannot invoke method {}!", method.getName(), e);
    }
    if (reply != null) {
        try {
            event.getMessage().getChannel().sendMessage(String.valueOf(reply));
        } catch (MissingPermissionsException | RateLimitException | DiscordException ignored) { }
    }
}
 
开发者ID:BtoBastian,项目名称:sdcf4j,代码行数:23,代码来源:Discord4JHandler.java

示例7: main

import sx.blah.discord.util.RateLimitException; //导入依赖的package包/类
public static void main (String... args) throws RateLimitException {

        LOG.info("Wrapping standard output and error streams with tracer!");
        System.setOut(new PrintStreamTraced(System.out));
        System.setErr(new PrintStreamTraced(System.err));

        LOG.info("Shutting Discord4J's Yap");
        LoggingHandler.setLoggerLevel((ch.qos.logback.classic.Logger) Discord4J.LOGGER, Level.OFF);

        LOG.info("Starting bot with token " + Utilities.partiallyReplace(config.authToken, 4));

        try {

            instance = new ClientBuilder().withToken(config.authToken).login();
            instance.getDispatcher().registerListener(state);
            instance.getDispatcher().registerListener(commands);
            instance.getDispatcher().registerListener(auditor);
        }

        catch (final DiscordException e) {

            LOG.trace("Error during startup", e);
            instance.logout();
            System.exit(0);
        }
    }
 
开发者ID:MinecraftModDevelopment,项目名称:MMDBot,代码行数:27,代码来源:MMDBot.java

示例8: processCommand

import sx.blah.discord.util.RateLimitException; //导入依赖的package包/类
@Override
public void processCommand (IMessage message, String[] params) {

    try {

        if (params.length == 3) {

            MMDBot.instance.changeAvatar(Image.forUrl(params[1], params[2]));
            Utilities.sendMessage(message.getChannel(), "How do I look?");
        }
        else {
            Utilities.sendMessage(message.getChannel(), "You must enter an extension and a valid url for this to work.");
        }
    }

    catch (DiscordException | RateLimitException e) {

        MMDBot.LOG.trace("Could not change avatar", e);
    }
}
 
开发者ID:MinecraftModDevelopment,项目名称:MMDBot,代码行数:21,代码来源:CommandAvatar.java

示例9: dispatch

import sx.blah.discord.util.RateLimitException; //导入依赖的package包/类
@Override
public void dispatch(String[] args, IUser sender, IChannel channel) {
    if (!sender.getID().equals(ABot.ROOT_ID)) {
        Messages.send("You are not allowed to see my data!", channel);
        return;
    }
    try {
        IChannel toRecieve = sender.getOrCreatePMChannel();
        Messages.send("Data folder: " + Launcher.WORKING_DIR.getAbsolutePath(), toRecieve);
        Messages.send("Permissions file: " + ABot.PERMISSIONS.getAbsolutePath(), toRecieve);
        Messages.send("Nolog: " + ABot.getNoLog(), toRecieve);
        Messages.send("Command char: " + Launcher.getCommandChar(), toRecieve);
        Messages.send("Invite msg: " + Launcher.getInvite(sender.mention()), toRecieve);
        Messages.send("Version: " + Launcher.getVersion(), toRecieve);
        Messages.send("Commands: " + Launcher.getInstance().getDispatcher().getCommands().size(), toRecieve);
        new Commands().dispatch(args, sender, toRecieve);
    } catch (RateLimitException | DiscordException e) {
        Messages.sendException("", e, channel);
    }
}
 
开发者ID:ArsenArsen,项目名称:ABot,代码行数:21,代码来源:Debug.java

示例10: processCommand

import sx.blah.discord.util.RateLimitException; //导入依赖的package包/类
@Override
public void processCommand(IMessage message, String[] args) {
    IGuild guild = message.getGuild();
    String name = "";
    try {
        if (args.length > 1) {
            name = args[1];
            if (args.length > 2) {
                name = name(args[1], args[2]);
                if (args.length > 3) {
                    name = name(args[1], args[2], args[3]);
                    if (args.length > 4)
                        name = name(args[1], args[2], args[3], args[4]);
                }
            }
        }
        guild.changeName(name);
    } catch (RateLimitException | DiscordException | MissingPermissionsException e) {
        e.printStackTrace();
    }
}
 
开发者ID:sokratis12GR,项目名称:ModFetcher,代码行数:22,代码来源:CommandGuildRename.java

示例11: sendMessage

import sx.blah.discord.util.RateLimitException; //导入依赖的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

示例12: execute

import sx.blah.discord.util.RateLimitException; //导入依赖的package包/类
@Override
	public MessageBuilder execute(CommandData<Baristron> commandData) {
		if (commandData.getChannel().isPrivate())
			return null;

		if (commandData.getArgs().size() == 0)
			return CommandResponse
					.getWrongArgumentsMessage(commandData.getChannel(), this, commandData.getCmdUsed(), commandData);

		try {
//			DiscordUtils.checkPermissions(commandData.getBot().client, commandData.getChannel().getGuild(),
//					commandData.getUser().getRolesForGuild(commandData.getChannel().getGuild()),
//					EnumSet.of(Permissions.BAN));
			commandData.getChannel().getGuild().banUser(Long.parseUnsignedLong(commandData.getArgs().get(0)),
					(commandData.getArgs().size() >= 2 ? Integer.parseInt(commandData.getArgs().get(1)) : 0));
		} catch (MissingPermissionsException | DiscordException | RateLimitException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}

		return null;
	}
 
开发者ID:chrislo27,项目名称:Baristron,代码行数:23,代码来源:BanByIDCommand.java

示例13: executeCommand

import sx.blah.discord.util.RateLimitException; //导入依赖的package包/类
@Override
public void executeCommand(IMessage msg) {
	Long l = msg.getTimestamp().atZone(ZoneId.systemDefault()).toEpochSecond();
	int r = new Random().nextInt(responses.length);
	EmbedBuilder em = new EmbedBuilder();
	em.withColor(Color.CYAN).withDesc(responses[r]);
	em.withFooterText("Delay: ");
	//MessageUtils.sendMessage(msg.getChannel(), em.build());
	IMessage m = MessageUtils.buildAndReturn(msg.getChannel(), em.build());
	LocalDateTime now = LocalDateTime.now(ZoneId.systemDefault());
	try {
		m.edit("", em.withFooterText("Delay: " 
				+ (now.atZone(ZoneId.systemDefault()).toEpochSecond() - l) + "ms").build());
	} catch (DiscordException | RateLimitException | MissingPermissionsException e) {
		e.printStackTrace();
	}
}
 
开发者ID:paul-io,项目名称:momo-discord-old,代码行数:18,代码来源:Ping.java

示例14: newMessageDeletionTask

import sx.blah.discord.util.RateLimitException; //导入依赖的package包/类
@NotNull
private TimerTask newMessageDeletionTask(@NotNull IMessage message) {
    return new TimerTask() {
        @Override
        public void run() {
            try {
                message.delete();
            } catch (@NotNull MissingPermissionsException | RateLimitException | DiscordException e) {
                MessageUtils.handleDiscord4JException(logger, e);
            }
        }
    };
}
 
开发者ID:ViniciusArnhold,项目名称:ProjectAltaria,代码行数:14,代码来源:Timers.java

示例15: sendIncorrectUsageMessage

import sx.blah.discord.util.RateLimitException; //导入依赖的package包/类
public static void sendIncorrectUsageMessage(IDiscordClient client, IChannel channel, String command, String reason) throws RateLimitException, DiscordException, MissingPermissionsException {
    new MessageBuilder(client)
            .appendContent("Incorrect usage of command: ", MessageBuilder.Styles.BOLD)
            .appendContent(command, MessageBuilder.Styles.BOLD)
            .appendContent("\n")
            .appendContent(reason, MessageBuilder.Styles.BOLD)
            .withChannel(channel)
            .send();
}
 
开发者ID:ViniciusArnhold,项目名称:ProjectAltaria,代码行数:10,代码来源:EventUtils.java


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