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


Java CommandEvent.getGuild方法代码示例

本文整理汇总了Java中com.jagrosh.jdautilities.commandclient.CommandEvent.getGuild方法的典型用法代码示例。如果您正苦于以下问题:Java CommandEvent.getGuild方法的具体用法?Java CommandEvent.getGuild怎么用?Java CommandEvent.getGuild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jagrosh.jdautilities.commandclient.CommandEvent的用法示例。


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

示例1: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event) {
    String id = null;
    if (event.isFromType(ChannelType.TEXT)) {
        id = Constant.getTextChannelConf().getProperty(event.getGuild().getId());
        if (id != null) {
            if (!event.getChannel().getId().equals(id)) {
                return;
            }
        }
    }
    if (event.getGuild().getAudioManager().isConnected()) {
        if (!event.getArgs().isEmpty()) {
            Constant.music.loadAndPlay(event);
            if (id != null) {
                if (!Constant.nowPlayingList.containsKey(event.getGuild().getId())) {
                    new NowPlaying(event.getGuild(), Constant.music);
                }
            }
        } else {
            event.replyWarning(event.getMember().getAsMention() + " You need to specify an url");
        }
    } else {
        event.replyWarning(event.getMember().getAsMention() + " I'm not even connected :joy:");
    }
}
 
开发者ID:elgoupil,项目名称:GoupilBot,代码行数:27,代码来源:PlayCommand.java

示例2: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
    Guild guild = event.getGuild();
    String msg = db.getWelcomeMessage(guild);

    if(!(msg==null))
        event.replySuccess("Welcome message at **"+guild.getName()+"**: `"+msg+"`");
    else
        event.replyError("No message configured!");
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:12,代码来源:Welcome.java

示例3: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
    Guild guild = event.getGuild();
    TextChannel modlog = db.getModlogChannel(guild);
    TextChannel serverlog = db.getServerlogChannel(guild);
    TextChannel welcome = db.getWelcomeChannel(guild);
    TextChannel leave = db.getLeaveChannel(guild);
    EmbedBuilder builder = new EmbedBuilder();
    String title = ":information_source: Settings of **"+event.getGuild().getName()+"**:";

    try
    {
        builder.addField("Modlog Channel: ", (modlog==null?"None":modlog.getAsMention()), true);
        builder.addField("Serverlog Channel: ", (serverlog==null?"None":serverlog.getAsMention()), true);
        builder.addField("Welcome Channel: ", (welcome==null?"None":welcome.getAsMention()), true);
        builder.addField("Leave Channel: ", (leave==null?"None":leave.getAsMention()), true);
        builder.setColor(event.getSelfMember().getColor());

        event.getChannel().sendMessage(new MessageBuilder().append(title).setEmbed(builder.build()).build()).queue();
    }
    catch(Exception e)
    {
        event.replyError("Something went wrong when getting the settings: \n```"+e+"```");
    }

}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:28,代码来源:ServerSettings.java

示例4: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent event)
{
    Guild guild = event.getGuild();
    String msg = db.getLeaveMessage(guild);

    if(!(msg==null))
        event.replySuccess("Leave message at **"+guild.getName()+"**: `"+msg+"`");
    else
        event.replyError("No message configured!");
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:12,代码来源:Leave.java

示例5: doCommand

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void doCommand(CommandEvent event)
{
    Guild guild = event.getGuild();
    String args = event.getArgs();
    if(args.isEmpty())
        fail(event, getUsageEmbed(guild));

    MessageEmbed usage = MDCBot.getCommandUsage(guild, args);
    reply(event, usage != null ? usage : Util.createBotMessage(guild, "Command has no usage description"));
}
 
开发者ID:thebrightspark,项目名称:MDC-Discord-Bot,代码行数:12,代码来源:CommandUsage.java

示例6: doCommand

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void doCommand(CommandEvent event)
{
    if(MDCBot.mutedRole == null)
    {
        fail(event, "No muted role. Set one using the command:\n" +
                "%s config %s <role name>", MDCBot.PREFIX, EConfigs.MUTED_ROLE);
        return;
    }

    String args = event.getArgs();
    if(args.isEmpty())
    {
        fail(event, "Must provide a member to mute");
        return;
    }

    Guild guild = event.getGuild();
    Member member = getMemberFromString(event, guild, args);

    if(member == null) return;
    if(member.getRoles().contains(MDCBot.mutedRole))
    {
        if(MuteHandler.unmuteMember(member))
        {
            //Unmuted member
            info(event, "%s has been unmuted", member.getEffectiveName());
            reply(event, "%s (%s) has been unmuted", member.getEffectiveName(), member.getRoles().get(0).getName());
        }
        else
        {
            //Member is not muted
            warn(event, "%s is not muted", member.getEffectiveName());
            reply(event, "%s (%s) is not muted", member.getEffectiveName(), member.getRoles().get(0).getName());
        }
    }
}
 
开发者ID:thebrightspark,项目名称:MDC-Discord-Bot,代码行数:38,代码来源:CommandUnmute.java

示例7: execute

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
@Override
protected void execute(CommandEvent commandEvent) {
    Config configForServer = null;
    try {
        final Guild guild = commandEvent.getGuild();
        if (guild != null) {
            final String server = guild.getName().trim().toLowerCase();
            configForServer = serverConfigRepository.getConfigForServer(server);
            if (configForServer == null) {
                final String noConfigText = localeService.getMessageFor(LocaleService.NO_CONFIG,
                        localeService.getLocaleForUser(commandEvent.getAuthor()));
                commandEvent.reply(noConfigText);
                if (commandListener != null) {
                    commandListener.onCompletedCommand(commandEvent, this);
                }
                return;
            }
        }
        executeWithConfig(commandEvent, configForServer);
        if (commandListener != null) {
            commandListener.onCompletedCommand(commandEvent, this);
        }
    } catch (Throwable t) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Exception thrown from command " + this.getClass().getSimpleName()
                    + " with input message \"" + commandEvent.getMessage().getRawContent() + "\"" +
                    (configForServer != null ? " for server " +
                            configForServer.getServer() : "") + ":\n" + t.getMessage());
            if (t.getMessage() == null) {
                LOGGER.debug("Dumping stacktrace, since exception was null.", t);
            }
        }
        try {
            if (t instanceof IllegalArgumentException) {
                getFeedbackStrategy(configForServer).replyError(configForServer, commandEvent,
                        new UserMessedUpException(commandEvent.getAuthor().getName(), t.getMessage()), localeService);
            } else {
                getFeedbackStrategy(configForServer).replyError(configForServer, commandEvent, t, localeService);
            }
            if (commandListener != null) {
                commandListener.onTerminatedCommand(commandEvent, this);
            }
        } catch (Throwable tt) {
            LOGGER.warn("Exception when trying to give feedback about an error for server " + configForServer +
                    ": " + tt.getMessage());
        }
    }
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:49,代码来源:ConfigAwareCommand.java

示例8: createEmote

import com.jagrosh.jdautilities.commandclient.CommandEvent; //导入方法依赖的package包/类
private void createEmote(String iconName, CommandEvent commandEvent, Icon icon, Role... roles) {
    JSONObject body = new JSONObject();
    body.put("name", iconName);
    body.put("image", icon.getEncoding());
    if (roles.length > 0) // making sure none of the provided roles are null before mapping them to the snowflake id
    {
        body.put("roles",
                Stream.of(roles).filter(Objects::nonNull).map(ISnowflake::getId).collect(Collectors.toSet()));
    }

    // todo: check bot permissions, must be able to handle emojis
    GuildImpl guild = (GuildImpl) commandEvent.getGuild();
    JDA jda = commandEvent.getJDA();
    Route.CompiledRoute route = Route.Emotes.CREATE_EMOTE.compile(guild.getId());
    AuditableRestAction<Emote> action = new AuditableRestAction<Emote>(jda, route, body)
    {
        @Override
        protected void handleResponse(Response response, Request<Emote> request)
        {
            if (response.isOk()) {
                JSONObject obj = response.getObject();
                final long id = obj.getLong("id");
                String name = obj.getString("name");
                EmoteImpl emote = new EmoteImpl(id, guild).setName(name);
                // managed is false by default, should always be false for emotes created by client accounts.

                JSONArray rolesArr = obj.getJSONArray("roles");
                Set<Role> roleSet = emote.getRoleSet();
                for (int i = 0; i < rolesArr.length(); i++)
                {
                    roleSet.add(guild.getRoleById(rolesArr.getString(i)));
                }

                // put emote into cache
                guild.getEmoteMap().put(id, emote);

                request.onSuccess(emote);
            }
            else {
                request.onFailure(response);
                throw new RuntimeException("Couldn't install emojis. " +
                        "Make sure that pokeraidbot has access to manage emojis.");
            }
        }
    };
    action.queue();
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:48,代码来源:InstallEmotesCommand.java


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