use of sx.blah.discord.handle.obj.IMessage in project DiscordSailv2 by Vaerys-Dawn.
the class TimerHandler method sendReminder.
// Reminder new setup.
public static void sendReminder(ReminderObject object) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
long initialDelay = object.getExecuteTime() - now.toEpochSecond();
// System.out.println(initialDelay + "");
if (initialDelay < 0) {
initialDelay = 5;
}
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
IMessage message = RequestHandler.sendMessage(object.getMessage(), Globals.getClient().getChannelByID(object.getChannelID())).get();
if (message == null) {
logger.error("REMINDER FAILED FOR USER WITH ID \"" + object.getUserID() + "\" TO SEND. WILL ATTEMPT TO SEND AGAIN IN 5 MINS.");
object.setSent(false);
} else {
Globals.getGlobalData().removeReminder(object);
}
}
}, initialDelay * 1000);
}
use of sx.blah.discord.handle.obj.IMessage in project Discord4J by Discord4J.
the class MessageHistory method delete.
/**
* Deletes the message with the given ID. The deleted message is NOT removed from the collection.
*
* @param id The ID of the message to delete.
* @return The deleted message (or null if no message was found).
*/
public IMessage delete(long id) {
IMessage message = get(id);
if (message == null)
return null;
message.delete();
return message;
}
use of sx.blah.discord.handle.obj.IMessage in project Discord4J by Discord4J.
the class MessageHistory method delete.
/**
* Deletes the message at the specified index. The deleted message is NOT removed from the collection.
*
* @param index The index of the message to delete.
* @return The deleted message.
*/
public IMessage delete(int index) {
IMessage message = get(index);
message.delete();
return message;
}
use of sx.blah.discord.handle.obj.IMessage in project Shadbot by Shadorc.
the class MessageListener method onMessageReceivedEvent.
private void onMessageReceivedEvent(MessageReceivedEvent event) {
VariousStatsManager.log(VariousEnum.MESSAGES_RECEIVED);
IMessage message = event.getMessage();
try {
if (message.getAuthor().isBot()) {
return;
}
if (message.getChannel().isPrivate()) {
this.privateMessageReceived(message);
return;
}
ShardManager.getShadbotShard(message.getShard()).messageReceived();
if (!BotUtils.isChannelAllowed(message.getGuild(), message.getChannel())) {
return;
}
if (MessageManager.intercept(message)) {
return;
}
String prefix = Database.getDBGuild(message.getGuild()).getPrefix();
if (message.getContent().startsWith(prefix)) {
CommandManager.execute(new Context(prefix, message));
}
} catch (MissingPermissionsException err) {
BotUtils.sendMessage(TextUtils.missingPerm(err.getMissingPermissions()), message.getChannel());
LogUtils.infof("{Guild ID: %d} %s", message.getGuild().getLongID(), err.getMessage());
} catch (Exception err) {
BotUtils.sendMessage(Emoji.RED_FLAG + " Sorry, an unknown error occurred. My developer has been warned.", message.getChannel());
LogUtils.error(message.getContent(), err, String.format("{Guild ID: %d} An unknown error occurred while receiving a message.", message.getGuild().getLongID()));
}
}
use of sx.blah.discord.handle.obj.IMessage in project Shadbot by Shadorc.
the class DiceManager method show.
private void show() {
EmbedBuilder embed = EmbedUtils.getDefaultEmbed().setLenient(true).withAuthorName("Dice Game").withThumbnail("http://findicons.com/files/icons/2118/nuvola/128/package_games_board.png").withDescription(String.format("**Use `%s%s <num>` to join the game.**%n**Bet:** %s", this.getPrefix(), this.getCmdName(), FormatUtils.formatCoins(bet))).appendField("Player", numsPlayers.values().stream().map(IUser::getName).collect(Collectors.joining("\n")), true).appendField("Number", numsPlayers.keySet().stream().map(Object::toString).collect(Collectors.joining("\n")), true).appendField("Results", results, false).withFooterText(String.format("You have %d seconds to make your bets.", GAME_DURATION));
RequestFuture<IMessage> msgRequest = message.send(embed.build());
if (msgRequest != null) {
msgRequest.get();
}
}
Aggregations