當前位置: 首頁>>代碼示例>>Java>>正文


Java Message.getChannel方法代碼示例

本文整理匯總了Java中net.dv8tion.jda.core.entities.Message.getChannel方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.getChannel方法的具體用法?Java Message.getChannel怎麽用?Java Message.getChannel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.dv8tion.jda.core.entities.Message的用法示例。


在下文中一共展示了Message.getChannel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onGuildMessageReceived

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
    Message message = event.getMessage();
    checkForAdvertising(event.getMember(), event.getMessage(), event.getChannel());
    if (message.getChannel() == Channels.BOT_META.getChannel() && message.isWebhookMessage()) {
        MessageEmbed embed = message.getEmbeds().get(0);
        if ((embed.getTitle().startsWith("[WheezyGold7931/happybot] Issue closed:") || embed.getTitle().startsWith("[WheezyGold7931/happybot] New comment on issue") ) && !RuntimeEditor.isPingIssueClose())
            return;
        Roles.GIT.getRole().getManager().setMentionable(true).queue();
        Channels.BOT_META.getChannel().sendMessage(Roles.GIT.getRole().getAsMention()).queue();
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            Roles.GIT.getRole().getManager().setMentionable(false).queue();
        }
    }
        
}
 
開發者ID:WheezyGold7931,項目名稱:happybot,代碼行數:21,代碼來源:AutoMod.java

示例2: doYaThing

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
    String content = message.getRawContent();
    MessageChannel channel = message.getChannel();
    String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
    try {
        if (commandNParameters.length > 1) {
            for (Submission s : RedditHandler.getPosts(commandNParameters[1], 2)) {
                channel.sendMessage("https://www.reddit.com" + s.getPermalink()).complete();
            }
        } else
            channel.sendMessage("```" + prefix + usage + "```").complete();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        channel.sendMessage("```" + e.getMessage() + "```").complete();
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:19,代碼來源:Reddit.java

示例3: doYaThing

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
    String content = message.getRawContent();
    MessageChannel channel = message.getChannel();
    String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
    try {
        if (commandNParameters.length > 1) {
            message.delete().complete();
            String whatToSay = DodoStringHandler.glueStringsBackTogether(commandNParameters, " ", 1);
            channel.sendMessage(whatToSay.substring(0, 1).toUpperCase() + whatToSay.substring(1) + ".").complete();
        } else {
            channel.sendMessage(getUsage()).complete();
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:19,代碼來源:Speak.java

示例4: doYaThing

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
    MessageChannel channel = message.getChannel();
    User author = message.getAuthor();
    try {
        BufferedImage avatar = ReadImage.readImageFromURL(author.getAvatarUrl());
        BufferedImage triggered = ReadImage.readImageFromDisk("triggered.jpg");
        DrawOnImg.drawImg(avatar, triggered, 0, avatar.getHeight() - 20, avatar.getWidth(), 20);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ImageIO.write(avatar, "png", baos);
        channel.sendFile(baos.toByteArray(), "triggered.png", null).complete();

    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:18,代碼來源:Triggered.java

示例5: doYaThing

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
    MessageChannel channel = message.getChannel();
    EmbedBuilder embMsg = new EmbedBuilder();
    try {
        embMsg.setTitle("About DodoBot", "https://github.com/ExidCuter/JDodoBot");
        embMsg.setThumbnail("https://pbs.twimg.com/profile_images/932637770874589186/KgP5zJjH_400x400.jpg");
        embMsg.setColor(new Color(0x13FF00));
        embMsg.addField("Version", ver, true);
        embMsg.addField("By", "Dodo Dodović", true);
        embMsg.addField("Servers", Integer.toString(getNumOfServers()), true);
        embMsg.addField("GitHub", "https://github.com/ExidCuter/JDodoBot", false);
        embMsg.addField("Donate", " https://www.paypal.me/DodoDodovic", false);
        channel.sendMessage(embMsg.build()).complete();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:20,代碼來源:About.java

示例6: CommandMessage

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
public CommandMessage(Message message, boolean mentionableCommand, String[] aliasArguments) {
    super(message.getIdLong(), message.getChannel(), message.isWebhookMessage(), message.getType());

    this.mentionableCommand = mentionableCommand;
    String rawContent = prepareRawContent(message.getRawContent(), aliasArguments != null);
    if (aliasArguments != null) {
        rawContent = ":alias " + String.join(" ", aliasArguments) + " " + rawContent;
    }

    this.setContent(rawContent)
        .setAuthor(message.getAuthor())
        .setTime(message.getCreationTime())
        .setEditedTime(message.getEditedTime())
        .setAttachments(message.getAttachments())
        .setEmbeds(message.getEmbeds())
        .setMentionedChannels(message.getMentionedChannels())
        .setMentionedRoles(message.getMentionedRoles())
        .setMentionedUsers(prepareMentionedUsers(message.getMentionedUsers()))
        .setMentionsEveryone(message.mentionsEveryone())
        .setReactions(message.getReactions())
        .setPinned(message.isPinned())
        .setTTS(message.isTTS());
}
 
開發者ID:avaire,項目名稱:avaire,代碼行數:24,代碼來源:CommandMessage.java

示例7: update

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
public void update(Message message) {
    if (!(message.getChannel() instanceof TextChannel)) {
        UIChannelListItem item = channelItems.get(message.getChannel().getId());
        channelList.remove(item);
        channelList.add(item,c,0);
        item.updatePreview(message);
        refresh();
    }
}
 
開發者ID:MCPlummet,項目名稱:TransparentDiscord,代碼行數:10,代碼來源:UIChannelList.java

示例8: doYaThing

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
    String content = message.getRawContent();
    MessageChannel channel = message.getChannel();
    String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
    try {
        if (commandNParameters.length > 2) {
            String quote = DodoStringHandler.glueStringsBackTogether(commandNParameters, " ", 2);
            quote = quote.replace("\"", "");
            Quote temp = new Quote(commandNParameters[1], quote);
            quotes.add(temp);
            FileHandler.writeToFile(quotes);
            channel.sendMessage(temp.toString()).complete();
        } else if (commandNParameters.length == 2) {
            Random rnd = new Random();
            ArrayList<Quote> tempQuotes = new ArrayList<>();
            for (Quote q : quotes) {
                System.out.println(q.getWho());
                if (q.getWho().toLowerCase().equals(commandNParameters[1].toLowerCase())) {
                    tempQuotes.add(q);
                }
            }
            if (tempQuotes.size() > 0)
                channel.sendMessage(tempQuotes.get(rnd.nextInt(tempQuotes.size())).toString()).complete();
            else
                channel.sendMessage("No quotes from " + commandNParameters[1] + "!").complete();
        } else {
            channel.sendMessage("```" + prefix + usage + "```").complete();
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:35,代碼來源:QuotePerson.java

示例9: doYaThing

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
    User author = message.getAuthor();
    MessageChannel channel = message.getChannel();

    BankAccount temp = new BankAccount("temp");
    boolean exists = false;
    for (BankAccount b : bankAccounts) {
        if (b.getID().equals(author.getId())) {
            exists = true;
            temp = b;
        }
    }
    try {
        if (exists && temp.lastPay.before(new Date(System.currentTimeMillis() - TimeUnit.HOURS.toMillis(23)))) {
            temp.setBalance(temp.getBalance() + 100.00);
            temp.lastPay = new Date();
            channel.sendMessage("You got 100.00 Dodos.\nNew balance: " + Double.toString(temp.getBalance())).complete();
            FileHandler.writeToFile(bankAccounts);
        } else {
            channel.sendMessage("You have already got your pay!").complete();
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:28,代碼來源:Payday.java

示例10: doYaThing

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
    User author = message.getAuthor();
    String content = message.getRawContent();
    MessageChannel channel = message.getChannel();
    String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
    BankAccount temp = new BankAccount("temp");
    boolean exists = false;
    for (BankAccount b : bankAccounts) {
        if (b.getID().equals(author.getId())) {
            exists = true;
            temp = b;
        }
    }
    try {
        if (commandNParameters.length < 2)
            channel.sendMessage("```" + prefix + usage + "```").complete();
        else if (exists && temp.getBalance() >= Double.parseDouble(commandNParameters[1])) {
            if (Double.parseDouble(commandNParameters[1]) > -1)
                SlotMashina.slotMashinas(Double.parseDouble(commandNParameters[1]), channel, temp);
            else
                channel.sendMessage("Can't slot that!").complete();
        } else {
            if (!exists) {
                channel.sendMessage("You have to register! Use `" + prefix + "bank register`").complete();
            } else channel.sendMessage("You are too poor!").complete();
        }

    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:34,代碼來源:Slot.java

示例11: doYaThing

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
    MessageChannel channel = message.getChannel();
    User author = message.getAuthor();
    try {
        BufferedImage avatar;
        List<User> users = message.getMentionedUsers();
        if (users.isEmpty()) avatar = ReadImage.readImageFromURL(author.getAvatarUrl());
        else avatar = ReadImage.readImageFromURL(users.get(0).getAvatarUrl());
        for (int i = 0; i < gif.length; i++) {
            gif[i] = ReadImage.readImageFromDisk("gif/"+String.valueOf(i)+".png");
        }

        GifImage img = new GifImage(gif[0].getWidth(),gif[0].getHeight(),GifImage.RESIZE_STRATEGY_SCALE_TO_FIT_IMAGE_SIZE);

        for (int i = 0; i < gif.length; i++) {
            if (i>21) DrawOnImg.drawImg(gif[i],avatar,30-(10*(i-20)),42+(11*(i-20)),110,98);
            else DrawOnImg.drawImg(gif[i],avatar,30,42,110,98);
            img.addGifFrame(new GifFrame(gif[i]));
        }
        img.setDefaultDelay(1);
        GifEncoder.encode(img, new File("hudio.gif"), true);
        Path fileLocation = Paths.get("hudio.gif");
        byte[] data = Files.readAllBytes(fileLocation);

        channel.sendFile(data, "shoot.gif", null).complete();

    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:33,代碼來源:Shoot.java

示例12: doYaThing

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
    MessageChannel channel = message.getChannel();
    try {
        String helpVoice = "join [name]  - Joins a voice channel that has the provided name\njoin [id]    - Joins a voice channel based on the provided id.\nleave        - Leaves the voice channel that the bot is currently in.\nplay         - Plays songs from the current queue. Starts playing again if it was previously paused\nplay [url]   - Adds a new song to the queue and starts playing if it wasn't playing already\npplay        - Adds a playlist to the queue and starts playing if not already playing\npause        - Pauses audio playback\nstop         - Completely stops audio playback, skipping the current song.\nskip         - Skips the current song, automatically starting the next\nnowplaying   - Prints information about the currently playing song (title, current time)\nnp           - alias for nowplaying\nlist         - Lists the songs in the queue\nvolume [val] - Sets the volume of the MusicPlayer [10 - 100]\nrestart      - Restarts the current song or restarts the previous song if there is no current song playing.\nrepeat       - Makes the player repeat the currently playing song\nreset        - Completely resets the player, fixing all errors and clearing the queue.\n";
        channel.sendMessage("```Voice Commands:  \n" + helpVoice + "```").complete();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:12,代碼來源:HelpMusic.java

示例13: doYaThing

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
    String content = message.getRawContent();
    MessageChannel channel = message.getChannel();
    String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
    try {
        if (commandNParameters.length > 1)
            channel.sendMessage("http://lmgtfy.com/?q=" + URLEncoder.encode(DodoStringHandler.glueStringsBackTogether(commandNParameters, " ", 1), "UTF-8")).complete();
        else
            channel.sendMessage(getUsage()).complete();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:16,代碼來源:LMGTFY.java

示例14: doYaThing

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
    MessageChannel channel = message.getChannel();
    try {
        channel.sendMessage(HTTPHandler.getCat()).complete();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:11,代碼來源:Cat.java

示例15: doYaThing

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void doYaThing(Message message) {
    User author = message.getAuthor();
    MessageChannel channel = message.getChannel();
    try {
        channel.sendMessage("Hello " + author.getAsMention()).complete();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
 
開發者ID:ExidCuter,項目名稱:JDodoBot,代碼行數:12,代碼來源:Hi.java


注:本文中的net.dv8tion.jda.core.entities.Message.getChannel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。