Search in sources :

Example 1 with GuildMessageChannel

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()));
}
Also used : Commands(net.dv8tion.jda.api.interactions.commands.build.Commands) SlashCommandContext(at.xirado.bean.command.SlashCommandContext) GuildAudioPlayer(at.xirado.bean.music.GuildAudioPlayer) SlashCommandInteractionEvent(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent) SlashCommand(at.xirado.bean.command.SlashCommand) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) GuildMessageChannel(net.dv8tion.jda.api.entities.GuildMessageChannel) Bean(at.xirado.bean.Bean) NotNull(org.jetbrains.annotations.NotNull) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) GuildAudioPlayer(at.xirado.bean.music.GuildAudioPlayer) GuildMessageChannel(net.dv8tion.jda.api.entities.GuildMessageChannel)

Example 2 with GuildMessageChannel

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;
}
Also used : MessageBulkDeleteEvent(net.dv8tion.jda.api.events.message.MessageBulkDeleteEvent) DataArray(net.dv8tion.jda.api.utils.data.DataArray) GuildMessageChannel(net.dv8tion.jda.api.entities.GuildMessageChannel)

Example 3 with GuildMessageChannel

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();
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) Member(net.dv8tion.jda.api.entities.Member) Usability(com.freya02.botcommands.internal.Usability) GuildMessageChannel(net.dv8tion.jda.api.entities.GuildMessageChannel)

Example 4 with GuildMessageChannel

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;
}
Also used : MessageReaction(net.dv8tion.jda.api.entities.MessageReaction) EmoteImpl(net.dv8tion.jda.internal.entities.EmoteImpl) MessageReactionRemoveEmoteEvent(net.dv8tion.jda.api.events.message.react.MessageReactionRemoveEmoteEvent) DataObject(net.dv8tion.jda.api.utils.data.DataObject) Emote(net.dv8tion.jda.api.entities.Emote) Guild(net.dv8tion.jda.api.entities.Guild) GuildMessageChannel(net.dv8tion.jda.api.entities.GuildMessageChannel)

Aggregations

GuildMessageChannel (net.dv8tion.jda.api.entities.GuildMessageChannel)4 Bean (at.xirado.bean.Bean)1 SlashCommand (at.xirado.bean.command.SlashCommand)1 SlashCommandContext (at.xirado.bean.command.SlashCommandContext)1 GuildAudioPlayer (at.xirado.bean.music.GuildAudioPlayer)1 Usability (com.freya02.botcommands.internal.Usability)1 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)1 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)1 Emote (net.dv8tion.jda.api.entities.Emote)1 Guild (net.dv8tion.jda.api.entities.Guild)1 Member (net.dv8tion.jda.api.entities.Member)1 MessageReaction (net.dv8tion.jda.api.entities.MessageReaction)1 SlashCommandInteractionEvent (net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent)1 MessageBulkDeleteEvent (net.dv8tion.jda.api.events.message.MessageBulkDeleteEvent)1 MessageReactionRemoveEmoteEvent (net.dv8tion.jda.api.events.message.react.MessageReactionRemoveEmoteEvent)1 Commands (net.dv8tion.jda.api.interactions.commands.build.Commands)1 DataArray (net.dv8tion.jda.api.utils.data.DataArray)1 DataObject (net.dv8tion.jda.api.utils.data.DataObject)1 EmoteImpl (net.dv8tion.jda.internal.entities.EmoteImpl)1 NotNull (org.jetbrains.annotations.NotNull)1