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

com.github.alex1304.ultimategdbot.api.command.annotated.paramconverter.GuildChannelConverter 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.GuildChannel;
import reactor.core.publisher.Mono;

public class GuildChannelConverter implements ParamConverter {

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy