use of sx.blah.discord.handle.obj.IMessage in project DisCal-Discord-Bot by NovaFox161.
the class EventCreator method init.
public PreEvent init(MessageReceivedEvent e, GuildSettings settings, String summary, boolean handleMessage) {
if (!hasPreEvent(e.getGuild().getLongID())) {
PreEvent event = new PreEvent(e.getGuild().getLongID());
event.setSummary(summary);
try {
// TODO: Handle multiple calendars...
String calId = DatabaseManager.getManager().getMainCalendar(e.getGuild().getLongID()).getCalendarAddress();
if (!settings.useExternalCalendar()) {
event.setTimeZone(CalendarAuth.getCalendarService().calendars().get(calId).execute().getTimeZone());
} else {
event.setTimeZone(CalendarAuth.getCalendarService(settings).calendars().get(calId).execute().getTimeZone());
}
} catch (Exception 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 RedditLinker method onMessageReceived.
@EventSubscriber
public void onMessageReceived(final MessageReceivedEvent event) {
final IMessage message = event.getMessage();
final String messageContent = message.getContent();
Pattern pattern = Pattern.compile("^/?r/(\\w+)$");
Matcher matcher = pattern.matcher(messageContent);
if (matcher.matches()) {
Util.sendMessage(message.getChannel(), "https://www.reddit.com/r/" + matcher.group(1));
}
}
use of sx.blah.discord.handle.obj.IMessage in project BoltBot by DiscordBolt.
the class NowPlayingCommand method nowPlayingCommand.
@BotCommand(command = "nowplaying", aliases = { "np", "current", "playing" }, module = MusicModule.MODULE, description = "View what is currently playing", usage = "NowPlaying", allowedChannels = "music")
public static void nowPlayingCommand(CommandContext cc) throws CommandException {
AudioTrack at = MusicModule.getVoiceManager().getNowPlaying(cc.getGuild());
if (at == null)
throw new CommandStateException("Nothing is currently playing. Play something with !Play");
IMessage nowPlayingMessage = cc.replyWith(MusicModule.createPlayingEmbed(cc.getGuild(), MusicModule.getVoiceManager().getNowPlaying(cc.getGuild())));
ChannelUtil.addReaction(nowPlayingMessage, new Emoji[] { EmojiManager.getForAlias(":black_right_pointing_double_triangle_with_vertical_bar:"), EmojiManager.getForAlias(":star:") });
MusicModule.getVoiceManager().putNowPlayingMessage(nowPlayingMessage, MusicModule.getVoiceManager().getNowPlaying(cc.getGuild()));
}
use of sx.blah.discord.handle.obj.IMessage in project Discord4J by Discord4J.
the class ParrotBot method handle.
/**
* Called when the client receives a message.
*/
@Override
public void handle(MessageReceivedEvent event) {
// Gets the message from the event object NOTE: This is not the content of the message, but the object itself
IMessage message = event.getMessage();
// Gets the channel in which this message was sent.
IChannel channel = message.getChannel();
try {
// Builds (sends) and new message in the channel that the original message was sent with the content of the original message.
new MessageBuilder(this.client).withChannel(channel).withContent(message.getContent()).build();
} catch (RateLimitException e) {
// RateLimitException thrown. The bot is sending messages too quickly!
System.err.print("Sending messages too quickly!");
e.printStackTrace();
} catch (DiscordException e) {
// DiscordException thrown. Many possibilities. Use getErrorMessage() to see what went wrong.
// Print the error message sent by Discord
System.err.print(e.getErrorMessage());
e.printStackTrace();
} catch (MissingPermissionsException e) {
// MissingPermissionsException thrown. The bot doesn't have permission to send the message!
System.err.print("Missing permissions for channel!");
e.printStackTrace();
}
}
use of sx.blah.discord.handle.obj.IMessage in project DiscordSailv2 by Vaerys-Dawn.
the class AnnotationListener method onReactionAddEvent.
@EventSubscriber
public void onReactionAddEvent(ReactionAddEvent event) {
if (event.getUser().isBot()) {
return;
}
ReactionEmoji x = Utility.getReaction("x");
ReactionEmoji pin = Utility.getReaction(Constants.EMOJI_ADD_PIN);
ReactionEmoji thumbsUp = Utility.getReaction(Constants.EMOJI_APPROVE);
ReactionEmoji thumbsDown = Utility.getReaction(Constants.EMOJI_DISAPPROVE);
ReactionEmoji heart = Utility.getReaction(Constants.EMOJI_LIKE_PIN);
ReactionEmoji remove = Utility.getReaction(Constants.EMOJI_REMOVE_PIN);
ReactionEmoji emoji = event.getReaction().getEmoji();
if (emoji == null)
return;
IMessage message = event.getMessage();
if (message == null)
message = event.getChannel().getMessageByID(event.getMessageID());
CommandObject object = new CommandObject(message);
UserObject pinner = new UserObject(event.getUser(), object.guild);
UserObject owner = new UserObject(event.getAuthor(), object.guild);
// do only on server channels
if (!event.getChannel().isPrivate() && emoji.isUnicode()) {
// if is x and can bypass
if (emoji.equals(remove))
ArtHandler.unPin(object);
if (emoji.equals(x) && GuildHandler.testForPerms(object, Permissions.MANAGE_MESSAGES) && object.client.bot.longID == object.user.longID)
RequestHandler.deleteMessage(object.message);
// if is pushpin
if (emoji.equals(pin))
ArtHandler.pinMessage(object, pinner, owner);
// if is thumbsup or thumbs down and is creator.
if (emoji.equals(thumbsUp) || emoji.equals(thumbsDown))
QueueHandler.reactionAdded(object, event.getReaction());
// if is hear and is pinned then give xp
if (emoji.equals(heart))
ArtHandler.pinLiked(object, pinner, owner);
// do only within Direct messages
} else if (event.getChannel().isPrivate() && emoji.isUnicode()) {
// if anyone uses x
if (emoji.equals(x) && object.client.bot.longID == object.user.longID) {
RequestHandler.deleteMessage(message);
}
}
}
Aggregations