Search in sources :

Example 11 with Command

use of com.jagrosh.jdautilities.command.Command in project flowermoon by wolf-yuan-6115.

the class PlayCmd method doCommand.

@Override
public void doCommand(CommandEvent event) {
    if (event.getArgs().isEmpty() && event.getMessage().getAttachments().isEmpty()) {
        AudioHandler handler = (AudioHandler) event.getGuild().getAudioManager().getSendingHandler();
        if (handler.getPlayer().getPlayingTrack() != null && handler.getPlayer().isPaused()) {
            if (DJCommand.checkDJPermission(event)) {
                handler.getPlayer().setPaused(false);
                event.replySuccess("繼續播放 **" + handler.getPlayer().getPlayingTrack().getInfo().title + "**.");
            } else
                event.replyError("只有擁有DJ權限的成員可以繼續播放歌曲!");
            return;
        }
        StringBuilder builder = new StringBuilder(event.getClient().getWarning() + " 播放指令:\n");
        builder.append("\n`").append(event.getClient().getPrefix()).append(name).append(" <標題>` - 播放YouTube上的音樂");
        builder.append("\n`").append(event.getClient().getPrefix()).append(name).append(" <網址>` - 播放歌曲,播放清單或直播音樂");
        for (Command cmd : children) builder.append("\n`").append(event.getClient().getPrefix()).append(name).append(" ").append(cmd.getName()).append(" ").append(cmd.getArguments()).append("` - ").append(cmd.getHelp());
        event.reply(builder.toString());
        return;
    }
    String args = event.getArgs().startsWith("<") && event.getArgs().endsWith(">") ? event.getArgs().substring(1, event.getArgs().length() - 1) : event.getArgs().isEmpty() ? event.getMessage().getAttachments().get(0).getUrl() : event.getArgs();
    event.reply(loadingEmoji + " 載入中... `[" + args + "]`", m -> bot.getPlayerManager().loadItemOrdered(event.getGuild(), args, new ResultHandler(m, event, false)));
}
Also used : Command(com.jagrosh.jdautilities.command.Command) DJCommand(com.jagrosh.jmusicbot.commands.DJCommand) MusicCommand(com.jagrosh.jmusicbot.commands.MusicCommand) AudioLoadResultHandler(com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler) AudioHandler(com.jagrosh.jmusicbot.audio.AudioHandler)

Example 12 with Command

use of com.jagrosh.jdautilities.command.Command in project flowermoon by wolf-yuan-6115.

the class PlaylistCmd method execute.

@Override
public void execute(CommandEvent event) {
    StringBuilder builder = new StringBuilder(event.getClient().getWarning() + " 播放清單管理指令:\n");
    for (Command cmd : this.children) builder.append("\n`").append(event.getClient().getPrefix()).append(name).append(" ").append(cmd.getName()).append(" ").append(cmd.getArguments() == null ? "" : cmd.getArguments()).append("` - ").append(cmd.getHelp());
    event.reply(builder.toString());
}
Also used : Command(com.jagrosh.jdautilities.command.Command) OwnerCommand(com.jagrosh.jmusicbot.commands.OwnerCommand)

Aggregations

Command (com.jagrosh.jdautilities.command.Command)12 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)5 SlashCommand (com.jagrosh.jdautilities.command.SlashCommand)3 CommandEvent (com.jagrosh.jdautilities.command.CommandEvent)2 AudioHandler (com.jagrosh.jmusicbot.audio.AudioHandler)2 DJCommand (com.jagrosh.jmusicbot.commands.DJCommand)2 MusicCommand (com.jagrosh.jmusicbot.commands.MusicCommand)2 OwnerCommand (com.jagrosh.jmusicbot.commands.OwnerCommand)2 PaginatedCommand (com.mcmoddev.mmdbot.modules.commands.community.PaginatedCommand)2 AudioLoadResultHandler (com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler)2 IOException (java.io.IOException)2 SwearHandler (org.geysermc.discordbot.listeners.SwearHandler)2 CommandClientBuilder (com.jagrosh.jdautilities.command.CommandClientBuilder)1 SlashCommandEvent (com.jagrosh.jdautilities.command.SlashCommandEvent)1 EventWaiter (com.jagrosh.jdautilities.commons.waiter.EventWaiter)1 MMDBot (com.mcmoddev.mmdbot.MMDBot)1 GistUtils (com.mcmoddev.mmdbot.gist.GistUtils)1 Utils (com.mcmoddev.mmdbot.utilities.Utils)1 ScriptTrick (com.mcmoddev.mmdbot.utilities.tricks.ScriptTrick)1 Trick (com.mcmoddev.mmdbot.utilities.tricks.Trick)1