Search in sources :

Example 1 with TextChannel

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);
            }
        }
    });
}
Also used : TextChannel(discord4j.core.object.entity.TextChannel) Message(discord4j.core.object.entity.Message) MessageChannel(discord4j.core.object.entity.MessageChannel)

Example 2 with TextChannel

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;
}
Also used : Reload(io.github.spugn.Sargo.Functions.Reload) MessageCreateEvent(discord4j.core.event.domain.message.MessageCreateEvent) Logger(org.slf4j.Logger) CommandSettingsParser(io.github.spugn.Sargo.XMLParsers.CommandSettingsParser) ReadyEvent(discord4j.core.event.domain.lifecycle.ReadyEvent) Update(io.github.spugn.Sargo.Functions.Update) DiscordClientBuilder(discord4j.core.DiscordClientBuilder) LoggerFactory(org.slf4j.LoggerFactory) DiscordClient(discord4j.core.DiscordClient) java.awt(java.awt) Consumer(java.util.function.Consumer) MessageListener(io.github.spugn.Sargo.Listeners.MessageListener) java.io(java.io) Message(discord4j.core.object.entity.Message) ScoutMasterParser(io.github.spugn.Sargo.XMLParsers.ScoutMasterParser) Activity(discord4j.core.object.presence.Activity) EmbedCreateSpec(discord4j.core.spec.EmbedCreateSpec) SystemData(io.github.spugn.Sargo.System.SystemData) LoginSettingsParser(io.github.spugn.Sargo.XMLParsers.LoginSettingsParser) GitHubImage(io.github.spugn.Sargo.Utilities.GitHubImage) TextChannel(discord4j.core.object.entity.TextChannel) Presence(discord4j.core.object.presence.Presence) Message(discord4j.core.object.entity.Message)

Aggregations

Message (discord4j.core.object.entity.Message)2 TextChannel (discord4j.core.object.entity.TextChannel)2 DiscordClient (discord4j.core.DiscordClient)1 DiscordClientBuilder (discord4j.core.DiscordClientBuilder)1 ReadyEvent (discord4j.core.event.domain.lifecycle.ReadyEvent)1 MessageCreateEvent (discord4j.core.event.domain.message.MessageCreateEvent)1 MessageChannel (discord4j.core.object.entity.MessageChannel)1 Activity (discord4j.core.object.presence.Activity)1 Presence (discord4j.core.object.presence.Presence)1 EmbedCreateSpec (discord4j.core.spec.EmbedCreateSpec)1 Reload (io.github.spugn.Sargo.Functions.Reload)1 Update (io.github.spugn.Sargo.Functions.Update)1 MessageListener (io.github.spugn.Sargo.Listeners.MessageListener)1 SystemData (io.github.spugn.Sargo.System.SystemData)1 GitHubImage (io.github.spugn.Sargo.Utilities.GitHubImage)1 CommandSettingsParser (io.github.spugn.Sargo.XMLParsers.CommandSettingsParser)1 LoginSettingsParser (io.github.spugn.Sargo.XMLParsers.LoginSettingsParser)1 ScoutMasterParser (io.github.spugn.Sargo.XMLParsers.ScoutMasterParser)1 java.awt (java.awt)1 java.io (java.io)1