• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MissingPermissionsException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: sendConnectionErrorMessage

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

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


示例7: invokeMethod

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


示例8: commonReply

import sx.blah.discord.util.MissingPermissionsException; //导入依赖的package包/类
private CompletableFuture<IMessage> commonReply(IMessage message, Command command, String response, File file) throws InterruptedException, DiscordException, MissingPermissionsException {
    ReplyMode replyMode = command.getReplyMode();
    if (replyMode == ReplyMode.PRIVATE) {
        // always to private - so ignore all permission calculations
        return answerPrivately(message, response, file);
    } else if (replyMode == ReplyMode.ORIGIN) {
        // use the same channel as invocation
        return answer(message, response, command.isMention(), file);
    } else if (replyMode == ReplyMode.PERMISSION_BASED) {
        // the channel must have the needed permission, otherwise fallback to a private message
        if (permissionService.canDisplayResult(command, message.getChannel())) {
            return answer(message, response, command.isMention(), file);
        } else {
            return answerPrivately(message, response, file);
        }
    } else {
        log.warn("This command ({}) has an invalid reply-mode: {}", command.getKey(), command.getReplyMode());
        return answerPrivately(message, response, null);
    }
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:21,代码来源:CommandService.java


示例9: onUserSpeaking

import sx.blah.discord.util.MissingPermissionsException; //导入依赖的package包/类
@EventSubscriber
public void onUserSpeaking(VoiceUserSpeakingEvent event) {
    if (!event.isSpeaking()) {
        SettingsService.ResponseConfig config = settingsService.getSettings()
            .getUserToVoiceResponse().get(event.getUser().getID());
        if (config != null) {
            List<String> responses = config.getResponses();
            if (!responses.isEmpty() && RandomUtils.nextInt(0, 100) < config.getChance()) {
                String text = (responses.size() == 1 ? responses.get(0) :
                    responses.get(RandomUtils.nextInt(0, responses.size())));
                try {
                    discordService.sendMessage(config.getChannelId(), text);
                } catch (DiscordException | MissingPermissionsException | InterruptedException e) {
                    log.warn("Could not send voice response", e);
                }
            }
        }
    }
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:20,代码来源:SoundBitePresenter.java


示例10: deleteInBatch

import sx.blah.discord.util.MissingPermissionsException; //导入依赖的package包/类
public static void deleteInBatch(IChannel channel, List<IMessage> toDelete) {
    if (toDelete.isEmpty()) {
        log.info("No messages to delete");
    } else {
        log.info("Preparing to delete {} messages from {}", toDelete.size(), DiscordUtil.toString(channel));
        for (int x = 0; x < (toDelete.size() / 100) + 1; x++) {
            List<IMessage> subList = toDelete.subList(x * 100, Math.min(toDelete.size(), (x + 1) * 100));
            RequestBuffer.request(() -> {
                try {
                    acquireDelete();
                    channel.getMessages().bulkDelete(subList);
                } catch (MissingPermissionsException | DiscordException e) {
                    log.warn("Failed to delete message", e);
                }
                return null;
            });
        }
    }
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:20,代码来源:DiscordUtil.java


示例11: dispatch

import sx.blah.discord.util.MissingPermissionsException; //导入依赖的package包/类
@Override
public void dispatch(String[] args, IUser sender, IChannel channel) {
    RequestBuffer.request(() -> {
        try {
            channel.getMessages().bulkDelete(channel.getMessages().stream().filter((message) -> message.getAuthor()
                    .equals(Launcher.getInstance().getClient().getOurUser())).collect(Collectors.toList()));
        } catch (DiscordException | MissingPermissionsException ignored) {
            AtomicBoolean cont = new AtomicBoolean(true);
            channel.getMessages().stream().filter((message) -> message.getAuthor()
                    .equals(Launcher.getInstance().getClient().getOurUser()))
                    .forEach((message) -> RequestBuffer.request(() -> {
                        if (cont.get())
                            try {
                                message.delete();
                            } catch (MissingPermissionsException | DiscordException e1) {
                                Messages.sendException("**Could not purge!**", e1, channel);
                            }
                    }));
        }
    });

}
 
开发者ID:ArsenArsen,项目名称:ABot,代码行数:23,代码来源:Purge.java


示例12: dispatch

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


示例13: processCommand

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


示例14: sendMessage

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


示例15: execute

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


示例16: execute

import sx.blah.discord.util.MissingPermissionsException; //导入依赖的package包/类
@Override
public MessageBuilder execute(CommandData<Baristron> commandData) {
	if (commandData.getArgs().size() < 1)
		return CommandResponse.getWrongArgumentsMessage(commandData.getChannel(), this, commandData.getCmdUsed(),
				commandData);

	if (commandData.getChannel().isPrivate())
		return null;

	final IUser u = Utils.findFirstUser(commandData.getChannel().getGuild(), commandData.getFullContent());

	if (u == null)
		return CommandResponse.withAutoDeleteMessage(Bot.getNewBuilder(commandData.getChannel())
				.withContent("Couldn't find that user!"), Bot.AUTO_DELETE_TIME);

	RequestBuffer.request(() -> {
		try {
			commandData.getChannel().getGuild().kickUser(u);
			ModLog.addCase(commandData.getBot(), u, commandData.getChannel().getGuild(), "kick");
		} catch (MissingPermissionsException | DiscordException e) {
			e.printStackTrace();
		}
	});

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


示例17: addOrEditMessage

import sx.blah.discord.util.MissingPermissionsException; //导入依赖的package包/类
public static ModLogSettings.Case addOrEditMessage(IChannel channel, ModLogSettings.Case c, final String content) {
	IMessage msg = channel.getMessageByID(c.messageID);

	if (msg == null) {
		c.messageID = Bot.sendMessage(Bot.getNewBuilder(channel).withContent(content)).get().getID();
	} else {
		RequestBuffer.request(() -> {
			try {
				msg.edit(content);
			} catch (MissingPermissionsException | DiscordException e) {
				e.printStackTrace();
			}
		});
	}

	return c;
}
 
开发者ID:chrislo27,项目名称:Baristron,代码行数:18,代码来源:ModLog.java


示例18: sendMessage

import sx.blah.discord.util.MissingPermissionsException; //导入依赖的package包/类
/**
 * Send a message to a channel
 * @param channel Channel target
 * @param content Content of message
 * @param embed EmbedObject to format with
 */
private static void sendMessage(IChannel channel, String content, EmbedObject embed, boolean bypass) {
	if(!bypass)
		content = content.replaceAll("@", "\\\\@");
	if(content.equals("") && embed == null)
		return;
	final String s = content;
	RequestBuffer.request(() -> {
		try {
			new MessageBuilder(Bot.getInstance().getBot()).withChannel(channel).withContent(s).withEmbed(embed).build();
		} catch (MissingPermissionsException | DiscordException e) {
			e.printStackTrace();
			return;
		}
	});
}
 
开发者ID:paul-io,项目名称:momo-discord-old,代码行数:22,代码来源:MessageUtils.java


示例19: executeCommand

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


示例20: throwException

import sx.blah.discord.util.MissingPermissionsException; //导入依赖的package包/类
public void throwException(IChannel channel, Language lg, MissingPermissionsException e) {
    StringBuilder st = new StringBuilder(Translator.getLabel(lg, "exception.missing_permission")
            .replace("{channel.name}", channel.getName()));

        for(Permissions p : e.getMissingPermissions())
            st.append(Translator.getLabel(lg, PERMISSION_PREFIX + p.name().toLowerCase())).append(", ");
        st.delete(st.length() - 2, st.length()).append(".");

    if (channel.getModifiedPermissions(ClientConfig.DISCORD().getOurUser()).contains(Permissions.SEND_MESSAGES))
        Message.sendText(channel, st.toString());
    else
        try {
            Message.sendText(channel.getGuild().getOwner().getOrCreatePMChannel(), st.toString());
        } catch(sx.blah.discord.util.DiscordException de){
            LOG.warn("throwException", "Impossible de contacter l'administrateur de la guilde ["
                + channel.getGuild().getName() + "].");
        }
}
 
开发者ID:Kaysoro,项目名称:KaellyBot,代码行数:19,代码来源:MissingPermissionDiscordException.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PostgreSQL82Dialect类代码示例发布时间:2022-05-21
下一篇:
Java InterfaceType类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap