default MessageAction sendFile(InputStream data, String fileName) return sendFile(data, fileName, null);
default MessageAction sendFile(byte[] data, String fileName) return sendFile(data, fileName, null);
default MessageAction sendFile(File file) return sendFile(file, (Message) null);
default MessageAction sendFile(File file, String fileName) return sendFile(file, fileName, null);
return sendFile(file, file.getName(), message);
return sendFile(new FileInputStream(file), fileName, message);
final long maxSize = getJDA().getSelfUser().getAllowedFileSize(); Checks.check(data.length <= maxSize, "File is too big! Max file-size is %d bytes", maxSize); return sendFile(new ByteArrayInputStream(data), fileName, message);
@Override public String execute(DiscordBot bot, String[] args, MessageChannel channel, User author, Message inputMessage) { SimpleRank rank = bot.security.getSimpleRank(author); if (!rank.isAtLeast(SimpleRank.SYSTEM_ADMIN)) { return Templates.no_permission.formatGuild(channel); } if (args.length == 0) { return Templates.invalid_use.formatGuild(channel); } File f = new File(Joiner.on("").join(args)); if (f.exists()) { try { bot.queue.add(channel.sendFile(f)); } catch (Exception e) { e.printStackTrace(); return "can't for some reason; " + e.getMessage(); } return ""; } return "File doesn't exist"; } }
File outputfile = new File("tmp_" + channel.getId() + ".jpg"); ImageIO.write(ImageIO.read(in), "jpg", outputfile); bot.queue.add(channel.sendFile(outputfile, new MessageBuilder().append(post.data.title).build()), message -> outputfile.delete()); return ""; } catch (IOException e) {
bot.queue.add(channel.sendFile(memeFile), message -> memeFile.delete()); return "";
bot.queue.add(channel.sendFile(f), message -> f.delete()); } catch (IOException e) { e.printStackTrace();
File f = new File("./Sample_Chart.png"); BitmapEncoder.saveBitmap(chart, f.getAbsolutePath(), BitmapEncoder.BitmapFormat.PNG); bot.queue.add(channel.sendFile(f), message -> f.delete()); } catch (IOException e) { e.printStackTrace();
file = version2.getProfileImage(); bot.queue.add(channel.sendFile(file), (message) -> file.delete()); } catch (Exception e) { System.out.println(e.getMessage());
@Override public boolean onCommand(CommandMessage context, String[] args) { if (args.length == 0) { return sendErrorMessage(context, context.i18n("noArgumentsGiven")); } if (args.length < 3 && args[0].equalsIgnoreCase("list")) { return sendCharacterList(context, args); } if (args.length == 1) { return sendErrorMessage(context, "errors.missingArgument", "message"); } try { MessageBuilder messageBuilder = new MessageBuilder(); EmbedBuilder embedBuilder = context.makeEmbeddedMessage() .setImage("attachment://" + getClass().getSimpleName() + "-" + args[0] + ".png") .requestedBy(context) .build(); messageBuilder.setEmbed(embedBuilder.build()); InputStream stream = getImageInputStream(args); context.getMessageChannel().sendFile(stream, getClass().getSimpleName() + "-" + args[0] + ".png", messageBuilder.build()).queue(); return true; } catch (IOException e) { return sendErrorMessage(context, context.i18n("failedToGenerateImage")); } }
context.getMessageChannel().sendFile( new ByteArrayInputStream(render.renderToBytes()), "rank-background.png", message.build()
context.getMessageChannel().sendFile( new ByteArrayInputStream(render.renderToBytes()), attachmentName, message.build()