execute method

  1. @override
Future<String> execute(
  1. CommandContext context
)
override

Implementation

@override
Future<String> execute(CommandContext context) async {
  if (!context.hasArgs) {
    return '❌ Please provide track position!';
  }

  final position = int.tryParse(context.args[0]);
  if (position == null || position < 1) {
    return '❌ Invalid position!';
  }

  final player = context.player;
  final index = position - 1;

  if (index >= player.queueLength) {
    return '❌ Position out of range!';
  }

  final track = player.queue[index];
  player.removeFromQueue(index);

  return '🗑️ Removed: **${track.info.title}**';
}