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


Java GuildMessageReceivedEvent.getChannel方法代码示例

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


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

示例1: 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;
    MessageChannel channel = event.getChannel();
    channel.sendTyping().queue();
    event.getMessage().delete().queue();

    util.embedSender.sendEmbed(":battery: System Restarting!", channel, Color.GREEN);

    //Code by ZekroTJA(github.com/ZekroTJA)
    if (System.getProperty("os.name").toLowerCase().contains("linux"))
        Runtime.getRuntime().exec("screen python restart.py");

    System.exit(0);

}
 
开发者ID:LeeDJD,项目名称:Amme,代码行数:17,代码来源:Restart.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: 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);

    Member member = event.getMember();
    Message message = event.getMessage();
    TextChannel channel = event.getChannel();
    Guild guild = event.getGuild();
    Member selfMember = guild.getSelfMember();

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

    if (!selfMember.hasPermission(Permission.MESSAGE_MANAGE)) {
        DiscordUtils.failMessage(bot, message, "I don't have enough permissions to do that!");
        return false;
    }

    if (!messageIterator.hasNextInt()) {
        DiscordUtils.failReact(bot, message);
        return true;
    }

    int messageCount = messageIterator.nextInt();

    if (messageCount < 1) {
        DiscordUtils.failMessage(bot, message, "You can't delete zero or negative messages.");
        return false;
    } else if (messageCount > 100) {
        DiscordUtils.failMessage(bot, message, "You can't delete more than 100 messages at once.");
        return false;
    }

    String targetArgument;
    User targetUser = null;

    if (!messageIterator.hasNext()) {
        targetArgument = "";
    } else if (messageIterator.hasNext(DiscordUtils.USER_MENTION_PATTERN)) {
        targetUser = message.getMentionedUsers().get(0);
        targetArgument = "user";
    } else {
        targetArgument = messageIterator.next();
    }

    List<Message> messages;
    switch (targetArgument) {
        case "":
            messages = fetchMessages(channel, messageCount, true, false, false, null);
            break;
        case "bot":
            messages = fetchMessages(channel, messageCount, false, true, false, null);
            break;
        case "user":
            if (targetUser != null) {
                messages = fetchMessages(channel, messageCount, true, false, true, targetUser);
                break;
            }
        default:
            DiscordUtils.failMessage(bot, message, "Invalid target, please try mentioning a user or writing `bot`.");
            return false;
    }

    Pair<List<Message>, List<Message>> seperatedMessages = seperateMessages(messages);
    bulkDelete(seperatedMessages, channel);
    DiscordUtils.successReact(bot, message);

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

示例5: run

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

    if (!embedHasAvatarURL) {
        embedBuilder.setAuthor("Safety Jim", null, shard.getSelfUser().getAvatarUrl());
        embed = embedBuilder.build();
        embedHasAvatarURL = true;
    }

    DiscordUtils.successReact(bot, message);
    DiscordUtils.sendMessage(channel, embed);

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

示例6: action

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

    channel = event.getChannel();
    event.getMessage().delete().queue();
    channel.sendTyping().queue();

    if (args.length < 1) {
        message(help(), Color.red);
    } else {
        switch (args[0].toLowerCase()) {
            case "create":
                createPoll(args, event);
                break;
            case "v":
                votePoll(args, event);
                break;
            case "stats":
                voteStats(event);
                break;
            case "close":
                closeVote(event);
                break;

        }

        polls.forEach((guild, poll) -> {
            File path = new File("SERVER_SETTINGS/" + guild.getId() + "/");
            if(!path.exists())
                path.mkdirs();
            try {
                savePoll(guild);
            } catch (IOException e) {
                e.printStackTrace();
            }
        });
    }


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

示例7: action

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

    if(args.length > 0){
        String query = "";
        for(int i = 0; i < args.length; i++){
            query += " " + args[i];
        }
        String url = "http://lmgtfy.com/?iie=1&q=" + query.replace( " ", "%20");

        embedSender.sendEmbed("Link created send the following link to the person which needs help " + url, channel, Color.green);
    }}
 
开发者ID:LeeDJD,项目名称:Amme,代码行数:16,代码来源:lmgtfy.java

示例8: run

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
@Override
public boolean run(DiscordBot bot, GuildMessageReceivedEvent event, String args) {
    Guild guild = event.getGuild();
    User owner = guild.getOwner().getUser();
    TextChannel channel = event.getChannel();
    Message message = event.getMessage();
    String memberCount = Long.toString(guild.getMemberCache().size());
    String creationDate = guild.getCreationTime().toLocalDate().toString();
    StringBuilder emojis = new StringBuilder();

    for (Emote emote: guild.getEmotes()) {
        emojis.append(emote.getAsMention());
    }

    String emojiString = emojis.toString();
    emojiString = emojiString.equals("") ? "None" : emojiString;

    EmbedBuilder embed = new EmbedBuilder();
    embed.setAuthor(guild.getName(), null, guild.getIconUrl());
    embed.setColor(new Color(0x4286F4));
    embed.addField("Server Owner", DiscordUtils.getTag(owner), true);
    embed.addField("Member Count", memberCount, true);
    embed.addField("Creation Date", creationDate, true);
    embed.addField("Emojis", emojiString, false);

    DiscordUtils.successReact(bot, message);
    DiscordUtils.sendMessage(channel, embed.build());

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

示例9: displayTags

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
private void displayTags(DiscordBot bot, GuildMessageReceivedEvent event) {
    DSLContext database = bot.getDatabase();
    JDA shard = event.getJDA();
    Guild guild = event.getGuild();
    TextChannel channel = event.getChannel();
    Message message = event.getMessage();

    Result<TaglistRecord> records = database.selectFrom(Tables.TAGLIST)
                                            .where(Tables.TAGLIST.GUILDID.eq(guild.getId()))
                                            .fetch();

    if (records.isEmpty()) {
        DiscordUtils.successReact(bot, message);
        DiscordUtils.sendMessage(channel, "No tags have been added yet!");
        return;
    }

    StringJoiner tagString = new StringJoiner("\n");

    for (TaglistRecord record: records) {
        tagString.add("\u2022 `" + record.getName() + "`");
    }

    EmbedBuilder embed = new EmbedBuilder();
    embed.setAuthor("Safety Jim", null, shard.getSelfUser().getAvatarUrl());
    embed.addField("List of tags", tagString.toString(), false);
    embed.setColor(new Color(0x4286F4));

    DiscordUtils.successReact(bot, message);
    DiscordUtils.sendMessage(channel, embed.build());
}
 
开发者ID:Samoxive,项目名称:SafetyJim,代码行数:32,代码来源:Tag.java

示例10: handleSettingsDisplay

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
private void handleSettingsDisplay(DiscordBot bot, GuildMessageReceivedEvent event) {
    JDA shard = event.getJDA();
    TextChannel channel = event.getChannel();
    Message message = event.getMessage();
    SelfUser selfUser = shard.getSelfUser();
    String output = getSettingsString(bot, event);

    EmbedBuilder embed = new EmbedBuilder();
    embed.setAuthor("Safety Jim", null, selfUser.getAvatarUrl());
    embed.addField("Guild Settings", output, false);
    embed.setColor(new Color(0x4286F4));

    DiscordUtils.successReact(bot, message);
    DiscordUtils.sendMessage(channel, embed.build());
}
 
开发者ID:Samoxive,项目名称:SafetyJim,代码行数:16,代码来源:Settings.java

示例11: 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

示例12: action

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
@Override
public void action(String[] args, GuildMessageReceivedEvent event) throws ParseException, IOException {
    Guild guild = event.getGuild();
    MessageChannel channel = event.getChannel();
    if (core.permissionHandler.check(3, event)) return;
    if (args.length < 2) event.getChannel().sendMessage(help());
    String joinmessage = SQL.getValue(guild, "joinmessage");
    switch (args[0].toLowerCase()) {
        case "msg":
            if (args[1].toLowerCase().equals("toggle")) {
                String enabled = SQL.getValue(guild, "msg");

                if(enabled.equals("1")){
                    SQL.updateValue(guild, "msg", "0");
                    embedSender.sendEmbed(":white_check_mark: Succesfully disabled Write Comment!", channel, Color.green);
                } else if(enabled.equals("0")){
                    SQL.updateValue(guild, "msg", "1");
                    embedSender.sendEmbed(":white_check_mark: Succesfully enabled Write Comment!", channel, Color.green);
                }

            }
            break;
        case "prefix":
            if (args.length < 2) {
                event.getChannel().sendMessage(help());
                return;
            }
            SQL.updateValue(guild, "prefix", args[1]);
            embedSender.sendEmbed(":white_check_mark: Succesfully set the Prefix!", channel, Color.green);
            break;
        case "logchannel":
            if (args.length < 2) {
                event.getChannel().sendMessage(help());
                return;
            }
            String txt = event.getMessage().getMentionedChannels().get(0).getId();
            SQL.updateValue(guild, "logchannel", txt);
            embedSender.sendEmbed(":white_check_mark: Succesfully set the LogChannel!", channel, Color.green);
            break;
        case "autorole":
            if (args.length < 2) {
                event.getChannel().sendMessage(help() + "\n(watch for large and lower case\n)");
                return;
            }
            SQL.updateValue(guild, "autorole", args[1]);
            embedSender.sendEmbed(":white_check_mark: Succesfully set the Autorole!", channel, Color.green);
            break;
        case "joinmessage":
            if (args.length < 2) {
                event.getChannel().sendMessage(help() + "\n(watch for large and lower case\n)");
                return;
            }
            String temp = "";
            for(int i = 1; i < args.length; i++){
                temp += " " + args[i];
            }
            SQL.updateValue(guild, "joinmessage", temp.replaceFirst("null ", ""));
            String up = SQL.getValue(guild, "joinmessage");
            embedSender.sendEmbed(":white_check_mark:  Successfully set joinmessage to `" + up + "`!", channel, Color.green);
            break;
        case "joinmessagechannel":
            if (args.length < 2) {
                event.getChannel().sendMessage(help() + "\n(watch for large and lower case\n)");
                return;
            }
            String ch = event.getMessage().getMentionedChannels().get(0).getId();
            SQL.updateValue(guild, "joinchannel", ch);
            embedSender.sendEmbed(":white_check_mark: Succesfully set the Joinmessagechannel!", channel, Color.green);
            break;
    }
}
 
开发者ID:LeeDJD,项目名称:Amme,代码行数:72,代码来源:settings.java

示例13: 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

示例14: handleRaidFromIntegration

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
public void handleRaidFromIntegration(User user, GuildMessageReceivedEvent guildEvent, Pokemon raidBoss, Gym raidGym,
                                      LocalDateTime endOfRaid, Config config, ClockService clockService,
                                      PokemonRaidInfo pokemonRaidInfo,
                                      PokemonRaidStrategyService pokemonRaidStrategyService) {
    Validate.notNull(user, "User");
    Validate.notNull(guildEvent, "Guild event");
    Validate.notNull(config, "Config");
    Validate.notNull(raidBoss, "Raid boss");
    Validate.notNull(raidGym, "Gym");
    Validate.notNull(user, "User");

    final LocalDateTime now = clockService.getCurrentDateTime();
    LocalDateTime currentDateTime = now;
    final boolean moreThan10MinutesLeftOnRaid = endOfRaid.isAfter(currentDateTime.plusMinutes(10));
    if (moreThan10MinutesLeftOnRaid) {
        final Raid raidToCreate = new Raid(raidBoss,
                endOfRaid,
                raidGym,
                localeService, config.getRegion());
        final MessageChannel channel = guildEvent.getChannel();
        try {
            if (raidRepository.isActiveOrExRaidAt(raidGym, config.getRegion())) {
                Raid existingRaid =
                        raidRepository.getActiveRaidOrFallbackToExRaid(raidGym, config.getRegion(), user);
                if (existingRaid.getPokemon().isEgg()) {
                    existingRaid = raidRepository.changePokemon(existingRaid, raidBoss,
                            guildEvent.getGuild(), config, user,
                            "(bot) " +
                                    "!raid hatch " + raidBoss.getName() + " " + existingRaid.getGym().getName());
                    LOGGER.info("Hatched raid: " + existingRaid);
                } else {
                    LOGGER.info("Raid already present, which is not an egg to hatch. " +
                            "Skipping raid at: " + raidGym.getName() + " for server " + config.getServer());
                }
            } else {
                createRaid(user, guildEvent, config, clockService, pokemonRaidInfo, now, raidToCreate, channel);
            }
        } catch (Throwable t) {
            LOGGER.warn("Exception when trying to create raid via botintegration for server " +
                    config.getServer() + ", channel " + (channel != null ? channel.getName() : "NULL") + ": " +
                    t.getMessage());
        }
    } else {
        LOGGER.debug("Skipped creating raid at " + raidGym +
                ", less than 10 minutes remaining on it.");
    }
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:48,代码来源:GymHuntrRaidEventListener.java

示例15: onGuildMessageReceived

import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; //导入方法依赖的package包/类
@Override
public void onGuildMessageReceived(GuildMessageReceivedEvent event)
{
    //TODO: Automod!
    /*
    Want the following:
        * Configurable auto deleting of links and file uploads
        * Whitelist/Blacklist for links and bad words
        * Regex on bad words (print to the log what words were matched in the message
        * Configurable muting when someone's done bad enough things:
            * Posted too many bad words within X time (default 5mins?)
            * Posted too many messages (configurable) within X time (default 5 messages in 2s?)
            * Posted too many duplicate characters in a message (default >60% similar characters in a message?)
     */

    Message message = event.getMessage();
    User author = message.getAuthor();

    //Ignore Admins and Moderators
    if(MDCBot.isMemberBotModerator(event.getGuild().getMember(author)))
        return;

    String content = message.getContent();
    TextChannel channel = event.getChannel();
    String channelName = channel.getName();

    if(checkLinks(channelName, message))
        deleteMessage(message, "Deleted message containing link from member %s (%s) in %s (%s):%s", author.getAsMention(), author.getName(), channel.getAsMention(), channelName, content);

    if(checkFiles(channelName, message))
    {
        StringBuilder sb = new StringBuilder();
        for(Message.Attachment a : message.getAttachments())
            sb.append("\n").append(a.getUrl());
        deleteMessage(message, "Deleted file posted by member %s (%s) in %s (%s):%s", author.getAsMention(), author.getName(), channel.getAsMention(), channelName, sb.toString());
    }

    if(checkSpamCharacters(channelName, content))
        deleteMessage(message, "Deleted message containing spammed characters from member %s (%s) in %s (%s):%s", author.getAsMention(), author.getName(), channel.getAsMention(), channelName, content);

    if(checkSpamMessages(channelName, message))
        for(Message m : messageSpamCache.get(author.getIdLong()))
            deleteMessage(m, "Deleted message due to spam from member %s (%s) in %s (%s):%s", author.getAsMention(), author.getName(), channel.getAsMention(), channelName, m.getContent());

    if(checkBadWords(channelName, content))
        deleteMessage(message, "Deleted message due to bad words from member %s (%s) in %s (%s):%s", author.getAsMention(), author.getName(), channel.getAsMention(), channelName, content);
}
 
开发者ID:thebrightspark,项目名称:MDC-Discord-Bot,代码行数:48,代码来源:AutomodListener.java


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