All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.alex1304.ultimategdbot.api.command.annotated.paramconverter.RoleConverter Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
package com.github.alex1304.ultimategdbot.api.command.annotated.paramconverter;

import com.github.alex1304.ultimategdbot.api.command.Context;
import com.github.alex1304.ultimategdbot.api.utils.DiscordParser;

import discord4j.core.object.entity.Role;
import reactor.core.publisher.Mono;

public class RoleConverter implements ParamConverter {

	@Override
	public Mono convert(Context ctx, String input) {
		return Mono.justOrEmpty(ctx.getEvent().getGuildId())
				.flatMap(guildId -> DiscordParser.parseRole(ctx.getBot(), guildId, input))
				.switchIfEmpty(Mono.error(new RuntimeException("Cannot find roles outside of a guild.")));
	}

	@Override
	public Class type() {
		return Role.class;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy