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


Java GuildMessageReceivedEvent.getAuthor方法代码示例

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


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

示例1: closeVote

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
private void closeVote(GuildMessageReceivedEvent event){
    Message message = event.getMessage();
    User author = event.getAuthor();
    if(!polls.containsKey(event.getGuild())){
        message("There is currently no poll running on this guild", Color.red);
        return;
    }

    Poll poll = polls.get(event.getGuild());

    if(core.permissionHandler.check(2,event)){
            return;
    }

    polls.remove(event.getGuild());
    channel.sendMessage(getParsedPoll(poll, event.getGuild()).build()).queue();
    message(":white_check_mark: Poll was closed by" + event.getAuthor().getAsMention(), new Color(0x3AD70E));
    Message pollmsg = channel.getMessageById(String.valueOf(poll.pollmsg)).complete();
    try {
        pollmsg.delete().queue();
    } catch (ErrorResponseException e){
        //This is an empty Catch Block
    }


}
 
开发者ID:LeeDJD,项目名称:Amme,代码行数:27,代码来源:Vote.java

示例2: action

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
@Override
public void action(String[] args, GuildMessageReceivedEvent event) throws ParseException, IOException {
    if (core.permissionHandler.check(4, event)) return;

    String message = String.join(" ", args).split("@")[0];
    User memb = event.getMessage().getMentionedUsers().size() > 0 ?  event.getMessage().getMentionedUsers().get(0) : null;
    User author = event.getAuthor();
    TextChannel chan = event.getChannel();

    if (args.length < 2 || memb == null) {
        chan.sendMessage(new EmbedBuilder().setColor(Color.red).setDescription(help()).build()).queue();
        return;
    }
    event.getMessage().delete().queue();

    memb.openPrivateChannel().queue(pc -> pc.sendMessage(message.substring(0, message.length() - 1)).queue());
}
 
开发者ID:LeeDJD,项目名称:Amme,代码行数:18,代码来源:say.java

示例3: action

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
@Override
public void action(String[] args, GuildMessageReceivedEvent event) throws ParseException, IOException {
    User author = event.getAuthor();
    Message message = event.getMessage();
    MessageChannel channel = event.getChannel();
    Guild guild = event.getGuild();
    channel.sendTyping().queue();
    message.delete().queue();

    if(args.length > 0){
        try {
            PrivateChannel privch = author.openPrivateChannel().complete();
            Url bitlink = as(STATICS.BITLYUSERNAME, SECRETS.bitlytoken).call(shorten(args[0]));
            embedSender.sendEmbed(":white_check_mark: Successfully created shortlink " + bitlink.getShortUrl(), channel, Color.green);
            privch.sendTyping().queue();
            embedSender.sendEmbed(":ballot_box_with_check: You have successfully shortened the link `" + bitlink.getLongUrl() + "` \n to " + bitlink.getShortUrl(), privch, Color.green);
        } catch (BitlyException e){
            embedSender.sendEmbed(":warning: Please send an valid URL", channel, Color.yellow);
        }
    } else {
        embedSender.sendEmbed("Usage: `" + "*" + "short <URL>`", channel, Color.red);
    }
}
 
开发者ID:LeeDJD,项目名称:Amme,代码行数:24,代码来源:shorter.java

示例4: createPoll

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
private void createPoll(String[] args, GuildMessageReceivedEvent event){

        Message message = event.getMessage();
        User author = event.getAuthor();
        if(permissionHandler.check(2,event)){

            if(permissionHandler.check(2,event)){
                embedSender.sendEmbed("Sorry, " + author.getAsMention() + " but you don't have the permission to perform that command!", channel, Color.red);
                return;
            }
            return;
        }

        String argsSTRG = String.join(" ", new ArrayList<>(Arrays.asList(args).subList(1, args.length)));
        List<String> content = Arrays.asList(argsSTRG.split("\\|"));
        String heading = content.get(0);
        List<String> answers = new ArrayList<>(content.subList(1, content.size()));


        Message pollmessage = channel.sendMessage(new EmbedBuilder().setDescription("Creating poll...").setColor(Color.cyan).build()).complete();
        String pollmsg = pollmessage.getId();

        Poll poll = new Poll(event.getMember(), heading, answers, pollmsg);
        polls.put(event.getGuild(), poll);

        List<String> emotis = new ArrayList<>(Arrays.asList(EMOTI));
        answers.forEach(a -> {
            toAddEmojis.add(emotis.get(0));
            emotis.remove(0);


        });
        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                pollmessage.editMessage(getParsedPoll(poll, event.getGuild()).build()).queue();
                toAddEmojis.forEach((String s) -> pollmessage.addReaction(s).queue());
            }
        }, 1500);
    }
 
开发者ID:LeeDJD,项目名称:Amme,代码行数:41,代码来源:Vote.java

示例5: createCommandLog

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
private void createCommandLog(GuildMessageReceivedEvent event, Command command, String commandName, String args) {
    User author = event.getAuthor();
    CommandlogsRecord record = bot.getDatabase().newRecord(Tables.COMMANDLOGS);
    record.setCommand(commandName);
    record.setArguments(args);
    record.setTime(new Timestamp((new Date()).getTime()));
    record.setUsername(DiscordUtils.getTag(author));
    record.setUserid(author.getId());
    record.setGuildname(event.getGuild().getName());
    record.setGuildid(event.getGuild().getId());
    record.store();
}
 
开发者ID:Samoxive,项目名称:SafetyJim,代码行数:13,代码来源:DiscordShard.java

示例6: SafeGuildMessageReceivedEvent

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
public SafeGuildMessageReceivedEvent(GuildMessageReceivedEvent event, int maxMessages) {
    this.event = event;
    this.channel = new SafeChannel(event.getChannel(), maxMessages);
    this.author = new SafeUser(event.getAuthor());
    this.member = new SafeMember(event.getMember());
    this.guild = new SafeGuild(event.getGuild(), channel);
    this.message = new SafeMessage(event.getMessage());
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:9,代码来源:SafeGuildMessageReceivedEvent.java

示例7: action

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
@Override
public void action(String[] args, GuildMessageReceivedEvent event) throws ParseException, IOException {
    //CODE BY SCHLAUBI
    User author = event.getAuthor();
    Message message = event.getMessage();
    MessageChannel channel = event.getChannel();
    Guild guild =event.getGuild();
    channel.sendTyping().queue();
    message.delete().queue();


    Member member;
    if (args.length > 0){
        //DANke SCHLAUBI
        member = guild.getMember(event.getMessage().getMentionedUsers().get(0));
    }else
        member = guild.getMember(event.getAuthor());
    String NAME = member.getEffectiveName();
    String TAG = member.getUser().getName() + "#" + member.getUser().getDiscriminator();
    String ID = member.getUser().getId();
    String STATUS = member.getOnlineStatus().getKey();
    String ROLES = "";
    String GAME;
    String AVATAR = member.getUser().getAvatarUrl();
    String GUILDDATE = member.getJoinDate().format(DateTimeFormatter.RFC_1123_DATE_TIME);
    String JOINDATE = member.getUser().getCreationTime().format(DateTimeFormatter.RFC_1123_DATE_TIME);

    try {
        GAME = member.getGame().getName();
    } catch (Exception e){
        GAME = "~";
    }
    if(AVATAR == null){
        AVATAR = "No avatar";
    }
    for(Role role : member.getRoles()){
        ROLES += role.getName() + ", ";
    }
    if(ROLES.length() > 0){
        ROLES = ROLES.substring(0, ROLES.length()-2);
    } else {
        ROLES = "NO ROLES";
    }
    EmbedBuilder embed = new EmbedBuilder()
            .setColor(Color.cyan)
            .setDescription(":spy: UserInfo for " + NAME + " (" + TAG + ")")
            .addField("Name/Nick", NAME, false)
            .addField("User tag", TAG, false)
            .addField("User id", ID , false)
            .addField("Current status", STATUS, false)
            .addField("Current game", GAME, false)
            .addField("Guild joined", GUILDDATE, false)
            .addField("Roles", ROLES, false)
            .addField("Dicord joined", JOINDATE, false)
            .addField("Avatar url", AVATAR, false);
    if(AVATAR != "No avatar"){
        embed.setThumbnail(AVATAR);
    }
    channel.sendMessage(embed.build()).queue();
}
 
开发者ID:LeeDJD,项目名称:Amme,代码行数:61,代码来源:UserInfo.java

示例8: run

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
@Override
public boolean run(DiscordBot bot, GuildMessageReceivedEvent event, String args) {
    Scanner messageIterator = new Scanner(args);
    JDA shard = event.getJDA();

    Member member = event.getMember();
    User user = event.getAuthor();
    Message message = event.getMessage();
    TextChannel channel = event.getChannel();
    Guild guild = event.getGuild();

    if (!member.hasPermission(Permission.KICK_MEMBERS)) {
        DiscordUtils.failMessage(bot, message, "You don't have enough permissions to execute this command!");
        return false;
    }

    if (!messageIterator.hasNext(DiscordUtils.USER_MENTION_PATTERN)) {
        return true;
    } else {
        // advance the scanner one step to get rid of user mention
        messageIterator.next();
    }

    User warnUser = message.getMentionedUsers().get(0);
    Member warnMember = guild.getMember(warnUser);

    if (user.getId().equals(warnUser.getId())) {
        DiscordUtils.failMessage(bot, message, "You can't warn yourself, dummy!");
        return false;
    }

    String reason = TextUtils.seekScannerToEnd(messageIterator);
    reason = reason.equals("") ? "No reason specified" : reason;

    Date now = new Date();

    EmbedBuilder embed = new EmbedBuilder();
    embed.setTitle("Warned in " + guild.getName());
    embed.setColor(new Color(0x4286F4));
    embed.setDescription("You were warned in " + guild.getName());
    embed.addField("Reason:", reason, false);
    embed.setFooter("Warned by " + DiscordUtils.getUserTagAndId(user), null);
    embed.setTimestamp(now.toInstant());

    try {
        DiscordUtils.sendDM(warnUser, embed.build());
    } catch (Exception e) {
        DiscordUtils.sendMessage(channel, "Could not send a warning to the specified user via private message!");
    }

    DiscordUtils.successReact(bot, message);

    DSLContext database = bot.getDatabase();

    WarnlistRecord record = database.insertInto(Tables.WARNLIST,
            Tables.WARNLIST.USERID,
            Tables.WARNLIST.MODERATORUSERID,
            Tables.WARNLIST.GUILDID,
            Tables.WARNLIST.WARNTIME,
            Tables.WARNLIST.REASON)
            .values(warnUser.getId(),
                    user.getId(),
                    guild.getId(),
                    now.getTime() / 1000,
                    reason)
            .returning(Tables.WARNLIST.ID)
            .fetchOne();

    DiscordUtils.createModLogEntry(bot, shard, message, warnMember, reason, "warn", record.getId(), null, false);
    DiscordUtils.sendMessage(channel, "Warned " + DiscordUtils.getUserTagAndId(warnUser));

    return false;
}
 
开发者ID:Samoxive,项目名称:SafetyJim,代码行数:74,代码来源:Warn.java

示例9: handleCustom

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
public void handleCustom(GuildMessageReceivedEvent event, String cmdname) {
    GabrielData.GuildData data = GabrielData.guilds().getObject(event.getGuild().getId());
    if(data == null) return;
    CustomCommand custom = data.customCommands.get(cmdname);
    if(custom == null) return;
    if(!PermissionUtil.checkPermission(event.getChannel(), event.getGuild().getSelfMember(), Permission.MESSAGE_EMBED_LINKS)) {
        event.getChannel().sendMessage("I need the Embed Links permission").queue();
        return;
    }
    String rawInput = event.getMessage().getRawContent();

    User user = event.getAuthor();
    Member m = event.getMember();
    Guild g = event.getGuild();
    Message msg = event.getMessage();
    TextChannel c = event.getChannel();
    String input = rawInput.substring(rawInput.indexOf(cmdname)+cmdname.length()).trim();
    String processed = custom.process(event, input,
            "user", event.getAuthor().getName(),
            "discrim", event.getAuthor().getDiscriminator(),
            "mention", event.getAuthor().getAsMention(),
            "channel", event.getChannel().getName(),
            "userid", event.getAuthor().getId(),
            "channelid", event.getChannel().getId(),
            "guild", event.getGuild().getName(),
            "guildid", event.getGuild().getId(),
            "event.message.raw", input,
            "event.message.stripped", msg.getStrippedContent(),
            "event.message", msg.getContent(),
            "event.author.mention", user.getAsMention(),
            "event.author.username", user.getName(),
            "event.author.discriminator", user.getDiscriminator(),
            "event.author.name", m.getEffectiveName(),
            "event.guild.name", g.getName(),
            "event.guild.owner.name", g.getOwner().getEffectiveName(),
            "event.guild.owner.username", g.getOwner().getUser().getName(),
            "event.guild.owner.discriminator", g.getOwner().getUser().getDiscriminator(),
            "event.channel.name", c.getName(),
            "event.channel.topic", c.getTopic(),
            "event.channel.mention", c.getAsMention()
    );
    if(processed == null) return;
    if(processed.length() > 1990) {
        processed = "Done! " + Utils.paste(processed);
    }
    event.getChannel().sendMessage(processed).queue();
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:48,代码来源:CommandRegistry.java

示例10: attemptUnsignFromMinusCommand

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
private void attemptUnsignFromMinusCommand(GuildMessageReceivedEvent guildMessageReceivedEvent, String[] splitArguments) {
    final String numberOfPeopleArgument = splitArguments[0];
    final String[] gymArgument = ArrayUtils.removeAll(splitArguments, 0);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Trying to remove " + numberOfPeopleArgument + " from raid, gym " +
                StringUtils.join(gymArgument, " "));
    }
    final String guild = guildMessageReceivedEvent.getGuild().getName().trim().toLowerCase();
    final Config configForServer = serverConfigRepository.getConfigForServer(guild);
    final User user = guildMessageReceivedEvent.getAuthor();
    String message;
    try {
        message = raidRepository.executeUnsignCommand(configForServer, user,
                localeService.getLocaleForUser(user),
                splitArguments, "signup");
        guildMessageReceivedEvent.getMessage().addReaction(Emotes.OK).queue();
        ConfigAwareCommand.removeOriginMessageIfConfigSaysSo(configForServer, guildMessageReceivedEvent);
    } catch (Throwable t) {
        LOGGER.debug("Unsign command failed: " + t.getMessage());
        message = t.getMessage() + "\n\n" +
        "Syntax: *-1 Solna Platform*";
        guildMessageReceivedEvent.getMessage().addReaction(Emotes.ERROR).queue();
        ConfigAwareCommand.removeOriginMessageIfConfigSaysSo(configForServer, guildMessageReceivedEvent);
    }
    if (!StringUtils.isEmpty(message)) {
        EmbedBuilder embedBuilder = new EmbedBuilder();
        embedBuilder.setAuthor(null, null, null);
        embedBuilder.setTitle(null);
        embedBuilder.setDescription(message);
        final String msgRemoveText =
                localeService.getMessageFor(LocaleService.KEEP_CHAT_CLEAN,
                        localeService.getLocaleForUser(user),
                        "15");
        embedBuilder.setFooter(msgRemoveText, null);
        guildMessageReceivedEvent.getMessage().getChannel().sendMessage(embedBuilder.build())
                .queue(msg -> {
                    msg.delete().queueAfter(15, TimeUnit.SECONDS); // Clean up feedback after x seconds
                }
        );
        LOGGER.debug("Removed signup.");
    }
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:43,代码来源:UnsignWithMinusCommandListener.java

示例11: attemptSignUpFromPlusCommand

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
private void attemptSignUpFromPlusCommand(GuildMessageReceivedEvent guildMessageReceivedEvent, String[] splitArguments) {
    final String numberOfPeopleArgument = splitArguments[0];
    final String etaArgument = splitArguments[1];
    final String[] gymArgument = ArrayUtils.removeAll(splitArguments, 0, 1);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Trying to add " + numberOfPeopleArgument + " to raid, ETA " + etaArgument + " to gym " +
                StringUtils.join(gymArgument, " "));
    }
    final String guild = guildMessageReceivedEvent.getGuild().getName().trim().toLowerCase();
    final Config configForServer = serverConfigRepository.getConfigForServer(guild);
    final User user = guildMessageReceivedEvent.getAuthor();
    String message;
    try {
        message = raidRepository.executeSignUpCommand(configForServer, user,
                localeService.getLocaleForUser(user),
                splitArguments, "signup");
        guildMessageReceivedEvent.getMessage().addReaction(Emotes.OK).queue();
        ConfigAwareCommand.removeOriginMessageIfConfigSaysSo(configForServer, guildMessageReceivedEvent);
    } catch (Throwable t) {
        LOGGER.debug("Signup plus command failed: " + t.getMessage());
        message = t.getMessage() + "\n\n" +
        "Syntax: *+1 09:45 Solna Platform*";
        guildMessageReceivedEvent.getMessage().addReaction(Emotes.ERROR).queue();
        ConfigAwareCommand.removeOriginMessageIfConfigSaysSo(configForServer, guildMessageReceivedEvent);
    }
    if (!StringUtils.isEmpty(message)) {
        EmbedBuilder embedBuilder = new EmbedBuilder();
        embedBuilder.setAuthor(null, null, null);
        embedBuilder.setTitle(null);
        embedBuilder.setDescription(message);
        final String msgRemoveText =
                localeService.getMessageFor(LocaleService.KEEP_CHAT_CLEAN,
                        localeService.getLocaleForUser(user), "15");
        embedBuilder.setFooter(msgRemoveText, null);
        guildMessageReceivedEvent.getMessage().getChannel().sendMessage(embedBuilder.build())
                .queue(msg -> {
                    msg.delete().queueAfter(15, TimeUnit.SECONDS); // Clean up feedback after x seconds
                }
        );
        LOGGER.debug("Added signup.");
    }
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:43,代码来源:SignupWithPlusCommandListener.java

示例12: privateMessage

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
private static void privateMessage(String content, Color color, GuildMessageReceivedEvent event){
    User author = event.getAuthor();
    EmbedBuilder eb = new EmbedBuilder().setDescription(content).setColor(color);
    PrivateChannel privch = author.openPrivateChannel().complete();
    privch.sendTyping().queue();
    privch.sendMessage(eb.build()).queue();



}
 
开发者ID:LeeDJD,项目名称:Amme,代码行数:11,代码来源:Vote.java


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