use of net.dv8tion.jda.api.entities.GuildMessageChannel in project Bean by Xirado.
the class PlayerCommand method executeCommand.
@Override
public void executeCommand(@NotNull SlashCommandInteractionEvent event, @NotNull SlashCommandContext ctx) {
GuildAudioPlayer player = Bean.getInstance().getAudioManager().getAudioPlayer(event.getGuild().getIdLong());
AudioTrack track = player.getPlayer().getPlayingTrack();
boolean isRepeat = player.getScheduler().isRepeat();
boolean isPaused = player.getPlayer().isPaused();
event.reply("One moment...").queue(x -> player.playerSetup((GuildMessageChannel) event.getChannel(), (success) -> event.getHook().deleteOriginal().queue(), (error) -> event.reply("An error occurred!").setEphemeral(true).queue()));
}
use of net.dv8tion.jda.api.entities.GuildMessageChannel in project JDA by DV8FromTheWorld.
the class MessageBulkDeleteHandler method handleInternally.
@Override
protected Long handleInternally(DataObject content) {
if (!content.isNull("guild_id")) {
long guildId = content.getLong("guild_id");
if (getJDA().getGuildSetupController().isLocked(guildId))
return guildId;
}
final long channelId = content.getLong("channel_id");
if (getJDA().isBulkDeleteSplittingEnabled()) {
SocketHandler handler = getJDA().getClient().getHandlers().get("MESSAGE_DELETE");
content.getArray("ids").forEach(id -> {
handler.handle(responseNumber, DataObject.empty().put("t", "MESSAGE_DELETE").put("d", DataObject.empty().put("channel_id", Long.toUnsignedString(channelId)).put("id", id)));
});
} else {
// TODO-v5-unified-channel-cache
GuildMessageChannel channel = getJDA().getTextChannelById(channelId);
if (channel == null)
channel = getJDA().getNewsChannelById(channelId);
if (channel == null)
channel = getJDA().getThreadChannelById(channelId);
if (channel == null) {
getJDA().getEventCache().cache(EventCache.Type.CHANNEL, channelId, responseNumber, allContent, this::handle);
EventCache.LOG.debug("Received a Bulk Message Delete for a GuildMessageChannel that is not yet cached.");
return null;
}
if (getJDA().getGuildSetupController().isLocked(channel.getGuild().getIdLong()))
return channel.getGuild().getIdLong();
DataArray array = content.getArray("ids");
List<String> messages = array.stream(DataArray::getString).collect(Collectors.toList());
getJDA().handleEvent(new MessageBulkDeleteEvent(getJDA(), responseNumber, channel, messages));
}
return null;
}
use of net.dv8tion.jda.api.entities.GuildMessageChannel in project BotCommands by freya022.
the class HelpCommand method sendCommandHelp.
public void sendCommandHelp(BaseCommandEvent event, CommandPath cmdPath) {
TextCommandCandidates cmds = event.getContext().findCommands(cmdPath);
if (cmds == null) {
event.respond("Command '" + getSpacedPath(cmdPath) + "' does not exist").queue(null, event.failureReporter("Failed to send help"));
return;
}
final Member member = event.getMember();
final GuildMessageChannel channel = event.getGuildChannel();
final Usability usability = Usability.of(context, cmds.first(), member, channel, !context.isOwner(member.getIdLong()));
if (usability.isNotShowable()) {
event.respond("Command '" + getSpacedPath(cmdPath) + "' does not exist").queue(null, event.failureReporter("Failed to send help"));
return;
}
final EmbedBuilder embed = getCommandHelpEmbed(event, cmds);
event.respond(embed.build()).queue();
}
use of net.dv8tion.jda.api.entities.GuildMessageChannel in project JDA by DV8FromTheWorld.
the class MessageReactionClearEmoteHandler method handleInternally.
@Override
protected Long handleInternally(DataObject content) {
long guildId = content.getUnsignedLong("guild_id");
if (getJDA().getGuildSetupController().isLocked(guildId))
return guildId;
Guild guild = getJDA().getGuildById(guildId);
if (guild == null) {
EventCache.LOG.debug("Caching MESSAGE_REACTION_REMOVE_EMOJI event for unknown guild {}", guildId);
getJDA().getEventCache().cache(EventCache.Type.GUILD, guildId, responseNumber, allContent, this::handle);
return null;
}
long channelId = content.getUnsignedLong("channel_id");
// TODO-v5-unified-channel-cache
GuildMessageChannel channel = guild.getTextChannelById(channelId);
if (channel == null)
channel = guild.getNewsChannelById(channelId);
if (channel == null)
channel = guild.getThreadChannelById(channelId);
if (channel == null) {
EventCache.LOG.debug("Caching MESSAGE_REACTION_REMOVE_EMOJI event for unknown channel {}", channelId);
getJDA().getEventCache().cache(EventCache.Type.CHANNEL, channelId, responseNumber, allContent, this::handle);
return null;
}
long messageId = content.getUnsignedLong("message_id");
DataObject emoji = content.getObject("emoji");
MessageReaction.ReactionEmote reactionEmote = null;
if (emoji.isNull("id")) {
reactionEmote = MessageReaction.ReactionEmote.fromUnicode(emoji.getString("name"), getJDA());
} else {
long emoteId = emoji.getUnsignedLong("id");
Emote emote = getJDA().getEmoteById(emoteId);
if (emote == null) {
emote = new EmoteImpl(emoteId, getJDA()).setAnimated(emoji.getBoolean("animated")).setName(emoji.getString("name", ""));
}
reactionEmote = MessageReaction.ReactionEmote.fromCustom(emote);
}
MessageReaction reaction = new MessageReaction(channel, reactionEmote, messageId, false, 0);
getJDA().handleEvent(new MessageReactionRemoveEmoteEvent(getJDA(), responseNumber, messageId, channel, reaction));
return null;
}
Aggregations