use of discord4j.core.object.entity.TextChannel in project lavaplayer by sedmelluq.
the class Main method onMessageReceived.
private void onMessageReceived(MessageCreateEvent event) {
Message message = event.getMessage();
message.getContent().ifPresent(it -> {
MessageChannel channel = message.getChannel().block();
if (channel instanceof TextChannel) {
String[] command = it.split(" ", 2);
if ("~play".equals(command[0]) && command.length == 2) {
loadAndPlay((TextChannel) channel, command[1]);
} else if ("~skip".equals(command[0])) {
skipTrack((TextChannel) channel);
}
}
});
}
use of discord4j.core.object.entity.TextChannel in project S-argo by Expugn.
the class Sargo method sendEmbed.
public static Message sendEmbed(TextChannel tc, Consumer<EmbedCreateSpec> ecsTemplate, File image) {
try {
InputStream is = new FileInputStream(image);
Message sentMessage = tc.createMessage(s -> s.setEmbed(ecsTemplate.andThen(es -> es.setImage("attachment://" + image.getName()))).addFile(image.getName(), is)).block();
is.close();
return sentMessage;
} catch (FileNotFoundException e) {
return tc.createMessage(ms -> ms.setEmbed(ecsTemplate.andThen(es -> es.addField("MISSING SCOUT RESULT", "Scout result image is missing.", true)))).block();
} catch (IOException e) {
// IGNORED
}
return null;
}
Aggregations