Search in sources :

Example 31 with IMessage

use of sx.blah.discord.handle.obj.IMessage in project DisCal-Discord-Bot by NovaFox161.

the class EventCommand method moduleCancel.

private void moduleCancel(MessageReceivedEvent event, GuildSettings settings) {
    long guildId = event.getGuild().getLongID();
    IMessage msg = null;
    if (EventCreator.getCreator().hasCreatorMessage(guildId))
        msg = EventCreator.getCreator().getCreatorMessage(guildId);
    if (EventCreator.getCreator().terminate(event)) {
        if (msg != null) {
            Message.deleteMessage(event);
            Message.deleteMessage(msg);
            Message.sendMessage(MessageManager.getMessage("Creator.Event.Cancel.Success", settings), event);
        } else {
            Message.sendMessage(MessageManager.getMessage("Creator.Event.Cancel.Success", settings), event);
        }
    } else {
        Message.sendMessage(MessageManager.getMessage("Creator.Event.NotInit", settings), event);
    }
}
Also used : IMessage(sx.blah.discord.handle.obj.IMessage)

Example 32 with IMessage

use of sx.blah.discord.handle.obj.IMessage in project DisCal-Discord-Bot by NovaFox161.

the class EventCreator method init.

// Functionals
/**
 * Initiates the EventCreator for a specific guild.
 *
 * @param e The event received upon initialization.
 * @return The PreEvent for the guild.
 */
public PreEvent init(MessageReceivedEvent e, GuildSettings settings, boolean handleMessage) {
    if (!hasPreEvent(e.getGuild().getLongID())) {
        PreEvent event = new PreEvent(e.getGuild().getLongID());
        try {
            // TODO: Handle multiple calendars...
            String calId = DatabaseManager.getManager().getMainCalendar(e.getGuild().getLongID()).getCalendarAddress();
            event.setTimeZone(CalendarAuth.getCalendarService().calendars().get(calId).execute().getTimeZone());
        } catch (IOException exc) {
        // Failed to get timezone, ignore safely.
        }
        if (handleMessage) {
            if (PermissionChecker.botHasMessageManagePerms(e)) {
                IMessage message = Message.sendMessage(EventMessageFormatter.getPreEventEmbed(event, settings), MessageManager.getMessage("Creator.Event.Create.Init", settings), e);
                event.setCreatorMessage(message);
                Message.deleteMessage(e);
            } else {
                Message.sendMessage(MessageManager.getMessage("Creator.Notif.MANAGE_MESSAGES", settings), e);
            }
        }
        events.add(event);
        return event;
    }
    return getPreEvent(e.getGuild().getLongID());
}
Also used : PreEvent(com.cloudcraftgaming.discal.api.object.event.PreEvent) IMessage(sx.blah.discord.handle.obj.IMessage) IOException(java.io.IOException)

Example 33 with IMessage

use of sx.blah.discord.handle.obj.IMessage in project de-DiscordBot by DACH-Discord.

the class DiscordBot method onMessageEdited.

/**
 * Wird bei jeder geänderten Nachricht aufgerufen, bearbeitete Nachrichten die jünger als 20 Sekunden sind
 * werden auch als Befehl interpretiert
 *
 * @param event Das Event der geänderten Nachricht
 */
@EventSubscriber
public void onMessageEdited(final MessageUpdateEvent event) {
    final IMessage message = event.getNewMessage();
    if (message.getEditedTimestamp().isPresent()) {
        final LocalDateTime messageTimestamp = message.getTimestamp();
        final LocalDateTime editTimestamp = message.getEditedTimestamp().get();
        final long seconds = messageTimestamp.until(editTimestamp, ChronoUnit.SECONDS);
        if (seconds < 20) {
            handleMessage(message);
        }
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) IMessage(sx.blah.discord.handle.obj.IMessage) EventSubscriber(sx.blah.discord.api.events.EventSubscriber)

Example 34 with IMessage

use of sx.blah.discord.handle.obj.IMessage in project lavaplayer by sedmelluq.

the class Main method onMessageReceived.

@EventSubscriber
public void onMessageReceived(MessageReceivedEvent event) {
    IMessage message = event.getMessage();
    String[] command = message.getContent().split(" ", 2);
    IGuild guild = message.getGuild();
    if (guild != null) {
        if ("~play".equals(command[0]) && command.length == 2) {
            loadAndPlay(message.getChannel(), command[1]);
        } else if ("~skip".equals(command[0])) {
            skipTrack(message.getChannel());
        }
    }
}
Also used : IMessage(sx.blah.discord.handle.obj.IMessage) IGuild(sx.blah.discord.handle.obj.IGuild) EventSubscriber(sx.blah.discord.api.events.EventSubscriber)

Example 35 with IMessage

use of sx.blah.discord.handle.obj.IMessage in project DiscordSailv2 by Vaerys-Dawn.

the class AnnotationListener method onSystemMessageReceivedEvent.

@EventSubscriber
public void onSystemMessageReceivedEvent(MessageSendEvent event) {
    IMessage message = event.getMessage();
    if (message.getType() != IMessage.Type.CHANEL_PINNED_MESSAGE)
        return;
    if (!message.getAuthor().equals(event.getClient().getOurUser()))
        return;
    RequestHandler.deleteMessage(message);
}
Also used : IMessage(sx.blah.discord.handle.obj.IMessage) EventSubscriber(sx.blah.discord.api.events.EventSubscriber)

Aggregations

IMessage (sx.blah.discord.handle.obj.IMessage)46 IUser (sx.blah.discord.handle.obj.IUser)10 EmbedBuilder (sx.blah.discord.util.EmbedBuilder)9 EventSubscriber (sx.blah.discord.api.events.EventSubscriber)6 IChannel (sx.blah.discord.handle.obj.IChannel)6 ProfileObject (com.github.vaerys.objects.ProfileObject)5 UserObject (com.github.vaerys.masterobjects.UserObject)4 ArrayList (java.util.ArrayList)4 DiscordException (sx.blah.discord.util.DiscordException)4 Announcement (com.cloudcraftgaming.discal.api.object.announcement.Announcement)3 PreEvent (com.cloudcraftgaming.discal.api.object.event.PreEvent)3 CommandObject (com.github.vaerys.commands.CommandObject)3 SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)3 GitHubImage (io.github.spugn.Sargo.Utilities.GitHubImage)3 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 RateLimitException (sx.blah.discord.util.RateLimitException)3 PreCalendar (com.cloudcraftgaming.discal.api.object.calendar.PreCalendar)2 TrackLikes (com.github.vaerys.objects.TrackLikes)2