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);
}
}
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());
}
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);
}
}
}
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());
}
}
}
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);
}
Aggregations