use of discord4j.core.object.entity.Guild in project lavaplayer by sedmelluq.
the class Main method attachToFirstVoiceChannel.
private static void attachToFirstVoiceChannel(Guild guild, D4jAudioProvider provider) {
VoiceChannel voiceChannel = guild.getChannels().ofType(VoiceChannel.class).blockFirst();
boolean inVoiceChannel = // Check if any VoiceState for this guild relates to bot
guild.getVoiceStates().any(voiceState -> guild.getClient().getSelfId().map(voiceState.getUserId()::equals).orElse(false)).block();
if (!inVoiceChannel) {
voiceChannel.join(spec -> spec.setProvider(provider)).block();
}
}
use of discord4j.core.object.entity.Guild in project KaellyBot by Kaysoro.
the class RSSCommand method request.
@Override
public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
// On check si la personne a bien les droits pour exécuter cette commande
if (isUserHasEnoughRights(message)) {
String value = m.group(1);
String guildId = message.getGuild().blockOptional().map(Guild::getId).map(Snowflake::asString).orElse("");
String channelId = message.getChannel().blockOptional().map(MessageChannel::getId).map(Snowflake::asString).orElse("");
if (value.matches("\\s+true") || value.matches("\\s+0") || value.matches("\\s+on")) {
if (!RSSFinder.getRSSFinders().containsKey(channelId)) {
new RSSFinder(guildId, channelId).addToDatabase();
message.getChannel().flatMap(chan -> chan.createMessage(Translator.getLabel(lg, "rss.request.1").replace("{game.url}", Translator.getLabel(lg, "game.url")))).subscribe();
} else
rssFound.throwException(message, this, lg);
} else if (value.matches("\\s+false") || value.matches("\\s+1") || value.matches("\\s+off"))
if (RSSFinder.getRSSFinders().containsKey(channelId)) {
RSSFinder.getRSSFinders().get(channelId).removeToDatabase();
message.getChannel().flatMap(chan -> chan.createMessage(Translator.getLabel(lg, "rss.request.2").replace("{game.url}", Translator.getLabel(lg, "game.url")))).subscribe();
} else
rssNotFound.throwException(message, this, lg);
else
badUse.throwException(message, this, lg);
} else
BasicDiscordException.NO_ENOUGH_RIGHTS.throwException(message, this, lg);
}
use of discord4j.core.object.entity.Guild in project KaellyBot by Kaysoro.
the class TwitterCommand method request.
@Override
public void request(MessageCreateEvent event, Message message, Matcher m, Language lg) {
// On check si la personne a bien les droits pour exécuter cette commande
if (isUserHasEnoughRights(message)) {
String value = m.group(1);
Long guildId = message.getGuild().blockOptional().map(Guild::getId).map(Snowflake::asLong).orElse(0L);
Long channelId = message.getChannel().blockOptional().map(MessageChannel::getId).map(Snowflake::asLong).orElse(0L);
if (value.matches("\\s+true") || value.matches("\\s+0") || value.matches("\\s+on")) {
if (!TwitterFinder.getTwitterChannels().containsKey(channelId)) {
new TwitterFinder(guildId, channelId).addToDatabase();
message.getChannel().flatMap(chan -> chan.createMessage(Translator.getLabel(lg, "twitter.request.1").replace("{twitter.name}", Translator.getLabel(lg, "twitter.name")))).subscribe();
} else
twitterFound.throwException(message, this, lg);
} else if (value.matches("\\s+false") || value.matches("\\s+1") || value.matches("\\s+off")) {
if (TwitterFinder.getTwitterChannels().containsKey(channelId)) {
TwitterFinder.getTwitterChannels().get(channelId).removeToDatabase();
message.getChannel().flatMap(chan -> chan.createMessage(Translator.getLabel(lg, "twitter.request.2").replace("{twitter.name}", Translator.getLabel(lg, "twitter.name")))).subscribe();
} else
twitterNotFound.throwException(message, this, lg);
} else
badUse.throwException(message, this, lg);
} else
BasicDiscordException.NO_ENOUGH_RIGHTS.throwException(message, this, lg);
}
Aggregations