本文整理汇总了Java中com.jagrosh.jdautilities.commandclient.CommandEvent.isOwner方法的典型用法代码示例。如果您正苦于以下问题:Java CommandEvent.isOwner方法的具体用法?Java CommandEvent.isOwner怎么用?Java CommandEvent.isOwner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jagrosh.jdautilities.commandclient.CommandEvent
的用法示例。
在下文中一共展示了CommandEvent.isOwner方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
if(event.getArgs().isEmpty())
{
event.replyWarning("Specify a tag name!");
return;
}
String tag = db.getTagContent(event.getArgs().trim().toLowerCase());
Long owner = db.getTagOwner(event.getArgs().trim().toLowerCase());
if(tag==null)
event.replyError("No tag found with that name!");
else
{
if(owner.equals(event.getAuthor().getIdLong()) || event.isOwner())
{
db.removeTag(event.getArgs().trim().toLowerCase());
event.replySuccess("Tag successfully deleted");
}
else
event.replyError("You aren't the owner of the tag!");
}
}
示例2: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent e) {
if (e.isOwner()) {
if (e.getArgs().startsWith("instance")) {
e.getMessage().addReaction("✅").queue();
e.replySuccess(":white_check_mark: Stopping the JDA Instance!");
e.getJDA().shutdown();
Logger.log("The JDA instance has been shutdown.");
} else if (e.getArgs().startsWith("vm")) {
e.getMessage().addReaction("✅").queue();
e.replySuccess(":white_check_mark: Stopping the VM!");
e.getJDA().shutdown();
Logger.log("The JDA instance has been shutdown...exiting the program.");
System.exit(0);
} else {
e.replyError("**Correct Usage:** ^" + name + " " + arguments);
}
} else {
e.replyError(C.permMsg(Roles.DEVELOPER));
}
}
示例3: showHelp
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
/**
* Sends the help message for the registered commands.
*
* @param event The {@link com.jagrosh.jdautilities.commandclient.CommandEvent CommandEvent} that handles the reply.
* @return The help message.
*/
public static String showHelp(CommandEvent event) {
event.replySuccess("Help is on the way! :sparkles:");
StringBuilder builder = new StringBuilder("**" + event.getSelfUser().getName() + "** commands:\n");
Command.Category category = null;
for (Command command : event.getClient().getCommands())
if (!command.isOwnerCommand() || event.isOwner() || event.isCoOwner()) {
if (!Objects.equals(category, command.getCategory())) {
category = command.getCategory();
builder.append("\n\n __").append(category == null ? "No Category" : category.getName()).append("__:\n");
}
builder.append("\n`").append(event.getClient().getPrefix()).append(command.getName())
.append(command.getArguments() == null ? "`" : " " + command.getArguments() + "`")
.append(" **-** ").append(command.getHelp());
}
User owner = event.getJDA().getUserById(event.getClient().getOwnerId());
if (owner != null) {
builder.append("\n\nFor additional help, contact **").append(owner.getName()).append("**#").append(owner.getDiscriminator());
}
return builder.toString();
}
示例4: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent e) {
if (RuntimeEditor.isEvalOwnerOnly()) {
if (!e.isOwner()) {
e.replyError(C.permMsg(Roles.DEVELOPER));
return;
}
} else {
if (!C.hasRole(e.getMember(), Roles.DEVELOPER)) {
e.replyError(C.permMsg(Roles.DEVELOPER));
return;
}
}
ScriptEngine se = new ScriptEngineManager().getEngineByName("Nashorn");
try {
se.eval("var imports = new JavaImporter(" +
"java.io," +
"java.lang," +
"java.util," +
"com.wheezygold.happybot.util.C," +
"com.wheezygold.happybot.util.Roles," +
"com.wheezygold.happybot.util.Channels," +
"com.wheezygold.happybot.util.RuntimeEditor," +
"net.dv8tion.jda.core.entities.Game," +
"Packages.com.wheezygold.happybot.util," +
"Packages.net.dv8tion.jda.core," +
"Packages.net.dv8tion.jda.core.entities," +
"Packages.net.dv8tion.jda.core.entities.impl," +
"Packages.net.dv8tion.jda.core.managers," +
"Packages.net.dv8tion.jda.core.managers.impl," +
"Packages.net.dv8tion.jda.core.utils);");
} catch (ScriptException e1) {
e1.printStackTrace();
}
se.put("e", e);
se.put("jda", e.getJDA());
se.put("guild", e.getGuild());
se.put("channel", e.getChannel());
se.put("textchannel", e.getTextChannel());
se.put("member", e.getMember());
try {
e.reply(e.getClient().getSuccess() + " Evaluated Successfully:\n```\n" + se.eval("(function() {" +
"with (imports) {" +
e.getArgs() +
"}" +
"})();") + " ```");
} catch (Exception ex) {
e.reply(e.getClient().getError() + " An exception was thrown:\n```\n" + ex + " ```");
}
}
示例5: execute
import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
if(jagrosh == null)
jagrosh = event.getJDA().retrieveUserById(event.getClient().getOwnerId()).complete();
if(monitor == null)
monitor = event.getJDA().retrieveUserById(event.getClient().getCoOwnerIds()[0]).complete();
String prefix = event.getClient().getPrefix();
List<Command> commands = event.getClient().getCommands();
StringBuilder sb = new StringBuilder();
sb.append(Bot.Config.BOT_EMOJI).append(" **__BalloonBoat Commands__**").append("\n\n");
commands.stream().filter(command -> !command.isOwnerCommand()).forEach(command -> {
appendCommand(sb, prefix, command);
});
sb.append("\n");
if(event.isOwner() || event.isCoOwner())
{
sb.append(Bot.Config.SUCCESS_EMOJI).append(" **__Developer Commands__**").append("\n\n");
commands.stream().filter(Command::isOwnerCommand).forEach(command -> {
appendCommand(sb, prefix, command);
});
sb.append("\n");
}
sb.append("If you require additional help contact **")
.append(jagrosh.getName()).append("**#").append(jagrosh.getDiscriminator())
.append(" or **")
.append(monitor.getName()).append("**#").append(monitor.getDiscriminator());
if(event.getClient().getServerInvite() != null)
{
sb.append(", or join my support server: ").append(event.getClient().getServerInvite());
}
if(event.isFromType(ChannelType.TEXT))
event.reactSuccess();
event.replyInDM(sb.toString());
}