/** * Reward the player a random amount of experience between 10 and 15 using the * {@link MessageReceivedEvent}, the reward is throttled to one use every * minute per-guild-player, if the player has received experience in the * same guild through this method before in the last minute, nothing * will be given to the player/user. * * @param event The event that should be used in rewarding the player. * @param guild The guild transformer from the current guild database instance. * @param player The player transformer from the current player database instance. */ public void rewardPlayer(@Nonnull MessageReceivedEvent event, @Nonnull GuildTransformer guild, @Nonnull PlayerTransformer player) { if (guild.getLevelExemptChannels().contains(event.getChannel().getIdLong())) { return; } CacheUtil.getUncheckedUnwrapped(cache, asKey(event), () -> { giveExperience(event.getMessage(), event.getMessage().getAuthor(), guild, player); return 0; }); }
@Override public boolean onCommand(CommandMessage context, String[] args) { if (!hasApiKey()) { return false; } if (args.length == 0) { return sendErrorMessage(context, "errors.missingArgument", "city"); } DrainWeatherQueueTask.queueWeather(new DrainWeatherQueueTask.WeatherEntity( context.getAuthor().getIdLong(), context.getMessageChannel().getIdLong(), String.join(" ", args) )); context.getMessageChannel().sendTyping().queue(); return true; }
return Templates.command.subscribe.invalid_service.formatGuild(channel); OSubscription subscription = CSubscriptions.findBy(CGuild.getCachedId(txt.getGuild().getIdLong()), CChannels.getCachedId(channel.getIdLong(), txt.getGuild().getIdLong()), service.id); if (subscription.subscribed == 1) { subscription.subscribed = 0; return Templates.command.subscribe.invalid_service.formatGuild(channel); OSubscription subscription = CSubscriptions.findBy(CGuild.getCachedId(txt.getGuild().getIdLong()), CChannels.getCachedId(channel.getIdLong(), ((TextChannel) channel).getGuild().getIdLong()), service.id); if (subscription.subscribed == 0) { subscription.subscribed = 1; subscription.channelId = CChannels.getCachedId(channel.getIdLong(), txt.getGuild().getIdLong()); subscription.serverId = CGuild.getCachedId(txt.getGuild().getIdLong()); subscription.serviceId = service.id;
commandUsed = command.getCommand(); long cooldown = getCommandCooldown(command, author, channel); if (command.canBeDisabled() && isDisabled(guildId, channel.getIdLong(), command.getCommand())) { commandSuccess = false; if (GuildSettings.getBoolFor(channel, GSetting.SHOW_UNKNOWN_COMMANDS)) {
Collection collection = avaire.getDatabase().newQueryBuilder(Constants.FEEDBACK_TABLE_NAME).insert(statement -> { statement.set("user_id", context.getAuthor().getIdLong()); statement.set("channel_id", context.isGuildMessage() ? context.getMessageChannel().getIdLong() : null); statement.set("message", String.join(" ", args), true); });
if (message.getChannel().getIdLong() == textChannelById.getIdLong()) { return stack.next();
private boolean checkUser(CommandMessage context, VoteCacheEntity voteEntity) { Carbon expire = avaire.getVoteManager().getExpireTime(context.getAuthor()); if (expire != null && expire.isFuture()) { context.makeInfo("You have already voted today, thanks for that btw!\nYou can vote again in :time.") .setFooter("You have " + (voteEntity == null ? 0 : voteEntity.getVotePoints()) + " vote points") .set("time", expire.diffForHumans()) .queue(); return true; } boolean wasAdded = avaire.getVoteManager().queueEntity(new VoteEntity( context.getAuthor().getIdLong(), context.getMessageChannel().getIdLong() )); if (!wasAdded) { return false; } context.makeInfo( ":user, You've been put on a queue to get your vote rewards. Make sure you've voted or nothing will happen!" ).queue(); return true; } }
deleteMessageAfterTrack(message.getChannel().getIdLong(), message.getIdLong());