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


Java ChannelType.TEXT属性代码示例

本文整理汇总了Java中net.dv8tion.jda.core.entities.ChannelType.TEXT属性的典型用法代码示例。如果您正苦于以下问题:Java ChannelType.TEXT属性的具体用法?Java ChannelType.TEXT怎么用?Java ChannelType.TEXT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在net.dv8tion.jda.core.entities.ChannelType的用法示例。


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

示例1: requireGuild

/**
 * Transforms this context into a guild context, telling the invoker to run the command in a guild if requested
 *
 * @param answerUser set to false to not tell the invoker about running the command in a guild
 *                   <p>
 * @return a GuildCommandContext if this command was issued in a guild, null otherwise
 */
@Nullable
public GuildCommandContext requireGuild(@Nonnull final boolean... answerUser) {
    if (this.channel.getType() == ChannelType.TEXT) {
        final TextChannel tc = (TextChannel) this.channel;
        final Guild g = tc.getGuild();
        final Member m = this.event.getMember();
        if (m != null) {
            return new GuildCommandContext(this, g, m, tc);
        } else {
            log.warn("Uh oh member is unexpectedly null when transforming CommandContext to GuildCommandContext");
        }
    }

    if (answerUser.length == 0 || answerUser[0]) {
        replyWithMention("please run this command in a guild channel.");
    }
    return null;
}
 
开发者ID:napstr,项目名称:wolfia,代码行数:25,代码来源:CommandContext.java

示例2: dispatch

@Override
public void dispatch(String[] args, MessageChannel channel, Message msg) {
    ScriptEngine engine = engineManager.getEngineByName("nashorn");
    engine.put("channel", channel);
    if(channel.getType() == ChannelType.TEXT)
        engine.put("guild", ((TextChannel)channel).getGuild());
    else engine.put("guild", null);
    engine.put("message", msg);
    engine.put("jda", msg.getJDA());
    String js = Arrays.stream(args).collect(Collectors.joining(" "));
    try {
        msg.editMessage("Code: ```js\n" + js + "```\nOutput: ```js\n" + engine.eval(js) + "\n```").queue();
    } catch (ScriptException e) {
        UserBot.LOGGER.error("Could not evaluate js! {}".replace("{}", js), e);
        msg.editMessage("Could not evaluate ```js\n" + js + "\n```\n```js" + e.getMessage() + "```").queue();
    }
}
 
开发者ID:ArsenArsen,项目名称:SelfBot,代码行数:17,代码来源:Javascript.java

示例3: execute

@Override
protected void execute(CommandEvent cmdEvent) {
    GGDCommandEvent event = new GGDCommandEvent(cmdEvent.getEvent(), cmdEvent.getArgs(), cmdEvent.getClient());

    if (!allowedInGuild && event.getChannelType() == ChannelType.TEXT) {
        event.replyErrorInDM("Diesen Befehl bitte hier ausführen!");
        event.getMessage().delete().queue();
        return;
    }

    executeCommand(event);
}
 
开发者ID:michidk,项目名称:GGD-Discord-Bot,代码行数:12,代码来源:GGDCommand.java

示例4: isValid

private boolean isValid(Input input, CommandSettings settings) {
  boolean canSpeakInChannel = !Main.commandBlacklist.getChannels()
      .contains(input.getChannel().getId());
  if (settings.getOwnerCommand() && !Main.bot.getAuth().getOwnerID()
      .equals(input.getAuthor().getId())) {
    return false;
  }
  if (settings.getNSFWCommand() && !Main.NSFWWhitelist.getChannels()
      .contains(input.getJDA().getTextChannelById(input.getChannel().getId()))) {
    return false;
  }
  if (settings.getGuildOnly() && input.getChannelType() != ChannelType.TEXT) {
    return false;
  }
  if (settings.getSelfPermissions() != null && !input.getGuild().getSelfMember()
      .hasPermission(settings.getSelfPermissions())) {
    return false;
  }
  if (settings.getAuthorPermissions() != null && !input.getMember()
      .hasPermission(settings.getAuthorPermissions())) {
    return false;
  }
  if (!Arrays.asList(settings.getNameAndAliases()).contains("blacklist") && !canSpeakInChannel) {
    return false;
  }
  return true;
}
 
开发者ID:Svetroid,项目名称:Hobbes-v1,代码行数:27,代码来源:CommandHandler.java

示例5: dispatch

@Override
public void dispatch(String[] args, MessageChannel channel, Message msg) {
    ScriptEngine engine = manager.getEngineByName("groovy");
    engine.put("channel", channel);
    if(channel.getType() == ChannelType.TEXT)
        engine.put("guild", ((TextChannel)channel).getGuild());
    else engine.put("guild", null);
    engine.put("message", msg);
    engine.put("jda", msg.getJDA());
    String groovy = Arrays.stream(args).collect(Collectors.joining(" "));
    try {
        msg.editMessage("Code: ```groovy\n" + groovy + "```\nOutput: ```groovy\n" + engine.eval("import java.util.*;\n" +
                "import java.util.concurrent.*;\n" +
                "import java.util.stream.*;\n" +
                "import java.time.*;\n" +
                "import java.math.*;\n" +
                "import net.dv8tion.jda.core.entities.*;\n" +
                "import net.dv8tion.jda.core.entities.impl.*;\n" +
                "import net.dv8tion.jda.core.managers.*;\n" +
                "import net.dv8tion.jda.core.*;\n" +
                "import com.arsenarsen.userbot.*;\n" +
                "import com.arsenarsen.userbot.command.*;\n" + groovy) + "\n```").queue();
    } catch (ScriptException e) {
        UserBot.LOGGER.error("Could not evaluate groovy! {}".replace("{}", groovy), e);
        msg.editMessage("Could not evaluate ```groovy\n" + groovy + "\n```\n```groovy" + e.getMessage() + "```").queue();
    }
}
 
开发者ID:ArsenArsen,项目名称:SelfBot,代码行数:27,代码来源:Groovy.java

示例6: display

/**
 * Shows the OrderedMenu as a new {@link net.dv8tion.jda.core.entities.Message Message} 
 * in the provided {@link net.dv8tion.jda.core.entities.MessageChannel MessageChannel}.
 * 
 * @param  channel
 *         The MessageChannel to send the new Message to
 */
@Override
public void display(MessageChannel channel) {
    if(channel.getType()==ChannelType.TEXT 
            && !allowTypedInput 
            && !PermissionUtil.checkPermission((TextChannel)channel, ((TextChannel)channel).getGuild().getSelfMember(), Permission.MESSAGE_ADD_REACTION))
        throw new PermissionException("Must be able to add reactions if not allowing typed input!");
    initialize(channel.sendMessage(getMessage()));
}
 
开发者ID:JDA-Applications,项目名称:JDA-Utilities,代码行数:15,代码来源:OrderedMenu.java


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